python

Get object created in child thread back in main thread

Assume i want to create 500 wxWidget like (some panels , color buttons and text ctrl etc), I have to create all this at single time but this will freeze my main thread, so i put this creation part in child thread and show some gif anim in main thread. But i was not able to get all these wxWidget object those created on my frame in child ...

How to manage several python subprojects with setuptools?

I'm wondering about the correct/easiest/most pythonic way of dealing with subprojects that you want have using the same base package. We currently have a file structure like this: trunk\ proj1\setup.py company_name\__init__.py + proj1's code proj2\setup.py company_name\__init__.py + proj2's code We want to ...

Debug a python script used with nmake

I have a Visual Studio project which uses nmake to call a Python file for clean, build, or rebuild. For ex. in VS project properties->Configuration Properties->NMake, for the Build Command Line I would have ....\blah\tools\myBuildFile.py build -arg1 -arg2 There are several python files used with lots of variables and routines so I wou...

Question about starting SSH tunnel using Python

I have ran into trouble while starting SSH tunnel from HTTP RPC server written in Python. There is a simple HTTP RPC server written in Python based on Python's BaseHTTPServer. As a part of one of the services I would like to start a SSH tunnel from the RPC server to a remote machine. I used os.system to start the SSH tunnel in the Pyth...

Function Names for sending and receiving RPCs?

I'm using twisted. I have my protocols set up so that, to send an RPC, I do protocol.send("update_status", data). To document which RPCs I've implemented, I make a separate function call for each one, so in this case I'd call REQUEST_UPDATE_STATUS(data) to send that RPC. When a protocol receives an RPC, a function gets called based on it...

What is the correct way to unset a linux environment variable in python?

From the documentation: If the platform supports the unsetenv() function, you can delete items in this mapping to unset environment variables. unsetenv() will be called automatically when an item is deleted from os.environ, and when one of the pop() or clear() methods is called. However I want something that will work regardless of...

Error configuring Django to run customized comments framework

I'm having an issue with setting up a Django website which uses the Django comments framework on my server. The site runs fine when run locally (using manage.py runserver) but when pushed live I'm getting the error: ImproperlyConfigured at / The COMMENTS_APP setting refers to a non-existing package. My server is an apache/mod_wsgi setu...

python+twisted+gtk: KeyboardInterrupt causes free variable?

I'm using twisted with GTK, and the following code runs when a connection could not be established: def connectionFailed(self, reason): #show a "connect failed" dialog dlg = gtk.MessageDialog( type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format="Could not connect to server:\n%s" % ( ...

copy objects between different Virtual-Machines efficiently

I have a feeling that I am going to ask a "stupid" question, yet I must ask ... I have 2 virtual machines. I would like to copy an instance of an object from one to another, Is it possible to copy the bits that represents this object in the VM's heap, send it to the other VM, like that the other VM just need to allocate the bits in it...

Extracting Text from Parsed HTML with Python

I'm new to Python and I have been trying to search through html with regular expressions that has been parsed with BeautifulSoup. I haven't had any success and I think the reason is that I don't completely understand how to set up the regular expressions properly. I've looked at older questions about similar problems but I still haven't ...

Do I need *.egg-info directories when using setuptools/distribute to create a python package

I have a "standard" python package layout like this: setup.py - using setuptools README src/moduleA test/ However, when I execute setup.py it decides to create the directory src/moduleA.egg-info. The question is, do I need to worry about the contents of this directory and check it in with the rest of my code, or should I just rely ...

Parse html with ajax json inside

Hi I have such files to parse (from scrapping) with Python: some HTML and JS here... SomeValue = { 'calendar': [ { 's0Date': new Date(2010, 9, 12), 'values': [ { 's1Date': new Date(2010, 9, 17), 'price': 9900 }, { 's1Date': new Date(2010, 9, 18), 'price': 9900 }, ...

python subprocess with timeout and large output (>64K)

I want to execute a process, limit the execution-time by some timeout in seconds and grab the output produced by the process. And I want to do this on windows, linux and freebsd. I have tried implementing this in three different ways: cmd - Without timeout and subprocess.PIPE for output capture. BEHAVIOUR: Operates as expected but do...

Blob object for python (ctypes), C++

Hallo! I want a blob object which I can pass around in python and from time to time give it to a C++ function to write to. ctypes seems the way to go but I have problem with the python standard functions. For example: >>> import ctypes >>> T=ctypes.c_byte * 1000 >>> blob = T() >>> ctypes.pointer(blob) <__main__.LP_c_byte_Array_1000 o...

gtk treeviewcolumn with differend combo model for each row

I have a global set of values, e.g. ["Foo", "Bar", "Baz", "Quux"]. Each row in my TreeView represents an entity that can only deal with a subset of these values. For example, the first row might deal with "Foo" and "Bar", and the second, "Bar" and "Quux". I want a ComboBox column to allow each row to select one of the values it can deal ...

How can I get pointer type behaviour in python

Hi, I want to write a test case which will test a list of functions. Here is an example of what I want to do: from mock import Mock def method1 (): pass def method2 (): pass ## The testcase will then contain: for func in method_list: func = Mock() # continue to setup the mock and do some testing What I want to achie...

Python; Linked list and traversing!

Hi! Starting some programming with python at school now, and I don't know how to proceed with this problem. Any thoughts? Input consists of integer separated by line breaks. Your program should submit them in a linked list, traverse the linked list and print the highest number. Something to take the first number, and do an action whic...

Mercurial http interface under Ubuntu Hardy. Doesn't work

Hello, I am trying to deploy mercurial under Ubuntu 8.04. Mercurial packages were installed correctly, but when I've configured http interface I always get 500 error. I enabled outputting debug info to error.log and got: mod_wsgi (pid=21159): Exception occurred within WSGI script '/home/hg/rep/hgwebdir.wsgi'. Traceback (most recent ca...

How can I get Eclipse / PyDev to ignore alternatives to cls?

I have inherited some code that uses klass instead of PyDev's preferred cls: def func(klass): # do something that doesn't reference klass return True PyDev issues a warning that there is an unused parameter klass, which it wouldn't do if we used the parameter cls. Is there an easy way to let PyDev know that klass is the same ...

python pythonpath modules

Ok a short question: Is there any SIMPLE software with a GUI, that lets me manage my pythonpath, path python version in mac? So I could set my Python, pythonpath and python version i want to use. Thanks! @ katrielalex and S.Lott : I had a very nightmare with installing modules in python and as pointed out correctly in another questi...