#
# 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.
#
""" Function to decode and print IOError type exception """
try:
print str(e)
# force migration away from sha1
if algorithm == "sha1":
algorithm = "sha256"
try:
m = hashlib.new(algorithm)
return False
while True:
try:
break
if block == '':
break
try:
return False
try:
if expr_bz.match(filename):
elif expr_gz.match(filename):
elif expr_tgz.match(filename):
else:
return False
return False
try:
return None
# 3xx, 4xx and 5xx (f|ht)tp codes designate unsuccessfull action
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 file copy"
continue
print "\n copying..."
else:
print "\n linking..."
else:
print "\n downloading...",
print "failed"
continue
print "\n validating...",
print "skipping (no hash)"
sys.exit(0)
print "ok"
sys.exit(0)
else:
if payloadhash == hash_arg:
print "ok"
sys.exit(0)
print "corruption detected"
print " expected: %s" % hash_arg
print " actual: %s" % realhash
print " payload: %s" % payloadhash
try:
sys.exit(1)
if __name__ == "__main__":
main()