python

Python TCP Server, writing to clients?

Hi I have a tcp server which uses the select call to multiplex reading from clients. I have a client class (MClient) which manages the decoding of incoming data packets while(1) rlist, wlist, xlist = select( input_sockets, output_sockets, [] , 1) for insock in rlist: #any clients???? if insock is server_socket: ...

How can I make the Eclipse Python debugger more reliable?

I've found that under some circumstances the Eclipse python debugger can be unreliable. For example, when stepping through a memory-hungry Python program I've found that after a certain point the debugger fails to respond. The entire process hangs with 100% cpu load. I've heard (unconfirmed) reports from developers that when this occur...

Resident Set Size (RSS) limit has no effect

The following problem occurs on a machine running Ubuntu 10.04 with the 2.6.32-22-generic kernel: Setting a limit for the Resident Set Size (RSS) of a process does not seem to have any effect. I currently set the limit in Python with the following code: import resource # (100, 100) is the (soft, hard) limit. ~100kb. resource.setrlimit(r...

Many-to-many relationship on same table with association object

Related (for the no-association-object use case): http://stackoverflow.com/questions/1889251/sqlalchemy-many-to-many-relationship-on-a-single-table Building a many-to-many relationship is easy. Building a many-to-many relationship on the same table is almost as easy, as documented in the above question. Building a many-to-many relation...

Use Regular expression with fileinput

Hello, I am trying to replace a variable stored in another file using regular expression. The code I have tried is: r = re.compile(r"self\.uid\s*=\s*('\w{12})'") for line in fileinput.input(['file.py'], inplace=True): print line.replace(r.match(line), sys.argv[1]), The format of the variable in the file is: self.uid = '027FC8E...

Problem with Django styling

Hi new to django but I'm having issues with the stylesheets (CSS) of pages. my settings.py contains MEDIA_ROOT = '' MEDIA_URL = '' TEMPLATE_DIRS = ( os.path.join(os.path.dirname(__file__), 'templates'), ) please can someone help me shed some light on what I need to do to get the CSS styles working in my templates Thanks ...

Simulate Browser Resources Expansion Behavior With Python

I'm looking for a way to simulate browser resources expansion behavior. The flow I'm trying to address is the following: Access an initial URL (e.g. http://example.dmn/index.htm) Parse the html response received (e.g. index.htm) Find the resources that a browser will fetch as a result of the index parsing, e.g.: Images Flash ...

Fetching just the Key/id from a ReferenceProperty in App Engine

Hi SO, I could use a little help in AppEngine land... Using the [Python] API I create relationships like this example from the docs: class Author(db.Model): name = db.StringProperty() class Story(db.Model): author = db.ReferenceProperty(Author) story = db.get(story_key) author_name = story.author.name As I understand it, t...

unattended install of binary python packages (modules) for windows

Is there no sane way to peform a scripted install of binary python packages for windows? Unfortunately it seems like several essential windows python packages like pywin32 and py2exe are only available as EXE's not MSI's (and as far as I know only the latter are scriptable). Easy_install/pip also seems no use since they apparently only f...

Showing updated content on the client

Hi, I have a file on server which is viewed by the client asynchronously as and when required . The file is going to get modified on server side . Also updates are reflected in browser also In my views.py the code is : def showfiledata(request): somecommand ="ls -l > /home/tazim/webexample/templates/tmp.txt" with open("/h...

regular expression - function body extracting

Hi, in Python script, for every method definition in some C++ code of the form: return_value ClassName::MethodName(args) {MehodBody} I need to extract three parts: the class name, the method name and the method body for further processing. Finding and extracting the ClassName and MethodName is easy, but is there any simple way to ex...

SQLAlchemy: How to group by two fields and filter by date

So I have a table with a datestamp and two fields that I want to make sure that they are unique in the last month. table.id table.datestamp table.field1 table.field2 There should be no duplicate record with the same field1 + 2 compound value in the last month. The steps in my head are: Group by the two fields Look back over the las...

Qt/PyQt dialog with togglable fullscreen mode - problem on Windows

I have a dialog created in PyQt. It's purpose and functionality don't matter. The init is: class MyDialog(QWidget, ui_module.Ui_Dialog): def __init__(self, parent=None): super(MyDialog, self).__init__(parent) self.setupUi(self) self.installEventFilter(self) self.setWindowFlags(Qt.Dialog | Qt....

how do i take advantage of sqlite manifest typing / type affinity using sqlalchemy?

I like the idea of sqlite's manifest typing / type affinity: http://www.sqlite.org/datatype3.html Essentially, if I set a column's affinity as 'numeric', it will duck type integers or floats to store them as such, but still allow me to store strings if I want to. Seems to me this is the best 'default' type for a column when i'm not su...

Multiprocessing vs Threading Python

Hello, I am trying to understand the advantages of the module Multiprocessing over Threading. I know that Multiprocessing get's around the Global Interpreter Lock, but what other advantages are there, and can threading not do the same thing? ...

On thread safety in python using D-Bus asynchronous method calls

I write a python class which makes asynchronous method calls using D-Bus. When my reply_handler is called, it stores data in list. This list can be used by another class methods at the same time. Is it safe or I can use only synchronized data structures like Queue class? ...

Python vs. Java performance (runtime speed)

Possible Duplicate: is python slower than java/C#? Ignoring all the characteristics of each languages and focusing SOLELY on speed, which language is better performance-wise? You'd think this would be a rather simple question to answer, but I haven't found a decent one. I'm aware that some types of operations may be faster w...

Custom headers with pycurl ?

Hi i'm wondering if i can send a custom header like "yadayadayad" to the server with the pycurl requsest ? Thanks :) ...

In django : how to renew expiry date for current session ?

I have a user logged in. How can i extend/renew expiry date of session received from the request ? Thanks in advance! ...

I'm trying to install psycopg2 onto Mac OS 10.6.3; it claims it can't find "stdarg.h" but I can see it's there; what should I do?

I'm desperately trying to successfully install psycopg2 but keep running into errors. The latest one seems to involve it not being to find "stdarg.h" (see code below). However I can see with my own eyes that a file called stdarg.h exists at /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h (where it claims it can't find anything) so I...