Skip to content

Commit 17740fd

Browse files
committedFeb 11, 2015
fetch build from github and copy to dev server
1 parent 5fbdbec commit 17740fd

File tree

2 files changed

+69
-4
lines changed

2 files changed

+69
-4
lines changed
 

‎.gitignore

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
*.py[cod]
2+
.token
3+
14
*.swp
25
*~
36

4-
RAMP/
5-
ramp-theme-canada/
6-
ramp-theme-intranet/
7-
ramp-theme-usability/
7+
[iI]nclude/
8+
[lL]ib/
9+
lib64
10+
Scripts/
11+
bin/

‎fetchdist.py

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import requests, shutil, zipfile, os, sys
2+
from StringIO import StringIO
3+
4+
paths = {
5+
'core': { 'repo':'ramp-pcar-dist', 'ref':None },
6+
'canada': { 'repo':'ramp-theme-dist', 'ref':'ramp-theme-canada' },
7+
'intranet': { 'repo':'ramp-theme-dist', 'ref':'ramp-theme-intranet' },
8+
'usability': { 'repo':'ramp-theme-dist', 'ref':'ramp-theme-usability' },
9+
}
10+
11+
def fetch_theme( fname, extract_path, auth ):
12+
j = requests.get( url, auth=auth ).json()
13+
for asset in j:
14+
print asset.get('name','NO NAME')
15+
if asset.get('name','NO NAME') == fname:
16+
break
17+
else:
18+
print 'NOT FOUND'
19+
return
20+
21+
dl_url = asset.get('download_url','NO URL')
22+
print dl_url
23+
a = requests.get(dl_url, auth=auth)
24+
if a.status_code == 200:
25+
data = StringIO(a.content)
26+
with zipfile.ZipFile(data, "r") as z:
27+
z.extractall( extract_path )
28+
else:
29+
print 'status:', a.status_code
30+
31+
if __name__ == '__main__':
32+
33+
if len(sys.argv) < 2:
34+
print 'Usage {0} [version]'.format(sys.argv[0])
35+
sys.exit(1)
36+
ver = sys.argv[1]
37+
tok = None
38+
with open('.token') as f:
39+
tok = f.read().strip()
40+
print 'Fetching RAMP v{0}'.format(ver)
41+
tag = 'v'+ver
42+
auth = (tok,'x-oauth-basic')
43+
os.mkdir( tag )
44+
for theme in paths:
45+
paths[theme]['path'] = os.path.join( tag, theme )
46+
if not paths[theme]['ref']:
47+
paths[theme]['ref'] = tag
48+
paths[theme]['filename'] = 'ramp-pcar-dist-{0}.zip'.format(ver)
49+
else:
50+
paths[theme]['filename'] = 'ramp-theme-{0}-dist-{1}.zip'.format(theme,ver)
51+
os.mkdir( paths[theme]['path'] )
52+
for theme in paths:
53+
url = 'https://api.github.com/repos/RAMP-PCAR/{repo}/contents/tarball?ref={ref}'.format( **paths[theme] )
54+
fetch_theme( paths[theme]['filename'], paths[theme]['path'], auth )
55+
shutil.copytree( tag, 'x:\\wwwroot\\RAMP_QC\\{0}'.format(tag) )
56+
57+
# if a.status_code == 200:
58+
# with open(zfile, 'wb') as f:
59+
# for chunk in a.iter_content(1024):
60+
# f.write(chunk)
61+

0 commit comments

Comments
 (0)