python

How can I make pybluez return a list of discovered devices every X seconds and then repeat?

I've been trying to figure out how I can use pybluez to monitor nearby devices... I want to be able to run my program and have it search for devices every 20 seconds. The problem is, how do I get pybluez to place nicely? :/ Using their example code http://code.google.com/p/pybluez/source/browse/trunk/examples/simple/inquiry.py, it's ea...

lxml version problem - unable to call fndall method !

lxml gives following error on version 1.3 for the below line.. self.doc.findall('.//field[@on_change]') File "/home/.../code_generator/xmlGenerator.py", line 158, in processOnChange onchangeNodes = self.doc.findall('.//field[@on_change]') File "etree.pyx", line 1042, in etree._Element.findall File "/usr/lib/python2.5/site-packages/lxm...

What are the major components of an affiliate marketing system?

I am thinking of "rolling my own" Affiliate marketing system - using either PHP (or more preferably, Python). I am relatively new to Affiliate marketing, so before I get started though I wanted to make sure that I had covered all bases, and was also not reinventing the wheel (in terms of there being a good open source [Python based] syst...

Does XML-RPC in general allows to call few functions at once?

Can I ask for few question in one post to XML-RPC server? If yes, how can I do it in python and xmlrpclib? I'm using XML-RPC server on slow connection, so I would like to call few functions at once, because each call costs me 700ms. ...

I'm trying to make a wx.Frame with variable transparancy (based on the png mapped in the erase bk event)

Hello, I'm trying to make a special splash screen that is displayed while the application is loading, it outputs messages of the various components loading and features a progress bar. The first job I am tackling is mapping a .png image to the frame that will host the splash screen. import wx class edSplash(wx.Frame): def __...

How to use py.test from Python?

I'm working in a project that recently switched to the py.test unittest framework. I was used to call my tests from Eclipse, so that I can use the debugger (e.g. placing breakpoints to analyze how a test failure develops). Now this is no longer possible, since the only way to run the tests is via the command line blackbox. Is there some...

What gui toolkit should I use with Pygame?

I'm making a game that needs to be able to pop up gui elements within a pygame surface. This question isn't what I want because wxPython goes around the SDL surface, not inside it. So far I've only seen ocemp, pgu, and GooeyPy in this problem space. Ocemp is huge and crufty looking. It mentions Python 2.3 and the newest file I found in...

Sqlite db, multiple row updates: handling text and floats

Hi, I have a large SQLite database with a mix of text and lots of other columns var1 ... var 50. Most of these are numeric, though some are text based. I am trying to extract data from the database, process it in python and write it back - I need to do this for all rows in the db. So far, the below sort of works: # get row using sele...

Django: construct form without validating fields?

Hi, I have a form MyForm which I update using ajax as the user fills it out. I have a view method which updates the form by constructing a MyForm from request.POST and feeding it back. def update_form(request): if request.method == 'POST': dict = {} dict['form'] = MyForm(request.POST).as_p() return HttpResp...

Django - complex forms with multiple models

Django 1.1 models.py: class Property(models.Model): name = models.CharField() addr = models.CharField() phone = models.CharField() etc.... class PropertyComment(models.Model): user = models.ForeignKey(User) prop = models.ForeignKey(Property) text = models.TextField() etc... I have a form which needs t...

Merging two datasets in Python efficiently

What would anyone consider the most efficient way to merge two datasets using Python? A little background - this code will take 100K+ records in the following format: {user: aUser, transaction: UsersTransactionNumber}, ... and using the following data {transaction: aTransactionNumber, activationNumber: assoiciatedActivationNumber}, ...

Starting a GUI process from a Python Windows Service

I am creating Windows service class in Python that will eventually display a Window when certain conditions are met. Since (as I understand it) services cannot have GUIs, I'm trying to start up a GUI in a seperate process (using subprocess.Popen) when the conditions are right. This isn't working, presumably because the child process has ...

Obfuscating Python code?

I am looking for how to hide my Python source code. print "hello World !" How can I encode this example so that it isn't human-readable? I've been told to use base64 but I'm not sure how… Can anyone tell me how to hide Python code? (I want to encode around 30 lines.) ...

Why does the istitle() string method return false if the string is clearly in title-case?

Of the istitle() string method, the Python 2.6.5 manual reads: Return true if the string is a titlecased string and there is at least one character, for example uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return false otherwise. But in this case it returns false: >>> book = 'wh...

sqlalchemy in a single python script file

I've read about using sqlalchemywithin the pylons framework. How will things work if I need it for a simple script file? I have like importer.py that is spidering a site and I want to save to mysql. If things are in a single file, can I still using sqlalchemy? How do I setup my model/mappings then? ...

Hiding the time in a datetime model field in Django?

I'm using Thauber's lovely Django schedule app, but have run into a problem: I can't figure out how to exclude the time portion of the datetime field. My form class and lame exclusion attempt looks like this: class LaundryDeliveryForm(EventForm): start = forms.DateTimeField(widget=forms.SplitDateTimeWidget) end = forms.DateTim...

Geopy in Django: JSONDecodeError

Hello, I have followed the tutorials in http://code.google.com/p/geopy/wiki/GettingStarted This works fine: g = geocoders.Google(resource='maps') I want to use json as the output format because I want to handle the results in javascript. BUT everytime I use: g = geocoders.Google(resource='maps', output_format='json') I get the e...

Splitting a string separated by "\r\n" into a list of lines?

I am reading in some data from the subprocess module's communicate method. It is coming in as a large string separated by "\r\n"s. I want to split this into a list of lines. How is this performed in python? ...

multicpu bzip2 using a python script

I want to quickly bzip2 compress several hundred gigabytes of data using my 8 core , 16 GB ram workstation. Currently I am using a simple python script to compress a whole directory tree using bzip2 and an os.system call coupled to an os.walk call. I see that the bzip2 only uses a single cpu while the other cpus remain relatively idle. ...

python: getting user input

i am running this: import csv import sys reader = csv.reader(open(sys.argv[0], "rb")) for row in reader: print row and i get this in response: ['import csv'] ['import sys'] ['reader = csv.reader(open(sys.argv[0]', ' "rb"))'] ['for row in reader:'] [' print row'] >>> for the sys.argv[0] i would like it to prompt me to enter...