网络托管上的 python 脚本问题

发布于 2024-07-20 19:22:03 字数 2059 浏览 6 评论 0原文

我为维基百科和维基百科编写了一个脚本。 它在我的计算机上运行良好,但是当我将其上传到我的网络主机(Dreamhost)时,它不起作用并且无法运行。 说我尝试登录的用户已被阻止 - 这不是真的,它可以在我的计算机上运行 我没有被阻止。 这是我收到的确切错误消息 -

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',)

关于它为什么不起作用的任何想法?

谢谢,非常感谢!

I have written a script for Wikipedia & it works fine on my computer, yet when I upload it to my web host(Dreamhost) it doesn't work & says that the user I am trying to log in as is blocked-this is not true, it works on my computer & I#m not blocked.
This is the exact error message I get-

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?

Thanks, much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心碎的声音 2024-07-27 19:22:03

可能是您的主机 (Dreamhost) 被阻止,而不是您的用户。

It could be that your host (Dreamhost) is blocked, and not your user.

吃不饱 2024-07-27 19:22:03

我首先添加一些调试。 您可以捕获发送到维基百科的输出及其返回的结果吗? 那里可能还包含更多信息,您可以提取这些信息来了解失败的原因。

[编辑]重新调试 - 鉴于您提供的小片段,很难给出建议。 事实上,单个文件中有超过 3.5k 行,这表明其中要么存在一些相当低效的编码,要么问题没有得到很好的分解......这可能会使调试变得更加棘手。

话虽如此,上面调试中提到的 .put() 几乎肯定是向服务器发送请求。 您可以首先打印出这些请求或请求的部分。 尝试拼凑正在发送的请求,然后尝试仅执行这些请求并使用 python 的 print 命令记录输出:

print "Sending '%s' to server%(my_put_request)

...其中 my_put_request 是您要发送的数据位。

[Edit2] 我刚刚发现这是您正在使用的 pywikipedia 机器人脚本。 关于机器人的维基百科文章提到了一些关于权限的观点,这将支持uggedals的建议是一个访问问题。 维基百科很可能承认 Dreamhosts IP,并且其他人过去曾尝试做一些坏事,导致他们以某种方式被阻止。

I'd start by adding in some debug. Can you capture the output you're sending to wikipedia and the results it resturns? There's probably some more information lodged in there which you can extract to see why it's failing.

[Edit] r.e. debugging - it's hard to give advice given the small snippet you provided. The fact that you've got over 3.5k lines in a single file suggests there's either some rather innefficient coding in there or that the problem wasn't particularly well broken down... which is likely to make debugging more tricky.

Having said that, the .put() mentioned in the debug above is almost certainly sending a request to the server. You could start by printing out those requests or bits of the request. To try and piece together what request is being sent and then try doing just those requests and recording the output using python's print command:

print "Sending '%s' to server%(my_put_request)

...where my_put_request is the bits of data you're sending.

[Edit2] I just spotted that this it's the pywikipedia bot script you're using. The wikipedia article on the bot mentions some points on permissions which would support uggedals suggestion of it being an access problem. It's quite possible that wikipedia recognises dreamhosts IP and that someone else has tried doing something bad in the past which has caused them to be blocked in some way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文