r9904 pywikipedia - Code Review archive

Repository:pywikipedia
Revision:r9903‎ | r9904 | r9905 >
Date:13:29, 17 February 2012
Author:drtrigon
Status:old
Tags:
Comment:
bug fix; scope has changed, thus output was not working
Modified paths:
  • /trunk/pywikipedia/pywikibot/comms/http.py (modified) (history)

Diff [purge]

Index: trunk/pywikipedia/pywikibot/comms/http.py
@@ -102,12 +102,12 @@
103103 u'Page %s could not be retrieved. Check your virus wall.'
104104 % url)
105105 elif e.code == 504:
106 - output(u'HTTPError: %s %s' % (e.code, e.msg))
 106+ pywikibot.output(u'HTTPError: %s %s' % (e.code, e.msg))
107107 if retry:
108108 retry_attempt += 1
109109 if retry_attempt > config.maxretries:
110110 raise MaxTriesExceededError()
111 - output(
 111+ pywikibot.output(
112112 u"WARNING: Could not open '%s'.Maybe the server or\n your connection is down. Retrying in %i minutes..."
113113 % (url, retry_idle_time))
114114 time.sleep(retry_idle_time * 60)
@@ -119,15 +119,15 @@
120120 continue
121121 raise
122122 else:
123 - output(u"Result: %s %s" % (e.code, e.msg))
 123+ pywikibot.output(u"Result: %s %s" % (e.code, e.msg))
124124 raise
125125 except Exception, e:
126 - output(u'%s' %e)
 126+ pywikibot.output(u'%s' %e)
127127 if retry:
128128 retry_attempt += 1
129129 if retry_attempt > config.maxretries:
130130 raise MaxTriesExceededError()
131 - output(
 131+ pywikibot.output(
132132 u"WARNING: Could not open '%s'. Maybe the server or\n your connection is down. Retrying in %i minutes..."
133133 % (url, retry_idle_time))
134134 time.sleep(retry_idle_time * 60)
@@ -160,7 +160,7 @@
161161 # We need to split it to get a value
162162 content_length = int(headers.get('content-length', '0').split(',')[0])
163163 if content_length != len(text) and 'content-length' in headers:
164 - output(
 164+ pywikibot.output(
165165 u'Warning! len(text) does not match content-length: %s != %s'
166166 % (len(text), content_length))
167167 return request(site, uri, retry, sysop, data, compress, no_hostname,
@@ -175,7 +175,7 @@
176176 charset = m.group(1)
177177 else:
178178 if verbose:
179 - output(u"WARNING: No character set found.")
 179+ pywikibot.output(u"WARNING: No character set found.")
180180 # UTF-8 as default
181181 charset = 'utf-8'
182182 # Check if this is the charset we expected
@@ -186,9 +186,9 @@
187187 except UnicodeDecodeError, e:
188188 print e
189189 if no_hostname:
190 - output(u'ERROR: Invalid characters found on %s, replaced by \\ufffd.' % uri)
 190+ pywikibot.output(u'ERROR: Invalid characters found on %s, replaced by \\ufffd.' % uri)
191191 else:
192 - output(u'ERROR: Invalid characters found on %s://%s%s, replaced by \\ufffd.' % (site.protocol(), site.hostname(), uri))
 192+ pywikibot.output(u'ERROR: Invalid characters found on %s://%s%s, replaced by \\ufffd.' % (site.protocol(), site.hostname(), uri))
193193 # We use error='replace' in case of bad encoding.
194194 text = unicode(text, charset, errors = 'replace')
195195

Follow-up revisions

RevisionCommit summaryAuthorDate
r9910bug fix; scope has changed, follow-up to r9901 and r9904drtrigon12:49, 19 February 2012

Status & tagging log