Changeset 6666 for anuga_core/source/anuga/utilities/system_tools.py
- Timestamp:
- Mar 31, 2009, 12:43:49 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/utilities/system_tools.py
r6656 r6666 304 304 '''Get a file from the web. 305 305 306 Note the tortuous path to the code below: 307 Q. How do we get a file on a server into patong validation? 308 A. wget! 309 Q. On Windows? 310 A. Damn! wget is UNIX only. Use python module urllib! One line of code! 311 Q. Through a proxy? 312 A. Damn! urllib fails. Use urllib2! 313 Q. How do we make it easy for the user to supply auth info? 314 A. Pass in and return an 'auth' tuple! And use environment variables! 315 Q. How do we stop a caching proxy from defeating updates? 316 A. Append a unique, ignored, string on each fetched URL! 317 318 Furtive look over the shoulder to see what other problems are approaching! 306 file_url: The URL of the file to get 307 file_name: Local path to save loaded file in 308 auth: A tuple (httpproxy, proxyuser, proxypass) 309 blocksize: Block size of file reads 310 311 Will try simple load through urllib first. Drop down to urllib2 312 if there is a proxy and it requires authentication. 313 314 Environment variable HTTP_PROXY can be used to supply proxy information. 315 PROXY_USERNAME is used to supply the authentication username. 316 PROXY_PASSWORD supplies the password, if you dare! 319 317 ''' 320 318 … … 345 343 # Get auth info from user if still not supplied 346 344 if httpproxy is None or proxyuser is None or proxypass is None: 347 print '----------------------------------------------------' 348 print 'You need to supply proxy authentication information.' 349 print 'Use environment variables HTTP_PROXY, PROXY_USERNAME' 350 print 'and PROXY_PASSWORD to bypass entry here:' 345 print '-'*80 346 print ('You need to supply proxy authentication information. ' 347 'Use environment variables') 348 print ('HTTP_PROXY, PROXY_USERNAME and PROXY_PASSWORD to bypass ' 349 'entry here:') 351 350 if httpproxy is None: 352 351 httpproxy = raw_input(' proxy server: ') … … 355 354 if proxypass is None: 356 355 proxypass = getpass.getpass('proxy password: ') 357 print '- ---------------------------------------------------'356 print '-'*80 358 357 359 358 # the proxy URL cannot start with 'http://'
Note: See TracChangeset
for help on using the changeset viewer.