Adding warnings when we do downloads so 1) we can know how bad our performance is...
authorEd Page <epage@Dulcinea.(none)>
Sun, 12 Apr 2009 03:12:26 +0000 (22:12 -0500)
committerEd Page <epage@Dulcinea.(none)>
Sun, 12 Apr 2009 03:12:26 +0000 (22:12 -0500)
src/rtmapi.py

index e8f0183..d513fc8 100644 (file)
@@ -78,13 +78,20 @@ class RTMapi(object):
                pairs = ''.join(['%s%s' % (k, v) for (k, v) in sortedItems(params)])
                return md5(self._secret+pairs).hexdigest()
 
+       @staticmethod
+       def open_url(url, queryArgs=None):
+               if queryArgs:
+                       url += '?' + urllib.urlencode(queryArgs)
+               warnings.warn("Performing download of %s" % url, stacklevel=5)
+               return urllib.urlopen(url)
+
        def get(self, **params):
                "Get the XML response for the passed `params`."
                params['api_key'] = self._apiKey
                params['format'] = 'json'
                params['api_sig'] = self._sign(params)
 
-               json = open_url(SERVICE_URL, params).read()
+               json = self.open_url(SERVICE_URL, params).read()
 
                if _use_simplejson:
                        data = DottedDict('ROOT', simplejson.loads(json))
@@ -168,12 +175,6 @@ def sortedItems(dictionary):
                yield key, dictionary[key]
 
 
-def open_url(url, queryArgs=None):
-       if queryArgs:
-               url = url + '?' + urllib.urlencode(queryArgs)
-       return urllib.urlopen(url)
-
-
 class DottedDict(object):
        "Make dictionary items accessible via the object-dot notation."