Using Python 2.6.1 on Mac OS X 10.6.2, I've the following problem:
I have a threaded process (a Thread class), and each of those threads has a pipe (a subprocess.Popen) something likeso:
from threading import Thread
cmd = "some_cmd"
class Worker(Thread):
def run(self):
pipe = Popen(cmd,
stdin=PIPE,
stdou...
I am trying to get a list of elements with a specific xsd type with lxml 2.x and I can't figure out how to traverse the xsd for specific types.
Example of schema:
<xsd:element name="ServerOwner" type="srvrs:string90" minOccurs="0">
<xsd:element name="HostName" type="srvrs:string35" minOccurs="0">
Example xml data:
<srvrs:ServerOwner...
When using python-daemon, I'm creating subprocesses likeso:
import multiprocessing
class Worker(multiprocessing.Process):
def __init__(self, queue):
self.queue = queue # we wait for things from this in Worker.run()
...
q = multiprocessing.Queue()
with daemon.DaemonContext():
for i in xrange(3):
Worker(q)
...
I'd like to be able to pull users from a database using either a supplied e-mail address or the user id (an integer). To do this, I have to detect if the supplied string is an integer, or an e-mail. Looking for the fastest way to do this. Thanks.
def __init__(self, data):
#populate class data
self._fetchInfo(data)
def _fetc...
I have added C:\Python26\Lib\site-packages\django\bin to my path, I have started a new cmd session in Windows 7, but when I try to do 'python django-admin.py ...' it says there is no file django-admin.py. When I type path, there is the full path to ...\django\bin. This is driving me nuts. Clearly it's there, but it's not working. Any su...
Hi all, i wanna write an IM server in python, but i'm not sure if python can handle the heavy connections?
Thanks in advance.
...
I'm trying to figure out how to use decorators on subclasses that use super(). Since my class decorator creates another subclass a decorated class seems to prevent the use of super() when it changes the className passed to super(className, self). Below is an example:
def class_decorator(cls):
class _DecoratedClass(cls):
def ...
How do you determine which file is imported in Python with an "import" statement?
I want to determine that I am loading the correct version of a locally modified .py file. Basically the equivalent of "which" in a POSIX environment.
...
Looking to have a database query set all the instance variables in a class:
Example:
def populate(self, if):
#Perform mysql query
self._name = row['name']
self._email = row['email']
...
What's the fastest way to do this? Or is this not recommended (with a better approach)?
Thanks.
...
Looking to implement better geo-location with Python.
Thanks.
...
Hi I am running Windows XP, on 32bit. How do I install python? When I run the installation file, it gives me an error saying "installation package not supported by processor type" does python need 64 bit to execute?
...
How can I can set a global variable for the username of the logged-in user? At the moment i have the following code in all my controllers to get the username. I rather set it as a global variable if possible.
request.environ.get("REMOTE_USER")
I tried putting the same code in the app_globals.py file but it gave me the following error m...
Update:
I switched this back from answered as I tried the solution posed in cogent Nick's answer and switched to Google's urlfetch:
logging.debug("starting urlfetch for http://%s%s" % (self.host, self.url))
result = urlfetch.fetch("http://%s%s" % (self.host, self.url), payload=self.body, method="POST", headers=self.headers, allow_trun...
I would like to code something with augmented reality, do you know any python library to play with?
...
Hi,
I want to change the colour of a product in an image. for example http://www.momgoesgreen.com/wp-content//ikea-blue-bags.jpg. I want to change the colour of the product to anything i like for example to black, red or brown using python . Please give a sample code
Thanks
...
Hi all,
I try to get a list with distinct into the forms.py like this:
forms.ModelMultipleChoiceField(queryset=Events.objects.values('hostname'), required=False).distinct()
In the python shell this command works perfect, but when trying it in forms.py leaves me a blank form, so nothing appears. When i just do Events.objects.all() the ...
Hello guys, I'm trying to setup blog engine django-mingus, but meet this obstacle:
[Tue Mar 30 04:14:02 2010] [error] [client 192.168.12.161] mod_wsgi (pid=12908): Exception occurred processing WSGI script '/home/piv/srv/python-env/myblog/project/django-mingus/mingus/deploy/django.wsgi'.
[Tue Mar 30 04:14:02 2010] [error] [client 192.16...
My question is not about a specific code snippet but more general, so please bear with me:
How should I organize the data I'm analyzing, and which tools should I use to manage it?
I'm using python and numpy to analyse data. Because the python documentation indicates that dictionaries are very optimized in python, and also due to the f...
Hello,
I have a camera and I am trying to connect to it vis suds. I have tried to send raw xml and have found that the only thing stopping the xml suds from working is an incorrect Soap envelope namespace.
The envelope namespace is:
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
and I want to rewrite it to:
xmlns:SOAP-EN...
I'm relatively new to wxPython (but not Python itself), so forgive me if I've missed something here.
I'm writing a GUI application, which at a very basic level consists of "Start" and "Stop" buttons that start and stop a thread. This thread is an infinite loop, which only ends when the thread is stopped. The loop generates messages, whi...