This repository has been archived by the owner on Jan 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding get_binaries.py and ipbus to the list of uploads
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
from urllib2 import urlopen, URLError, HTTPError | ||
from ast import literal_eval | ||
from optparse import OptionParser | ||
|
||
parser = OptionParser() | ||
parser.add_option("-t", "--tag", dest="tag", | ||
help="Tag name", metavar="tag") | ||
parser.add_option("-l", "--uploads", dest="uploads", | ||
help="List of files to upload\n Should be a dict:\n {\"filename\":\"path_to_file\"}", metavar="uploads") | ||
|
||
def dlfile(url, local_path): | ||
# Open the url | ||
try: | ||
f = urlopen(url) | ||
print "downloading " + url | ||
|
||
# Open our local file for writing | ||
with open(local_path, "wb") as local_file: | ||
local_file.write(f.read()) | ||
|
||
#handle errors | ||
except HTTPError, e: | ||
print "HTTP Error:", e.code, url | ||
except URLError, e: | ||
print "URL Error:", e.reason, url | ||
|
||
|
||
def main(): | ||
# parse command line options | ||
(options,args) = parser.parse_args() | ||
base_url = "https://github.com/cms-gem-daq-project/xhal/releases/download/" | ||
uploads_dict = {} | ||
with open(options.uploads,'r') as f: | ||
uploads_dict = literal_eval(f.read()) | ||
for key,val in uploads_dict.iteritems(): | ||
url = base_url+options.tag+"/"+key | ||
local_path = val.replace('$XHAL_ROOT', os.getenv('XHAL_ROOT')) | ||
dlfile(url, local_path) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters