Changeset 6786
- Timestamp:
- Apr 14, 2009, 12:08:23 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/numpy/anuga/utilities/system_tools.py
r6689 r6786 314 314 return map(string.rstrip, [''.join(x) for x in ll]) 315 315 316 ################################################################################ 316 317 317 318 ## … … 354 355 # @param auth Auth tuple (httpproxy, proxyuser, proxypass). 355 356 # @param blocksize Read file in this block size. 356 # @return 'auth' tuple for subsequent calls, if successful .357 # @return 'auth' tuple for subsequent calls, if successful, else False. 357 358 # @note If 'auth' not supplied, will prompt user. 358 359 # @note Will try using environment variable HTTP_PROXY for proxy server. … … 360 361 # @note Will try using environment variable PROXY_PASSWORD for proxy password. 361 362 def get_web_file(file_url, file_name, auth=None, blocksize=1024*1024): 362 '''Get a file from the web .363 '''Get a file from the web (HTTP). 363 364 364 365 file_url: The URL of the file to get … … 380 381 return None # no proxy, no auth required 381 382 except IOError, e: 382 if e[1] != 407: 383 raise # raise error if *not* proxy auth error 383 if e[1] == 407: # proxy error 384 pass 385 elif e[1][0] == 113: # no route to host 386 print 'No route to host for %s' % file_url 387 return False # return False 388 else: 389 print 'Unknown connection error to %s' % file_url 390 return False 384 391 385 392 # We get here if there was a proxy error, get file through the proxy … … 401 408 if httpproxy is None or proxyuser is None or proxypass is None: 402 409 print '-'*80 403 print ('You need to supply proxy authentication information. ' 404 'Use environment variables\n' 405 'HTTP_PROXY, PROXY_USERNAME and PROXY_PASSWORD to bypass ' 406 'entry here:') 410 print ('You need to supply proxy authentication information.') 407 411 if httpproxy is None: 408 412 httpproxy = raw_input(' proxy server: ') … … 425 429 opener = urllib2.build_opener(proxy, authinfo, urllib2.HTTPHandler) 426 430 urllib2.install_opener(opener) 427 webget = urllib2.urlopen(file_url) 431 try: 432 webget = urllib2.urlopen(file_url) 433 except urllib2.HTTPError, e: 434 print 'Proxy authentication failed' 435 return False 428 436 429 437 # transfer file to local filesystem
Note: See TracChangeset
for help on using the changeset viewer.