summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Velasquez <angvp@archlinux.org>2017-05-17 23:02:18 -0400
committerAngel Velasquez <angvp@archlinux.org>2017-05-17 23:02:18 -0400
commit49694232e2277212769bb5b174362dcf69db3408 (patch)
tree531c06c695d4af0eab0d5741feea4e87084422ec
parentf6887d0572f8781c31f72d31115e671d3da3e1a0 (diff)
downloadarchweb-49694232e2277212769bb5b174362dcf69db3408.tar.gz
archweb-49694232e2277212769bb5b174362dcf69db3408.zip
Fix reporead_inotify command
It was broken since the migration to Django 1.8, also some pep8 modifications were done in order to improve the code quality
-rw-r--r--devel/management/commands/reporead_inotify.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/devel/management/commands/reporead_inotify.py b/devel/management/commands/reporead_inotify.py
index 1422ae26..fadcb881 100644
--- a/devel/management/commands/reporead_inotify.py
+++ b/devel/management/commands/reporead_inotify.py
@@ -35,6 +35,7 @@ logging.basicConfig(
stream=sys.stderr)
logger = logging.getLogger()
+
class Command(BaseCommand):
help = "Watch database files and run an update when necessary."
args = "[path_template]"
@@ -73,16 +74,16 @@ class Command(BaseCommand):
directories we need to watch for database updates. It then validates
and passes these on to the various pyinotify pieces as necessary and
finally builds and returns a notifier object.'''
- transaction.commit_manually()
- arches = Arch.objects.filter(agnostic=False)
- repos = Repo.objects.all()
- transaction.set_dirty()
+ with transaction.atomic():
+ arches = Arch.objects.filter(agnostic=False)
+ repos = Repo.objects.all()
+
arch_path_map = {arch: None for arch in arches}
all_paths = set()
total_paths = 0
for arch in arches:
- combos = ({ 'repo': repo.name.lower(), 'arch': arch.name }
- for repo in repos)
+ combos = ({'repo': repo.name.lower(), 'arch': arch.name}
+ for repo in repos)
# take a python format string and generate all unique combinations
# of directories from it; using set() ensures we filter it down
paths = {self.path_template % values for values in combos}
@@ -97,7 +98,7 @@ class Command(BaseCommand):
# template mapped to only one architecture
if total_paths != len(all_paths):
raise CommandError('path template did not uniquely '
- 'determine architecture for each file')
+ 'determine architecture for each file')
# A proper atomic replacement of the database as done by rsync is type
# IN_MOVED_TO. repo-add/remove will finish with a IN_CLOSE_WRITE.
@@ -131,7 +132,7 @@ class Database(object):
def _start_update_countdown(self):
self.update_thread = threading.Timer(self.delay, self.update)
logger.info('Starting %.1f second countdown to update %s',
- self.delay, self.path)
+ self.delay, self.path)
self.update_thread.start()
def queue_for_update(self, mtime):