+def get_github_payload(repo, signature):
+ '''Return the github-style JSON encoded payload (as if we were called as a github webhook)'''
+ data = sys.stdin.buffer.read()
+ verify_signature = repo.compute_hmac(data)
+ if signature != "sha1="+verify_signature:
+ raise Exception("You are not GitHub!")
+ try:
+ data = json.loads(data.decode('utf-8'))
+ return data
+ except ValueError:
+ return {} # nothing read
+
+