Yuvipanda has uploaded a new change for review.
https://gerrit.wikimedia.org/r/77691
Change subject: Make github -> gerrit sync read from Redis
......................................................................
Make github -> gerrit sync read from Redis
This lets it be run as a continuous task, rather than as individual
tasks that are submitted by the webhost.
Change-Id: I96b3bcc16370fd1638bc6083753afd585aedc7a0
---
M suchabot/sync.py
1 file changed, 20 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/labs/tools/SuchABot
refs/changes/91/77691/1
diff --git a/suchabot/sync.py b/suchabot/sync.py
index 8d7f0b5..6915557 100644
--- a/suchabot/sync.py
+++ b/suchabot/sync.py
@@ -2,6 +2,7 @@
import sys
import logging
+import redis
import github
import sh
import jinja2
@@ -29,6 +30,9 @@
config = yaml.load(f)
gh = github.GitHub(username=config['github']['username'],
password=config['github']['password'])
+REDIS_DB = config['redis']['db']
+REDIS_HOST = config['redis']['host']
+PREFIX = config['github_receiver']['redis_prefix']
def is_git_repo(path):
return os.path.exists(path) and os.path.exists(os.path.join(path, '.git'))
@@ -145,11 +149,23 @@
if __name__ == '__main__':
name = sys.argv[1]
pr_num = sys.argv[2]
- job_id = os.environ['JOB_ID']
- logging.basicConfig(format='%%(asctime)s %s PR#%s Job#%s %%(message)s' %
(name, pr_num, job_id), filename=os.path.expanduser('~/logs/%s.process' %
name), level=logging.INFO)
+ logging.basicConfig(
+ format='%%(asctime)s %s PR#%s %%(message)s' % (name, pr_num),
+ filename=os.path.expanduser('~/logs/%s.process' % name),
+ level=logging.INFO
+ )
+
+ logging.info('Attempting to Redis connection to %s', REDIS_HOST)
+ red = redis.StrictRedis(host=REDIS_HOST, db=REDIS_DB)
+ logging.info('Redis connection to %s succeded', REDIS_HOST)
+
try:
- do_review(get_pullreq(name, pr_num))
+ while True:
+ data = json.loads(red.brpop(CLIENT_KEY)[1])
+ do_review(data)
except:
- gh.repos(OWNER, name).issues(pr_num).comments.post(body='Sorry, an
error occured :( @yuvipanda will now be notified that job#%s did not end well'
% job_id)
+ gh.repos(OWNER, name).issues(pr_num).comments.post(body='Sorry, an
error occured :( @yuvipanda will now be notified that this sync did not end
well')
logging.exception("Error!")
+ finally:
+ sys.exit(-1)
--
To view, visit https://gerrit.wikimedia.org/r/77691
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I96b3bcc16370fd1638bc6083753afd585aedc7a0
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/SuchABot
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits