Index: trunk/pywikipedia/pywikibot/comms/http.py |
— | — | @@ -102,12 +102,12 @@ |
103 | 103 | u'Page %s could not be retrieved. Check your virus wall.' |
104 | 104 | % url) |
105 | 105 | 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)) |
107 | 107 | if retry: |
108 | 108 | retry_attempt += 1 |
109 | 109 | if retry_attempt > config.maxretries: |
110 | 110 | raise MaxTriesExceededError() |
111 | | - output( |
| 111 | + pywikibot.output( |
112 | 112 | u"WARNING: Could not open '%s'.Maybe the server or\n your connection is down. Retrying in %i minutes..." |
113 | 113 | % (url, retry_idle_time)) |
114 | 114 | time.sleep(retry_idle_time * 60) |
— | — | @@ -119,15 +119,15 @@ |
120 | 120 | continue |
121 | 121 | raise |
122 | 122 | else: |
123 | | - output(u"Result: %s %s" % (e.code, e.msg)) |
| 123 | + pywikibot.output(u"Result: %s %s" % (e.code, e.msg)) |
124 | 124 | raise |
125 | 125 | except Exception, e: |
126 | | - output(u'%s' %e) |
| 126 | + pywikibot.output(u'%s' %e) |
127 | 127 | if retry: |
128 | 128 | retry_attempt += 1 |
129 | 129 | if retry_attempt > config.maxretries: |
130 | 130 | raise MaxTriesExceededError() |
131 | | - output( |
| 131 | + pywikibot.output( |
132 | 132 | u"WARNING: Could not open '%s'. Maybe the server or\n your connection is down. Retrying in %i minutes..." |
133 | 133 | % (url, retry_idle_time)) |
134 | 134 | time.sleep(retry_idle_time * 60) |
— | — | @@ -160,7 +160,7 @@ |
161 | 161 | # We need to split it to get a value |
162 | 162 | content_length = int(headers.get('content-length', '0').split(',')[0]) |
163 | 163 | if content_length != len(text) and 'content-length' in headers: |
164 | | - output( |
| 164 | + pywikibot.output( |
165 | 165 | u'Warning! len(text) does not match content-length: %s != %s' |
166 | 166 | % (len(text), content_length)) |
167 | 167 | return request(site, uri, retry, sysop, data, compress, no_hostname, |
— | — | @@ -175,7 +175,7 @@ |
176 | 176 | charset = m.group(1) |
177 | 177 | else: |
178 | 178 | if verbose: |
179 | | - output(u"WARNING: No character set found.") |
| 179 | + pywikibot.output(u"WARNING: No character set found.") |
180 | 180 | # UTF-8 as default |
181 | 181 | charset = 'utf-8' |
182 | 182 | # Check if this is the charset we expected |
— | — | @@ -186,9 +186,9 @@ |
187 | 187 | except UnicodeDecodeError, e: |
188 | 188 | print e |
189 | 189 | 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) |
191 | 191 | 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)) |
193 | 193 | # We use error='replace' in case of bad encoding. |
194 | 194 | text = unicode(text, charset, errors = 'replace') |
195 | 195 | |