userland-fetch revision 42
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
# fetch.py - a file download utility
#
# A simple program similiar to wget(1), but handles local file copy, ignores
# directories, and verifies file hashes.
#
try:
return False
if (hash == None):
return True
try:
m = hashlib.new(algorithm)
return False
while True:
if block == '':
break
try:
return None
try:
return None
while True:
if block == '':
break;
# return the name of the file that we downloaded the data to.
return filename
if tmp:
# filename should always be first
urls.insert(0, filename)
# command line url is a fallback, so it's last
return urls
print "Usage: %s [-f|--file (file)] [-l|--link] [-h|--hash (hash)] [-s|--search (search-dir)] --url (url)" % (sys.argv[0].split('/')[-1])
sys.exit(1)
# FLUSH STDOUT
try:
["file=", "link", "hash=", "search=", "url="])
usage()
else:
usage()
print "Source %s..." % url,
print "not found, skipping"
continue
print "copying...",
else:
print "linking...",
else:
print "downloading...",
print "failed"
continue
print "validating...",
print "ok"
sys.exit(0)
else:
print "corrupt"
try:
sys.exit(1)
if __name__ == "__main__":
main()