Created
June 4, 2013 06:17
-
-
Save fakechris/5703940 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import simplejson | |
import subprocess | |
USERNAME='user' | |
PROJECT='prj' | |
HOST='192.168.0.1' | |
ls_cmd = "ssh -p 29418 %s@%s gerrit query limit:1000 --current-patch-set --format=json status:open project:%s" % (USERNAME, HOST, PROJECT) | |
submit_cmd = "ssh -p 29418 %s@%s gerrit review --code-review 2 --abandon %s" | |
def submit(cmd): | |
print "submmitting ", cmd | |
proc = subprocess.Popen(cmd.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
out, err = proc.communicate() | |
proc = subprocess.Popen(ls_cmd.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
out, err = proc.communicate() | |
retcode = proc.returncode | |
for result in reversed(out.split("\n")): | |
try: | |
jsonr = simplejson.loads(result) | |
changeid = jsonr['currentPatchSet']['revision'] | |
full_submit_cmd = submit_cmd % (USERNAME, HOST, changeid) | |
submit(full_submit_cmd) | |
except: | |
print "Decode failed", result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment