python

socket.error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions

Hello all. I'm trying to create a custom TCP stack using Python 2.6.5 on Windows 7 to serve valid http page requests on port 80 locally. But, I've run into a snag with what seems like Windows 7 tightened up security. This code worked on Vista. Here's my sample code: import SocketServer import struct class MyTCPHandler(SocketServer....

Python: Problems finding string in website source code

I open a website with urlopen. I then put the website sourcecode into a variable like so source = website.read() When I just print the source it comes out formatted correctly, however when I try to iterate through each line each character is it's own line. for example when I just print it looks like this <HTML> title</html> When ...

Python: Strip everything but spaces and alphanumeric

I have a large string with brackets and commas and such. I want to strip all those characters but keep the spacing. How can I do this. As of now I am using strippedList = re.sub(r'\W+', '', origList) ...

Run and terminate a prgram (Python under Windows)

I'd like to create a small script to that basically does this: run program1.exe --> kill program1.exe after n seconds --> run program1.exe again. I know some basic Python and would read up on this, but I'm in a bit of a hurry and just need this to get done asap. If someone has a script/idea or could help my out with just the syntax I ...

How to programatically pause spotify when a call comes in on skype

Skype has an inbuilt function where iTunes playback is paused and resumed automatically when a call comes in. It would be nice to have something similar for Spotify. Both provide a python API so this would seem the obvious route to go down. ...

Parsing groupings of strings (Python)

I have a string that looks something like this: [["Name1","ID1","DDY1", "CALL1", "WHEN1"], ["Name2","ID2","DDY2", "CALL2", "WHEN2"],...]; This string was taken from a website. There can be any amount of groupings. How could I parse this string and print just the Name variables of each grouping? ...

Setting the first day of the week with the wx.lib.calendar.Calendar control?

As per the title, is it possible to change the first day of the week (Monday instead of Sunday)? ...

page separator in Kate editor

PEP 8 says: Python accepts the control-L (i.e. ^L) form feed character as whitespace; Many tools treat these characters as page separators, so you may use them to separate pages of related sections of your file This look like a great idea for me, but in the text editor I use(kate) "control+L" is for save all files. Someon...

Java/Python: Integration, problem with looping updating text

Hello! Basically I have a script in Python that grabs the text from an open window using getWindowText() and outputs it to the screen. The python loops so as the text in the window changes, it outputs the changes, so the output of the python will always be up to date with the window text. I'm trying to access this text in my Java progra...

Where is my python script spending time? Is there "missing time" in my cprofile / pstats trace?

I am attempting to profile a long running python script. The script does some spatial analysis on raster GIS data set using the gdal module. The script currently uses three files, the main script which loops over the raster pixels called find_pixel_pairs.py, a simple cache in lrucache.py and some misc classes in utils.py. I have profi...

python cairoplot store previous readings..

hi, i am using cairoplot, to make graphs, however the file from where i am reading the data is growing huge and its taking a long time to process the graph is there any real-time way to produce cairo graph, or at least store the previous readings..like rrd. -krisdigitx ...

why in python giving to str func a unicode string will throw an exception?

for example the following: str(u'לשום') will throw an error. how can i prevent these? ...

stop minidom converting < > to &lt; &gt;

Im trying to output some data from my google app engine datastore to xml so that a flash file can read it, The problem is when using CDATA tags the outputted xml contains &lt; instead of < e.g <name>&lt;![CDATA][name]]&gt;</name> here is my python which outputs the xml: doc = Document() feed = doc.createElement("feed") ...

Getting error on inserting tuple values in postgreSQL table using python

Hello, I want to keep last.fm's user recent music tracks list to postgresql database table using pylast interface.But when I tried to insert values to the table it shows errors.Code example: import pylast import psycopg2 import re from md5 import md5 import sys import codecs import psycopg2.extensions psycopg2.extensions.register_type...

django authentication .htaccess static

In my app users can upload files for other users. To make the uploaded files accesible only for the addresse I need some kind of static files authentication system. My idea, is to create the apache hosted directory for each user and to limit access to this derectory using .htaccess. This means that each time new django user is created,...

Python sum up time

In python how to sum up the following time 0:00:00 0:00:15 9:30:56 Thanks.. ...

Removing unwanted characters from a string in Python

Hi, I have some strings that I want to delete some unwanted characters from them. For example: Adam'sApple ----> AdamsApple.(case insensitive) Can someone help me, I need the fastest way to do it, cause I have a couple of millions of records that have to be polished. Thanks ...

Exception handling with simplexmlrpcserver - python.

Hello, Is there any way to handle connection errors with simplexmlrpcserver module? I want to catch any errors within my xmlrpc server to handle them in my own way instead of printing the traceback to stdout. ...

can Distribute setuptool be used to convert python 2 packages to python 3?

As per the below link porting python packages from 2 to 3 would be easy when distribute is used. Is tat true? anyone tried before? karnol ...

Informational messages in python unit testing

I'm using Python's unittest module for unit testing. I'd like to be able to report informational messages as part of the unit test output—other than pass/fail status. Specifically in my case, I want to report whether the module under test is using the pure Python implementation or the C extension. Is there a mechanism in unittest to ou...