urlopen errors in script

S

Sleepy Cabbage

I'm scripting a superkaramba theme using python and have intgrated output
from amarok. I have also would like to show the artist and song title from
a radio stream i've added to my playlist.

If I open a python console and add the following:

">>>import urllib2"
">>>from urllib2 import urlopen"

">>>nowplaying = str.split(urlopen('http://www.hearteastmids.co.uk//
jsfiles/NowPlayingDisplay.aspx?f=http%3A%2F%2Frope.ccap.fimc.net%2Ffeeds%
2Fnowplaying%2FGlobal%2FHeart_Network%2FHeart_East_Midlands%
2F6854.xml&l=6854&tzc=8&at=HeartEastMids').read(),'>')"

">>>print test[4][:-3]"

this works and displays the artist and song title.

However, when I add this to my script I get the following errors:

----------------------------------------------------------------------------

superkaramba(28855) ThemesDlg::addThemeToList: addThemeToList() file: "/
home/sleepy/dev/MyTheme/
MyTheme.theme"
superkaramba(28855) Karamba::startKaramba: Loading script module:
"MyTheme.py"
superkaramba(28855) KarambaInterface::initInterpreter: Using "python"
script: "/home/sleepy/dev/MyTheme/
MyTheme.py"
Kross: "Loading the interpreter library for python"
Kross: "Successfully loaded Interpreter instance from library."
Kross:
"PythonScript::Constructor."
Kross:
"PythonScript::execute"
Kross:
"PythonInterpreter::extractException:
File "/home/sleepy/dev/MyTheme/MyTheme.py", line 4, in
<module>
#this import statement allows access to the karamba
functions

File "/home/sleepy/dev/MyTheme/MyTheme.py", line 9, 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):
"
Kross: "Error error=Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given) lineno=81 trace=
File "/home/sleepy/dev/MyTheme/MyTheme.py", line 4, in
<module>
#this import statement allows access to the karamba functions

File "/home/sleepy/dev/MyTheme/MyTheme.py", line 9, 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):
"
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 38,
in apport_excepthook
from apport.packaging_impl import impl as
packaging
File "<string>", line 18, in
_import
File "/usr/lib/python2.6/dist-packages/apport/__init__.py", line 1, in
<module>
from apport.report import
Report
File "<string>", line 18, in
_import
File "/usr/lib/python2.6/dist-packages/apport/report.py", line 21, in
<module>
import
fileutils
File "<string>", line 18, in
_import
File "/usr/lib/python2.6/dist-packages/apport/fileutils.py", line 16,
in <module>
from packaging_impl import impl as
packaging
File "<string>", line 18, in
_import
File "/usr/lib/python2.6/dist-packages/apport/packaging_impl.py", line
18, in <module>
import
apt
File "<string>", line 18, in
_import
File "/usr/lib/python2.6/dist-packages/apt/__init__.py", line 7, in
<module>
from apt.package import
Package
File "<string>", line 18, in
_import
File "/usr/lib/python2.6/dist-packages/apt/package.py", line 23, 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):
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)

Original exception was:
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)
Kross: "PythonScript::Destructor."
 
P

Peter Otten

Sleepy said:
I'm scripting a superkaramba theme using python and have intgrated output
from amarok. I have also would like to show the artist and song title from
a radio stream i've added to my playlist.

If I open a python console and add the following:

">>>import urllib2"
">>>from urllib2 import urlopen"

">>>nowplaying = str.split(urlopen('http://www.hearteastmids.co.uk//
jsfiles/NowPlayingDisplay.aspx?f=http%3A%2F%2Frope.ccap.fimc.net%2Ffeeds%
2Fnowplaying%2FGlobal%2FHeart_Network%2FHeart_East_Midlands%
2F6854.xml&l=6854&tzc=8&at=HeartEastMids').read(),'>')"

">>>print test[4][:-3]"

this works and displays the artist and song title.

However, when I add this to my script I get the following errors:

Please give a minimal version of your script that produces the error, not
some arbitrary excerpt that you ran successfully on the command line.

If I were to guess: you are doing something like

import socket
socket.socket = socket

somewhere, thus confusing the socket class with the module of the same name.

Peter
 
S

Sleepy Cabbage

Sleepy said:
I'm scripting a superkaramba theme using python and have intgrated
output from amarok. I have also would like to show the artist and song
title from a radio stream i've added to my playlist.

If I open a python console and add the following:

">>>import urllib2"
">>>from urllib2 import urlopen"

">>>nowplaying = str.split(urlopen('http://www.hearteastmids.co.uk//
jsfiles/NowPlayingDisplay.aspx?f=http%3A%2F%2Frope.ccap.fimc.net% 2Ffeeds%
2Fnowplaying%2FGlobal%2FHeart_Network%2FHeart_East_Midlands%
2F6854.xml&l=6854&tzc=8&at=HeartEastMids').read(),'>')"

">>>print test[4][:-3]"

this works and displays the artist and song title.

However, when I add this to my script I get the following errors:

Please give a minimal version of your script that produces the error,
not some arbitrary excerpt that you ran successfully on the command
line.

If I were to guess: you are doing something like

import socket
socket.socket = socket

somewhere, thus confusing the socket class with the module of the same
name.

Peter

Thanks Peter.

This is the script up to where the error seems to fall:

"#!/usr/bin/env superkaramba"
"# -*- coding: iso-8859-1 -*-"

"import karamba"
"import subprocess"
"from subprocess import Popen, PIPE, STDOUT, call"
"import urllib"
"from urllib import urlopen"

"#this is called when your widget is initialized"
"def initWidget(widget):"
"clkPause = karamba.createClickArea(widget, 156, 470, 35, 35, "qdbus
org.kde.amarok /Player Pause")"
"nowplaying = urllib.urlopen('http://www.hearteastmids.co.uk//jsfiles/
NowPlayingDisplay.aspx?f=http%3A%2F%2Frope.ccap.fimc.net%2Ffeeds%
2Fnowplaying%2FGlobal%2FHeart_Network%2FHeart_East_Midlands%
2F6854.xml&l=6854&tzc=8&at=HeartEastMids').read()"

Hope this can enlighten things
 
P

Peter Otten

Sleepy said:
This is the script up to where the error seems to fall:

"#!/usr/bin/env superkaramba"
"# -*- coding: iso-8859-1 -*-"

"import karamba"
"import subprocess"
"from subprocess import Popen, PIPE, STDOUT, call"
"import urllib"
"from urllib import urlopen"

"#this is called when your widget is initialized"
"def initWidget(widget):"
"clkPause = karamba.createClickArea(widget, 156, 470, 35, 35, "qdbus
org.kde.amarok /Player Pause")"
"nowplaying = urllib.urlopen('http://www.hearteastmids.co.uk//jsfiles/
NowPlayingDisplay.aspx?f=http%3A%2F%2Frope.ccap.fimc.net%2Ffeeds%
2Fnowplaying%2FGlobal%2FHeart_Network%2FHeart_East_Midlands%
2F6854.xml&l=6854&tzc=8&at=HeartEastMids').read()"

Hope this can enlighten things

While there isn't any obvious blunder apart from the odd quotes that you
wrap around every line there seem to be other files missing to run the
script. I'm sorry, but I'm not prepared to invest much more than

$ sudo aptitude install superkaramba

into the problem.

Perhaps an actual user of superkaramba can step in.

Peter
 
S

Sleepy Cabbage

Thanks for the time you've spent anyway Peter. I have superkaramba
installed and the rest of the script is running fine, it's only when I
put the urlopen part in that it comes back with errors. The quotes are
just to make it readable on here as my first attempt at posting muted the
text.
 
S

Sleepy Cabbage

Thanks for the time you've spent anyway Peter. I have superkaramba
installed and the rest of the script is running fine, it's only when I
put the urlopen part in that it comes back with errors. The quotes are
just to make it readable on here as my first attempt at posting muted
the text.

This has been solved by upgrading to kde 4.3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top