Changeset 6646
- Timestamp:
- Mar 27, 2009, 3:11:48 PM (15 years ago)
- Location:
- anuga_core/source/anuga/utilities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/utilities/log.py
r6638 r6646 7 7 Use it this way: 8 8 import anuga.utilities.log as log 9 log.console_logging_level = log.DEBUG 9 10 log.debug('A message at DEBUG level') 10 11 log.info('Another message, INFO level') … … 47 48 log_filename = './anuga.log' 48 49 50 # set module variables so users don't have to do 'import logging'. 51 CRITICAL = logging.CRITICAL 52 ERROR = logging.ERROR 53 WARNING = logging.WARNING 54 INFO = logging.INFO 55 DEBUG = logging.DEBUG 56 NOTSET = logging.NOTSET 57 49 58 50 59 ################################################################################ … … 85 94 86 95 # tell the world how we are set up 87 start_msg = (" \nLogfile is '%s' with logging level of %s, "96 start_msg = ("Logfile is '%s' with logging level of %s, " 88 97 "console logging level is %s" 89 98 % (log_filename, -
anuga_core/source/anuga/utilities/system_tools.py
r6645 r6646 302 302 # @note Will try using environment variable PROXY_PASSWORD for proxy password. 303 303 def get_web_file(file_url, file_name, auth=None, blocksize=1024*1024): 304 '''Get a file from the web.''' 304 '''Get a file from the web. 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! 319 ''' 305 320 306 321 # Simple fetch, if fails, check for proxy error 307 322 try: 308 urllib.urlretrieve(file_url, file_name) 323 urllib.urlretrieve(file_url, file_name) # original 'line of code' 309 324 return None # no proxy, no auth required 310 325 except IOError, e: … … 330 345 # Get auth info from user if still not supplied 331 346 if httpproxy is None or proxyuser is None or proxypass is None: 347 print '----------------------------------------------------' 332 348 print 'You need to supply proxy authentication information:' 333 349 if httpproxy is None: … … 337 353 if proxypass is None: 338 354 proxypass = getpass.getpass('proxy password: ') 355 print '----------------------------------------------------' 339 356 340 357 # the proxy URL cannot start with 'http://' … … 343 360 httpproxy = httpproxy.replace('http://', '', 1) 344 361 345 # open 'netfile362 # open remote file 346 363 proxy = urllib2.ProxyHandler({'http': 'http://' + proxyuser 347 364 + ':' + proxypass
Note: See TracChangeset
for help on using the changeset viewer.