FogBugz » FogBugzPy A Python wrapper for the FogBugz API Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.9.3, 0.9.5, and 0.9.6

Fix a bug in the error handling and add debugging output instead of always printing the fields.

Changeset 9874532e37d9

Parent 586682d3b66a

by Profile picture of User 10Tyler G. Hicks-Wright <tghw@fogcreek.com>

Changes to one file · Browse files at 9874532e37d9 Showing diff from parent 586682d3b66a Diff from another changeset...

Change 1 of 3 Show Entire File fogbugz.py Stacked
 
1
2
3
4
5
6
 
 
7
8
9
 
28
29
30
31
32
 
 
33
34
35
 
78
79
80
81
82
 
 
 
83
84
85
 
 
1
2
3
4
5
6
7
8
9
10
 
29
30
31
 
 
32
33
34
35
36
 
79
80
81
 
 
82
83
84
85
86
87
@@ -1,9 +1,10 @@
-import urllib  import urllib2  import mimetools  from StringIO import StringIO    from BeautifulSoup import BeautifulSoup, CData + +DEBUG = False # Set to True for debugging output.    class FogBugzAPIError(Exception):   pass @@ -28,8 +29,8 @@
  self._opener = urllib2.build_opener()   try:   soup = BeautifulSoup(self._opener.open(url + 'api.xml')) - except URLError: - raise FogBugzConnectionError("Library could not connect to the FogBugz API. Either this installation of FogBugz does not support the API, or the url, %s, is incorrect." % (self._url,)) + except (urllib2.URLError, urllib2.HTTPError), e: + raise FogBugzConnectionError("Library could not connect to the FogBugz API. Either this installation of FogBugz does not support the API, or the url, %s, is incorrect.\n\nError: %s" % (self._url, e))   self._url = url + soup.response.url.string   self.currentFilter = None   @@ -78,8 +79,9 @@
  buf = StringIO()     for k, v in fields.items(): - print("field: %s: %s"% (repr(k), repr(v))) - buf.write(crlf.join([ '--' + BOUNDARY, 'Content-disposition: form-data; name="%s"' % k, '', v, '' ])) + if DEBUG: + print("field: %s: %s"% (repr(k), repr(v))) + buf.write(crlf.join([ '--' + BOUNDARY, 'Content-disposition: form-data; name="%s"' % k, '', str(v), '' ]))     n = 0   for f, h in files.items():