-
Notifications
You must be signed in to change notification settings - Fork 455
/
create_post.py
41 lines (28 loc) · 947 Bytes
/
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
import argparse
import boto
import requests
pulls_url = "https://api.github.com/repos/hawkthorne/hawkthorne-journey/pulls"
GITHUB_TIME = "%Y-%m-%dT%H:%M:%SZ"
def post_content():
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']
def commithash(version):
bucket = boto.s3.get_bucket("files.projecthawkthorne.com", validate=False)
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('output', type=argparse.FileType('w'))
args = parser.parse_args()
args.output.write(post_content())
if __name__ == "__main__":
main()