urlopen errors in script

Sleepy Cabbage sleepy at cabbage.co.uk
Tue Aug 18 07:48:42 EDT 2009


On Tue, 18 Aug 2009 13:21:59 +0200, Peter Otten wrote:

> Sleepy Cabbage wrote:
> 
>> 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



More information about the Python-list mailing list