Python script problems on web hosting
I wrote a script for Wikipedia and it works fine on my computer, but when I upload it to my web host (Dreamhost) it doesn't work and says that the user I'm trying to login from is blocked - it's not true. it works on my computer and i am not locked. This is the exact error message I am getting -
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
/home/tris1601/thewikipediaforum.com/pywikipedia/wikitest.py
35 site = wikipedia.getSite()
36 newpage = wikipedia.Page(site, u"User:Dottydotdot/test")
37 newpage.put(text + "<br><br>'''Imported from [http://en.wikiquote.org '''Wikiquote'''] by [[User:DottyQuoteBot|'''DottyQuoteBot''']]", u"Testing")
38
39 wikipedia.stopme()
newpage = Page{[[User:Dottydotdot/test]]}, newpage.put = <bound method Page.put of Page{[[User:Dottydotdot/test]]}>, text = u'You have so many things in the background that y... could possibly work?" <p> [[Ward Cunningham]] \n'
/home/tris1601/thewikipediaforum.com/pywikipedia/wikipedia.py in put(self=Page{[[User:Dottydotdot/test]]}, newtext=u"You have so many things in the background that y...''] by [[User:DottyQuoteBot|'''DottyQuoteBot''']]", comment=u'Testing', watchArticle=None, minorEdit=True, force=False, sysop=False, botflag=True)
1380
1381 # Check blocks
1382 self.site().checkBlocks(sysop = sysop)
1383
1384 # Determine if we are allowed to edit
self = Page{[[User:Dottydotdot/test]]}, self.site = <bound method Page.site of Page{[[User:Dottydotdot/test]]}>, ).checkBlocks undefined, sysop = False
/home/tris1601/thewikipediaforum.com/pywikipedia/wikipedia.py in checkBlocks(self=wikipedia:en, sysop=False)
4457 if self._isBlocked[index]:
4458 # User blocked
4459 raise UserBlocked('User is blocked in site %s' % self)
4460
4461 def isBlocked(self, sysop = False):
global UserBlocked = <class wikipedia.UserBlocked>, self = wikipedia:en
UserBlocked: User is blocked in site wikipedia:en
args = ('User is blocked in site wikipedia:en',)
Any ideas as to why it isn't working?
Thank you very much!
I would start by adding debug. Can you grab the output that you submit to Wikipedia and the results it recovers? There is probably more information in there that you can glean to understand why it doesn't work.
[Edit] re debug - hard to give advice given the small snippet you provided. The fact that you have over 3.5k lines in a single file suggests there is either pretty inefficient coding there, or that the problem hasn't been broken down particularly well ... which will likely make debugging more difficult.
Having said that, the .put () function mentioned in the above debug almost certainly sends a request to the server. You can start by printing these requests or the request bit. To try and link what request is being sent and then try to run only those requests and write the output using python print command:
print "Sending '%s' to server%(my_put_request)
... where my_put_request is the bit of data you are sending.
[Edit2] I just noticed that you are using the pywikipedia bot script. The bot's wikipedia article mentions some permissions points that will support the uggedals suggestion that this is an access issue. It is possible that wikipedia recognizes the IP address of the dreamhosts and that someone else tried to do something bad in the past that caused them to be blocked in some way.
a source to share