-
Notifications
You must be signed in to change notification settings - Fork 454
/
create_post.py
57 lines (40 loc) · 1.33 KB
/
create_post.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import sys
from datetime import datetime
import argparse
import boto
import requests
import jinja2
import json
import time
import subprocess
import version
pulls_url = "https://api.github.com/repos/hawkthorne/hawkthorne-journey/pulls"
compare_url = "https://github.com/hawkthorne/hawkthorne-journey/compare/{}...{}"
GITHUB_TIME = "%Y-%m-%dT%H:%M:%SZ"
def post_content(base, head):
if base is None or head is None:
url = ""
else:
url = compare_url(base, head)
resp = requests.get(pulls_url, params={'state': 'closed', 'base': 'release'})
pulls = resp.json()
if not pulls:
raise ValueError(('No pull request for this release, which means no'
'post'))
return pulls[0]['body'] + "\n" + url
def commithash(version):
bucket = boto.s3.get_bucket("files.projecthawkthorne.com")
key = bucket.get_key("releases/v{}/hawkthorne-osx.zip".format(version))
if key is None:
return key
return key.get_contents()
def main():
parser = argparse.ArgumentParser()
parser.add_argument('commit_hash')
parser.add_argument('output', type=argparse.FileType('w'))
args = parser.parse_args()
prevous_hash = commithash(version.prev_version)
args.output.write(post_content(previous_hash, args.commit_hash))
if __name__ == "__main__":
main()