Changeset 3684 for DPPP


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.

Location:
DPPP/kml/csml2kml/python/csml2kml
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • DPPP/kml/csml2kml/python/csml2kml/csml2kml/config/midas.csml2kml.conf.xml

    r3657 r3684  
    33  <UseRegions>yes</UseRegions> 
    44  <GetAllStationsRequestURL><![CDATA[http://bond.badc.rl.ac.uk:8084/geoserver/wfs?request=getFeature&service=wfs&version=1.1.0&typename=np:Station&maxFeatures=100000]]></GetAllStationsRequestURL> 
    5   <BalloonTemplate>&lt;h2&gt;Station $[station_name]&lt;/h2&gt;Click here to see the list of &lt;a href=&quot;http://superglue.badc.rl.ac.uk:8089/csmlGrapher/list?station_name=$[station_name]&quot;&gt;CSML features associated with this station&lt;/a&gt; (this will open a window of your default web browser).</BalloonTemplate> 
     5  <BalloonTemplate>&lt;h2&gt;Station $[station_name]&lt;/h2&gt;Click here to see the list of &lt;a href=&quot;http://superglue.badc.rl.ac.uk:8084/csmlGrapher/list?station_name=$[station_name]&quot;&gt;CSML features associated with this station&lt;/a&gt; (this will open a window of your default web browser).</BalloonTemplate> 
    66  <StationData> 
    77    <Datum name="station_id">#ID#</Datum> 
  • DPPP/kml/csml2kml/python/csml2kml/csml2kml/tests/testUtils.py

    r3654 r3684  
    55print 'Retrieving ' + str(n) + ' times.' 
    66for i in range(n): 
    7     content = utils.wget('http://bond.badc.rl.ac.uk:8089/dummyGeoServer/GetStationCSMLFeatures?gml_id=TWL1') 
     7    content = csml2kml.utils.wget('http://bond.badc.rl.ac.uk:8084/geoserver/wfs?request=getFeature&version=1.1.0&typename=np:Station&maxFeatures=2') 
    88    if content: 
    99        # print content 
  • 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 
  • DPPP/kml/csml2kml/python/csml2kml/setup.py

    r3657 r3684  
    22 
    33setup(name='csml2kml', 
    4       version='1.0b', 
     4      version='1.0b2', 
    55      install_depends=['csml>=2.0b'], 
     6      include_package_data=True, 
    67      packages=find_packages(), 
    78      author='Martin Kochan, for the British Atmospheric Data Centre, UK', 
Note: See TracChangeset for help on using the changeset viewer.