views:

327

answers:

3

Hello,

I'm totally new to python, so hopefully someone can help if I'm doing something obviously wrong. I'm trying to create and run a simple pywikipedia bot on vocabularies.referata.com, a semantic mediawiki site. I downloaded the pywikipedia distro and created a family file:

import config, family, urllib         # REQUIRED

class Family(family.Family):          # REQUIRED
    def __init__(self):               # REQUIRED
        family.Family.__init__(self)  # REQUIRED
        self.name = 'explicator'        # REQUIRED; replace with actual name

        self.langs = {                # REQUIRED
            'en': 'vocabularies.referata.com',  # Include one line for each wiki in family
        }

I've created a user, wikibot, and run:

python generate_user_files.py

as per instructions on:

http://meta.wikimedia.org/wiki/Using_the_python_wikipediabot

When I try to run:

python login.py

I'm getting the following error:

C:\pywikipedia>python login.py
Password for user wikibot on explicator:en:
Logging in to explicator:en as wikibot
Traceback (most recent call last):
  File "login.py", line 376, in <module>
    main()
  File "login.py", line 372, in main
    loginMan.login()
  File "login.py", line 261, in login
    cookiedata = self.getCookie(api)
  File "login.py", line 178, in getCookie
    response, data = self.site.postData(address, self.site.urlEncode(predata))
  File "C:\pywikipedia\wikipedia.py", line 4915, in postData
    conn.endheaders()
  File "C:\Python25\lib\httplib.py", line 860, in endheaders
    self._send_output()
  File "C:\Python25\lib\httplib.py", line 732, in _send_output
    self.send(msg)
  File "C:\Python25\lib\httplib.py", line 699, in send
    self.connect()
  File "C:\Python25\lib\httplib.py", line 683, in connect
    raise socket.error, msg
socket.error: (10060, 'Operation timed out')

Is their something stupid/apparent that I need to check or am doing wrong? I'm behind a firewall, would this be the problem? (and if so what steps do I need to take to fix it).

thanks for any help Stuart

A: 

I'm not familiar w/ pywikipedia =p, but the problem is at least about connection rather than python: the socket connection fails to be established at the beginning.

  • Is the post url, address in the login.py L178 , correct? Any typo or misconfiguration?
  • Is the url accessible? You could try to directly visit the url in browser and see if there is any http response. If the server is reachable, you could check whether it's listening on certain port like 80, by netstat -ant, netstat -anptcp or similar. On windows, a firewall w/ default settings may block communication, you could see whether there is any warning dialog waiting for confirm, or check the fireware log. Also, you need to have Administrator privilege to use port 80.
okm
A: 

Works for me, sorry. I just created an account, and used your family file. It seems to be on your side.

$ python login.py -v -v -family:explicator -lang:en
Pywikipediabot [http] trunk/pywikipedia (r6858, May 08 2009, 15:23:29)
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3]
WARNING: Using -v -v on login.py might leak private data. When sharing, please double check your password is not readable and log out your bots session.
Password for user NicDumZ on explicator:en: 
Logging in to explicator:en as NicDumZ
self.site.postData(/w/index.php?title=Special:Userlogin&useskin=monobook&action=submit, wpSkipCookieCheck=1&wpPassword=XXXXX&wpDomain=&wpRemember=1&wpLoginattempt=Aanmelden%20%26%20Inschrijven&wpName=NicDumZ)
302/Found
Date: Thu, 03 Sep 2009 19:46:47 GMT
Server: Apache
Cache-Control: private, must-revalidate, max-age=0
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: referata_session=XXXXXXXXXXdab8c53151d27046d68473; path=/; HttpOnly
Set-Cookie: referataUserID=4; expires=Sat, 03-Oct-2009 19:46:48 GMT; path=/; httponly
Set-Cookie: referataUserName=NicDumZ; expires=Sat, 03-Oct-2009 19:46:48 GMT; path=/; httponly
Set-Cookie: referatasession=XXXXXXXXXX270504613b1d26dfef82e6; expires=Sat, 03-Oct-2009 19:46:48 GMT; path=/; httponly
Vary: Accept-Encoding,Cookie
X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;string-contains=referataToken;string-contains=referataLoggedOut;string-contains=referata_session
Location: http://vocabularies.referata.com/wiki/Main_Page
Content-Encoding: gzip
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8


Should be logged in now

Can you try the same, with -v -v options so that I can help you debug that issue? Please comment back so I can get your updates.

NicDumZ
A: 

Hello all, Thanks for the help - it's much appreciated. I believe you're right about it not being the python script/pybot itself - it's a problem within the place I'm working and the firewall. I've since tried the code on a few other machines outwith my current firewall/network setup and it worked perfectly. thanks again for the quick help and advice. Stuart

stu73