Changeset 6666

Mar 31, 2009, 12:43:49 PM (15 years ago)

Added comments, tweaked interaction with user.

1 edited


  • anuga_core/source/anuga/utilities/

    r6656 r6666  
    304304    '''Get a file from the web.
    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!
    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
     311    Will try simple load through urllib first.  Drop down to urllib2
     312    if there is a proxy and it requires authentication.
     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!
    319317    '''
    345343    # Get auth info from user if still not supplied
    346344    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:')
    351350        if httpproxy is None:
    352351            httpproxy = raw_input('  proxy server: ')
    355354        if proxypass is None:
    356355            proxypass = getpass.getpass('proxy password: ')
    357         print '----------------------------------------------------'
     356        print '-'*80
    359358    # the proxy URL cannot start with 'http://'
Note: See TracChangeset for help on using the changeset viewer.