This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[ktorrent 3.2.1] help writing kross plugin

Tags: None
(comma "," separated)
ilich
Registered Member
Posts
2
Karma
0
I wrote a kross script that update twitter status when a download is complete.
It worked on kubuntu 8.10 with kde 4.2.2 from svn and ktorrent 3.2.1 from svn too.
When i upgraded to kubuntu 9.04 the script stops to work,
Code: Select all
ilich@azurill:~$ ktorrent --version
Qt: 4.5.0
KDE: 4.2.2 (KDE 4.2.2)
KTorrent: 3.2.1
ilich@azurill:~$ python --version
Python 2.6.2
ilich@azurill:~$ kross --version
Qt: 4.5.0
KDE: 4.2.2 (KDE 4.2.2)
Kross: 0.1

using the kross command line tool i noticed that the problem was loading the twitter library (python-twitter on ubuntu), digging in the traceback seems that the problem is the loading of ssl python library.

Code: Select all
Original exception was:
TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)
Kross: "PythonScript::Destructor."
Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)
  File "python/tor2twit2.py", line 20, in <module>
    import twitter

  File "<string>", line 18, in _import

  File "/var/lib/python-support/python2.6/twitter.py", line 17, in <module>
    import urllib2

  File "<string>", line 18, in _import

  File "/usr/lib/python2.6/urllib2.py", line 92, in <module>
    import httplib

  File "<string>", line 18, in _import

  File "/usr/lib/python2.6/httplib.py", line 1054, in <module>
    import ssl

  File "<string>", line 18, in _import

  File "/usr/lib/python2.6/ssl.py", line 81, in <module>
    class SSLSocket (socket):

Loading of twiiter, urllib2 or ssl python libraries in normal python script it gives no problem and works. (I get only a warning on twitter libraries)
Code: Select all
ilich@azurill:~$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib2, twitter, ssl
/var/lib/python-support/python2.6/twitter.py:10: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'ssl', 'twitter', 'urllib2']
>>>

Is this a bug or a problem of my box?
George
Moderator
Posts
5421
Karma
1

Wed Apr 29, 2009 8:23 am
Don't know, it should work, if it also works in a normal python script.

Are you sure you can actually use the twitter module in a normal python script ?
ilich
Registered Member
Posts
2
Karma
0

Wed Apr 29, 2009 4:21 pm
Are you sure you can actually use the twitter module in a normal python script ?


Code: Select all
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************
   
IDLE 2.6.2     
>>> import twitter

Warning (from warnings module):
  File "/var/lib/python-support/python2.6/twitter.py", line 10
    import md5
DeprecationWarning: the md5 module is deprecated; use hashlib instead
>>> api=twitter.Api("lit_alrovi","************")
>>> api.PostUpdate("Hello ktorrent!")
<twitter.Status object at 0x959facc>

Yes it works and you can see here

But i think that the problem depends on ssl library.
Someone can try a script with only:
Code: Select all
import Kross
import ssl #or urllib2 that is the library needed by python-twitter


and run:
Code: Select all
ilich@azurill:~$ kross script.py


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora, watchstar