forked from cginternals/khrbinding-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.py
36 lines (26 loc) · 824 Bytes
/
update.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
#!/usr/bin/python
import os, sys, getopt, io, subprocess
import json
def update(url, outputfile):
print("Retrieving latest revision of " + outputfile)
os.system("curl " + url + " > " + outputfile)
def main(argv):
try:
opts, args = getopt.getopt(argv[1:], "p:", ["profile="])
except getopt.GetoptError:
print("usage: %s -p <profile JSON>" % argv[0])
sys.exit(1)
profile = None
for opt, arg in opts:
if opt in ("-p", "--profile"):
profile = arg
if profile == None:
print("no profile given")
sys.exit(1)
if not os.path.isfile(profile):
print("Profile not readable")
sys.exit(1)
p = json.load(open(profile))
update(p["sourceUrl"], p["sourceFile"])
if __name__ == "__main__":
main(sys.argv)