Ignore:
Timestamp:
26/03/08 11:58:06 (11 years ago)
Author:
mkochan
Message:

Changed wget to return urllib2.HTTPError on retrieval error; changed setup.py to include config files in the csml2kml distribution.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DPPP/kml/csml2kml/python/csml2kml/csml2kml/utils.py

    r3612 r3684  
    55import urllib2 
    66 
     7class UrlRetrievalError(Exception): 
     8    def __init__(self, value): 
     9        self.value = value 
     10    def __repr__(self): 
     11        return repr(self.value) 
     12 
    713def wget(url): 
    814    ''' 
     
    1016    @param url: The URL. 
    1117    @type url: C{str} 
    12     @return: The returned data as a string, or C{None} on retrieval error. 
     18    @return: The returned data as a string, or an C{urllib2.HTTPError} on retrieval error. 
    1319    @rtype: C{str} 
    1420    ''' 
    1521    content = None 
    1622    try: 
    17         try: 
    18             f = urllib2.urlopen(url)         # open a file-like object with the data 
    19             content = f.read()               # read the text in 
    20         except urllib2.HTTPError: 
    21             pass                             # error in retrieval, wget() will return None 
     23        f = urllib2.urlopen(url)         # open a file-like object with the data 
     24        content = f.read()               # read the text in 
    2225    finally: 
    2326        try: 
    2427            f.close() 
    2528        except NameError: 
    26             pass                             # f uninitialised, so no need to close it 
     29            pass                         # in case socket has not even been opened 
    2730    return content 
Note: See TracChangeset for help on using the changeset viewer.