Commit 51f49c61a7c67f549d8222fbe6a2553c6650a143
1 parent
dd4560bd
Exists in
master
and in
39 other branches
Fixed some deprecated things and bugs
Showing
2 changed files
with
12 additions
and
15 deletions
Show diff stats
src/badger/management/commands/update_badges.py
... | ... | @@ -11,21 +11,13 @@ import logging |
11 | 11 | class Command(BaseCommand): |
12 | 12 | help = "Update the user's badges" |
13 | 13 | |
14 | - def search(self, object_type, **opts={}): | |
15 | - try: | |
16 | - sqs = SearchQuerySet().filter(type=object_type, **opts) | |
17 | - except Exception, e: | |
18 | - logging.except(e) | |
19 | - raise | |
20 | - return sqs | |
21 | - | |
22 | - def handle(self, *args, **kwargs): | |
14 | + def update_badges(self): | |
23 | 15 | for badge in Badge.objects.filter(type='auto'): |
24 | 16 | if not badge.comparison: |
25 | 17 | continue |
26 | 18 | elif badge.comparison == 'biggest': |
27 | 19 | order = u'-{}'.format(Badge.USER_ATTR_OPTS[badge.user_attr]) |
28 | - sqs = self.search('user') | |
20 | + sqs = SearchQuerySet().filter(type='user') | |
29 | 21 | user = sqs.order_by(order)[0] |
30 | 22 | badge.awardees.add(User.objects.get(pk=user.pk)) |
31 | 23 | continue |
... | ... | @@ -39,7 +31,14 @@ class Command(BaseCommand): |
39 | 31 | ) |
40 | 32 | opts = {key: badge.value} |
41 | 33 | |
42 | - sqs = self.search('user', **opts) | |
34 | + sqs = SearchQuerySet().filter(type='user', **opts) | |
43 | 35 | |
44 | 36 | for user in sqs: |
45 | 37 | badge.awardees.add(User.objects.get(pk=user.pk)) |
38 | + | |
39 | + def handle(self, *args, **kwargs): | |
40 | + try: | |
41 | + self.update_badges() | |
42 | + except Exception as e: | |
43 | + logging.exception(e) | |
44 | + raise | ... | ... |
src/super_archives/management/commands/import_emails.py
... | ... | @@ -282,11 +282,9 @@ class Command(BaseCommand, object): |
282 | 282 | try: |
283 | 283 | self.import_emails(archives_path, |
284 | 284 | options.get('all'), options.get('exclude_lists')) |
285 | - except Exception, e: | |
286 | - logging.except(e) | |
285 | + except Exception as e: | |
286 | + logging.exception(e) | |
287 | 287 | raise |
288 | 288 | finally: |
289 | 289 | os.remove(self.lock_file) |
290 | 290 | |
291 | - os.remove(self.lock_file) | |
292 | - | ... | ... |