Revision: 3984 Author: valhallasw Date: 2007-08-07 13:13:22 +0000 (Tue, 07 Aug 2007)
Log Message: ----------- Updated upload.py: follow 301's and re-upload to that location. Bad for your bandwidth though ;)
Modified Paths: -------------- trunk/pywikipedia/upload.py
Modified: trunk/pywikipedia/upload.py =================================================================== --- trunk/pywikipedia/upload.py 2007-08-07 12:45:08 UTC (rev 3983) +++ trunk/pywikipedia/upload.py 2007-08-07 13:13:22 UTC (rev 3984) @@ -216,6 +216,12 @@ #if response.status in [200, 302]: # wikipedia.output(u"Upload successful.")
+ elif response.status == 301: + wikipedia.output(u"Following redirect...") + address = response.getheader('Location') + wikipedia.output(u"Changed upload address to %s. Please update %s.py" % (address, self.targetSite.family.__module__)) + exec('self.targetSite.upload_address = lambda: %r' % address, locals(), globals()) + return self.upload_image(debug) else: try: # Try to find the error message within the HTML page.