Skip to content

Instantly share code, notes, and snippets.

@nibalizer
Created December 14, 2016 22:00
Show Gist options
  • Save nibalizer/2e22f7c4649a1d1ccbd34337710fd6a7 to your computer and use it in GitHub Desktop.
Save nibalizer/2e22f7c4649a1d1ccbd34337710fd6a7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# All the hard parts of this is written by Greg Haynes and is (c) IBM
# All bugs are mine
import json
import os
import sys
import pdfkit
import requests
gerrit_hostname = os.environ.get('GERRIT_HOSTNAME', 'review.openstack.org')
if __name__ == "__main__":
change_id = sys.argv[1]
r = requests.get(
'https://%s/changes/%s/detail?O=404' %
(gerrit_hostname, change_id)
)
#print r.text
detail = json.loads(r.text[4:])
#print json.dumps(detail["messages"] , indent=4, sort_keys=True)
#print detail['messages']
output = ""
for message in detail['messages']:
output += '\n\n\n'
print message['author']['name']
output += message['author']['name'] + '\n'
print message['message']
output += message['message'] + '\n'
pdfkit.from_string(output, 'out.pdf')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment