Revision: 7571 Author: russblau Date: 2009-10-29 20:48:49 +0000 (Thu, 29 Oct 2009)
Log Message: ----------- Upload by URL now working (at least on test:test), it was a server-side problem, adjusting client code accordingly.
Modified Paths: -------------- branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/site.py =================================================================== --- branches/rewrite/pywikibot/site.py 2009-10-29 19:06:13 UTC (rev 7570) +++ branches/rewrite/pywikibot/site.py 2009-10-29 20:48:49 UTC (rev 7571) @@ -2619,8 +2619,6 @@ raise pywikibot.Error( "User '%s' is not authorized to upload by URL on site %s." % (self.user(), self)) - # doesn't work yet - raise NotImplementedError("Upload by URL not yet implemented") req = api.Request(site=self, action="upload", token=token, filename=imagepage.title(withNamespace=False), url=source_url, comment=comment) @@ -2635,32 +2633,12 @@ raise result = result["upload"] pywikibot.output(result, level=pywikibot.DEBUG) - if source_url: - # get session key from result - key = result["upload_session_key"] - pywikibot.output(u"Asynchronous upload started.") - time.sleep(1) - while True: - # get upload status - statusrequest = api.Request(site=self, action="upload", - token=token, httpstatus="", - sessionkey=str(key)) - status = statusrequest.submit() - status = status["upload"] - if int(status["loaded"]) != int(status["content_length"]): - pywikibot.output( - u" %(loaded)s out of %(content_length)s bytes loaded..." - % status) - continue - # notify the user, since I have no idea what else to do at this point - pywikibot.output(str(status)) - return if "warnings" in result: warning = result["warnings"].keys()[0] message = result["warnings"][warning] raise pywikibot.UploadWarning(upload_warnings[warning] % {'msg': message}) - else: + elif "result" not in result: pywikibot.output(u"Upload: unrecognized response: %s" % result) if result["result"] == "Success": @@ -2668,7 +2646,7 @@ imagepage._imageinfo = result["imageinfo"] return
- + #### METHODS NOT IMPLEMENTED YET #### class NotImplementedYet:
pywikipedia-svn@lists.wikimedia.org