userland-fetch revision 137
911N/A# The contents of this file are subject to the terms of the 761N/A# Common Development and Distribution License (the "License"). 0N/A# You may not use this file except in compliance with the License. 0N/A# See the License for the specific language governing permissions 0N/A# and limitations under the License. 0N/A# When distributing Covered Code, include this CDDL HEADER in each 0N/A# If applicable, add the following below this CDDL HEADER, with the 0N/A# fields enclosed by brackets "[]" replaced with your own identifying 0N/A# information: Portions Copyright [yyyy] [name of copyright owner] 0N/A# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A# A simple program similiar to wget(1), but handles local file copy, ignores 0N/A# directories, and verifies file hashes. 0N/A """ Function to decode and print IOError type exception """ # return the name of the file that we downloaded the data to. # filename should always be first # command line url is a fallback, so it's last print "Usage: %s [-f|--file (file)] [-l|--link] [-h|--hash (hash)] [-s|--search (search-dir)] --url (url)" %
(sys.argv[0].split('/')[-1]) ["file=", "link", "hash=", "search=", "url="]) if opt in [
"-f",
"--file" ]:
elif opt in [
"-l",
"--link" ]:
elif opt in [
"-h",
"--hash" ]:
elif opt in [
"-s",
"--search" ]:
elif opt in [
"-u",
"--url" ]:
print "Source %s..." %
url,
print "not found, skipping file copy" elif scheme in [
'http',
'https',
'ftp' ]:
print "\n downloading...",
print "\n validating...",
print "skipping (no hash)" print "corruption detected"