Changeset 6886


Ignore:
Timestamp:
Apr 23, 2009, 3:25:26 PM (16 years ago)
Author:
rwilson
Message:

Better error handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/utilities/system_tools.py

    r6860 r6886  
    341341# @param auth Auth tuple (httpproxy, proxyuser, proxypass).
    342342# @param blocksize Read file in this block size.
    343 # @return 'auth' tuple for subsequent calls, if successful, else False.
     343# @return (True, auth) if successful, else (False, auth).
    344344# @note If 'auth' not supplied, will prompt user.
    345345# @note Will try using environment variable HTTP_PROXY for proxy server.
     
    365365    try:
    366366        urllib.urlretrieve(file_url, file_name)
    367         return None     # no proxy, no auth required
     367        return (True, auth)     # no proxy, no auth required
    368368    except IOError, e:
    369369        if e[1] == 407:     # proxy error
     
    371371        elif e[1][0] == 113:  # no route to host
    372372            print 'No route to host for %s' % file_url
    373             return False    # return False
     373            return (False, auth)    # return False
    374374        else:
    375375            print 'Unknown connection error to %s' % file_url
    376             return False
     376            return (False, auth)
    377377
    378378    # We get here if there was a proxy error, get file through the proxy
     
    423423    try:
    424424        webget = urllib2.urlopen(file_url)
    425     except urllib2.HTTPError:
    426         return False
     425    except urllib2.HTTPError, e:
     426        print 'Error received from proxy:\n%s' % str(e)
     427        print 'Possibly the user/password is wrong.'
     428        return (False, auth)
    427429
    428430    # transfer file to local filesystem
     
    437439
    438440    # return successful auth info
    439     return (httpproxy, proxyuser, proxypass)
     441    return (True, (httpproxy, proxyuser, proxypass))
    440442
    441443
Note: See TracChangeset for help on using the changeset viewer.