Download:
child 173:30e27c4a23c6
parent 171:dd72c5809c96
172:5be4b5a42212
Anton Shestakov <av6@dwimlabs.net>, Thu, 21 Jul 2016 23:38:15 +0800
queue: add push() to BaseHookHandler

1 файлов изменено, 12 вставок(+), 9 удалений(-) [+]
hooks-queue.py file | annotate | diff | comparison | revisions
--- a/hooks-queue.py Thu Jul 21 23:35:01 2016 +0800
+++ b/hooks-queue.py Thu Jul 21 23:38:15 2016 +0800
@@ -23,6 +23,17 @@
def rconn(self):
return self.application.rconn
+ def push(self, base, hashes):
+ for hash_ in hashes:
+ item = base.copy()
+ item['change'] = hash_
+ data = json.dumps(item)
+ logging.debug('Pushing %s', data)
+ self.rconn.rpush('candolint:queue:changes', data)
+ logging.info('Pushed a change for %s', item['repo'])
+
+ self.finish({'result': 'OK', 'queued': len(hashes)})
+
class BitbucketHookHandler(BaseHookHandler):
def post(self):
@@ -41,15 +52,7 @@
hashes.add(head['hash'])
hashes.add(change['new']['target']['hash'])
- for hash_ in hashes:
- item = base.copy()
- item['change'] = hash_
- data = json.dumps(item)
- logging.debug('Pushing %s', data)
- self.rconn.rpush('candolint:queue:changes', data)
- logging.info('Pushed a change for %s', item['repo'])
-
- self.finish({'result': 'OK', 'queued': len(hashes)})
+ self.push(base, hashes)
class CandolintHooks(Application):