10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-18 20:13:07 +01:00
quantum_package/install/scripts/fetch_from_web.py
2015-06-05 22:33:19 +02:00

34 lines
550 B
Python
Executable File

#!/usr/bin/env python
import urllib
import sys
__author__ = "Anthony Scemama"
__date__ = "Mon Apr 7 15:30:29 CEST 2014"
"""Fetches a file from a given URL.
syntax : %s <URL> <local_filename>"""%(sys.argv[0])
# Check command line
if len(sys.argv) < 3:
print """
usage:
%s <URL> <local_filename>"""%(sys.argv[0])
URL = sys.argv[1]
filename = sys.argv[2]
webpage = urllib.urlopen(URL)
data = webpage.read()
if "404 - Not Found" in data:
print "Error in URL"
sys.exit(1)
file = open(filename,'w')
file.write(data)
file.close()