python

Django - How to share configuration constants within an app?

It is sometimes beneficial to share certain constants between various code files in a django application. Examples: - Name or location of dump file used in various modules\commands etc - Debug mode on\off for the entire app - Site specific configuration What would be the elegant\pythonic way of doing this? ...

Can we generate DTMF tones using python?

Hello, i am keen to know whether we can generate a DTMF tones using python? If yes then is there any library to do so? I have checked on the net there i could find sample program to decode the DTMF tones but not vice-versa. It would be great if anyone can give me some hint. Thanks, Rupesh ...

URL updating on login using django

Hi , I have started using django very recently . I am building a service with user login. Login , I am sending as POST service. There is a template to render , once the user is logged in. But the browser address is not getting updated. eg : abc.com the root my form would be something like "form action="/login" .....>" ...

python Qt4 How to bind action on button click

hi! I'm trying make my first python app. I want make simple email sender form. In qt designer create a dialog.ui, then generate dialog.py from dialog.ui and write there function def SendEmail(self,efrom,eto,esubj,ebody): msg = MIMEText( ebody.encode('UTF-8'),'html', 'UTF-8') msg['Subject'] = esubj msg['From'] = efrom msg...

Reading an audiostream in python.

Hi, Amazingly, in bash, you can do $ curl http://mp3.streampower.be/radio1-high.mp3 > test.mp3 with an audiostream and then ^C out, and you will have a working mp3 file, leading me to believe I could have this automated in python, but I can't find how. If i just do file('python.mp3', 'w').write(urllib2.urlopen("http://mp3.streampo...

Rendering dynamic images with google app engine.

Hi All, I am working on a Google app engine project where I have saved some images in the datastore. Now I have to resize these images and render them to the template. I have successfully fetched the images but I am not getting,how to render them with other data dictionaries to the template. I am using App engine patch with GAE. Follo...

how to process an audio file using python

how to process an audio file using python ...

Downloading files using Python

Hi. I need to download files from the internet. For that I am using subprocess and calling wget. Is this the right way? The files are hosted on static links and there is no need to log in or anything. I glanced over urllib but I could not find any example of it being used to download files of other types. Any suggestions? ...

[python] mysqldb rowcount bug?

Hello I've got some problems with a script I'm writing. #!/usr/local/bin/python import MySQLdb ConvDB = MySQLdb.Connect(host="1.1.1.1", user="123", passwd="123", db="somedb") ConvDBcursor = ConvDB.cursor() query="SELECT id from sometable WHERE somethng=63" print query ConvDBcursor.execute(query.decode('cp1251').encode('utf8')) print...

Back-casting a ctypes.py_object in a callback

I am trying to wrap a C library using ctypes. One feature of the library is an ondestroy callback which is called when a handle returned by the library is about to be destroyed. The callback has the signature: void cb(f *beingdestroyed); The API allows one to associate a user-specified void * with f when it is returned by the librar...

how to make a script be active for only on every hour on the half hour?

Hello all. I have a script and I want to code it so that it becomes active every hour on the half hour. This is the code I have so far. from ConfigParser import * import emailModule from datetime import datetime import time configuration = ConfigParser() configuration.read('Email.conf') email = emailModule.emailModule(configuration) ...

Python equivalent of Curl HTTP post

I am posting to Hudson server using curl from the command line using the following-- curl -X POST -d '<run><log encoding="hexBinary">4142430A</log><result>0</result><duration>2000</duration></run>' \ http://user:pass@myhost/hudson/job/_jobName_/postBuildResult as shown in the hudson documentation..can I emulate the same thing using p...

How can I set UVs to a Mesh in Blender Python ?

Using Blender 2.49's Python API I'm creating a mesh. I have a list of vertices and a list of face indices. e.g. mesh = bpy.data.meshes.new('mesh') mesh.verts.extend(mVerts) mesh.faces.extend(mFaces) I've noticed MVert's uvco property and MFace's uv property, and added some random values, but I can't see any change when I render. Re...

Django: Save to a many-to-many field in a ModelForm's save() method?

I'm writing a webblog app in Django. I currently have 2 models Post and PostMeta. Post is a standard post style model with fields such as author, title, content etc. It also contains a single many-to-many field called post_meta which is associated with my second model PostMeta. PostMeta is a simple name/value model with two fields, meta_...

python: How do I assign values to letters?

I want to assign a value to each letter in the alphabet, so that a -> 1, b -> 2, c -> 3, ... z -> 26. Something like a function which returns the value of the letter, for example: value('a') = 1 value('b') = 2 etc... How would I go about doing this in python? ...

Error in `import objc` : Symbol not found: _PyType_Modified

My system is Mac OS X 10.5.8 and I have installed python from http://www.python.org/ftp/python/2.5.4/python-2.5.4-macosx.dmg because I do not want to use System python (python which already comes installed with Mac OS X) and have totally removed system python. Now when I try to install pyobjc it installs, but on import gives error Pyth...

Parsing .c/.cpp/.py source files in Python to get a list of the functions contained

I'm trying to learn about parsers, for Python, C and C++ source (on my own, not for a school project). Here is a summary of what i want to do: 1) read .c/.cpp/.py source files in Python 2) get a list of all the functions in the source files, and the span of their definitions in terms of line numbers. So to illustrate my question, con...

java-applet gui testing with python

is there any frame-work or tool to test java-applets in python ...

Why can't I create a COM object in a new thread in Python?

I'm trying to create a COM Object from a dll in a new thread in Python - so I can run a message pump in that thread: from comtypes.client import CreateObject import threading class MessageThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.daemon = True def run(self): pri...

Using lxml to find order of text and sub-elements

Let's say I have the following HTML: <div> text1 <div> t1 </div> text2 <div> t2 </div> text3 </div> I know of how to get the text and subelements of the enclosing div using lxml.html. But is there a way to access both text and sub elements in an iterative manner, that preserves order? In other words, I want to know where the "fr...