python

authorization on google appengine application

Please, help. How can I validate user's group membership? Only users of a few google groups can access some pages on the site on appengine (python). validating group membership gives a negative answer to my question, but it was a year ago, maybe something has changed.. ...

hot reloading / swapping with Python

I want code changes to take effect immediately during development. How can I detect changed files and reload them in the running Python (2.7) application? Edit: After reading the pages linked by 'Ivo van der Wijk', I think it would be best to restart the web application when code changes - like Django does. So the actual question is: H...

WSGI request and response wrappers

I'm looking for WSGI request and response wrappers for having a more convenient interface than the plain WSGI environ and start_response callback. I want something like WebOb or Werkzeug. But I don't like WebOb's PHP-like usage of GET and POST for parameter dictionaries, because HTTP is not limited to GET and POST and the distinction is ...

Setuptools : how to use the setup() function within a script (no setup specific command line argument)

Hi there! I'm writing a tool to automatically generate .egg files from python projects. The tool basically discovers some properties to guess the setup options (such as version number etc). Now I would like to call the setup() function, with the context bdist_egg. I do as such : if __name__ == '__main__' project_dir = _get_dir(sy...

How to monitor Python files for changes?

I want to restart my Python web application, if code gets changed. But there could be a large number of files that could be changed, since files in imported modules could change ... How to get the actual file names from imported packages / modules? How can modified Python files be detected efficiently? Is there a library to do that? ...

Python SocketServer

Hi, How can I call shutdown() in a SocketServer after receiving a certain message "exit"? As I know, the call to serve_forever() will block the server. Thanks! ...

Ruby Mash equivalent in Python?

Hi all, in Ruby, there's this awesome library called a Mash which is a Hash but through clever use of missing_method can convert: object['property'] to object.property This is really useful for mocks. Anyone know of a similar kind of thing in Python? ...

PyDev bugs with imports

Hello all, I am using PyDev/Eclipse for several monthes and I get ever and ever the same bugs with imports: PyDev underline in red an import and say Unresolved import xxx ; Found at yyy. When I click on yyy eclispe find and open the implementation of the module. (PyDev just inform me that it can't find the module xxx and in the same mes...

python nose and twisted

I am writing a test for a function that downloads the data from an url with Twisted (I know about twisted.web.client.getPage, but this one adds some extra functionality). Either ways, I want to use nosetests since I am using it throughout the project and it doesn't look appropriate to use Twisted Trial only for this particular test. So w...

How to extract the bitrate and other statistics of a video file with Python

I am trying to extract the prevailing bitrate of a video file (e.g. .mkv file containing a movie) at a regular sampling interval of between 1-10 seconds under conditions of normal playback. Kind of like you may see in vlc, during playback of the file in the statistics window. Can anyone suggest the best way to bootstrap the coding of s...

Can I safely use hashes of tuples containing 64 bit integers (longs) as unique keys in a python dictionary?

I have to store objects that have two attributes (ida and idb) inside a dict. Both attributes are 64 bit positive integers and I can only store one object for a unique arrangement(combination in which the order matters) of ida and idb. For example: obj1 = SomeClass(ida=5223372036854775807, idb=2) obj2 = SomeClass(ida=2, idb=522337203685...

Python's StringIO for Clojure

Hi, Is there something equivalent to Python's StingIO for Clojure? I'm trying to write a report generating/literate programming system similar to Sweave and Pweave for Clojure. I'm currently using a temp file, but I'd prefer using something similar to StringIO. ...

Agnostic automated deployment

What do you use to automatically deploy applications for various kinds of server applications (web, socket, daemon) that uses various technologies (different DBs, languages, etc)? Here we use Python, Java and Ruby, and may use other languages as well in the future. ...

Adding or merging python dictionaries without loss

I'm trying to count up ip addresses found in a log file on two servers and then merge the dictionary stats together without loosing elements or counts. I found a partial solution in another stack overflow question but as you can see it drops the '10.10.0.1':7 pair. >>> a = {'192.168.1.21':23,'127.0.0.1':5,'12.12.12.12':5,'55.55.55.55':1...

Import from a Django project with a different top-level folder name

I recently setup a deployment solution for my Django project using Fabric. The basic workflow being: Check out the latest source from git on the server. Copy it to a 'releases' directory and add a timestamp to the directory name. Update the 'current' symlink to point to the latest build. This works just fine, only problem is, since t...

Installing activeX controls

I have been tasked with installing a certain control across the network. I have access to wise installMaster, installbuilder, SMS installer, Advanced Installer, python, PSexec, MSIexec. I have tried on WInXP to register this control using regsvr32, i get that has sucedded in registering, however, its not getting listed within internet o...

Using reStructuredText to add some HTML with custom "id" and "class" attributes

Using rsStructuredText to generate HTML, I am trying to wrap a paragraph with an extra div element. The must contain an "id" attribute with a value I assign. Also, the must have a "class" attribute with "editable" value. This is what I have so far: .. raw:: html <div id="an_identifier"> .. class:: editable ...

Resampling irregularly spaced data to a regular grid in Python

Hi! I need to resample 2D-data to a regular grid. This is what my code looks like: import matplotlib.mlab as ml import numpy as np y = np.zeros((512,115)) x = np.zeros((512,115)) # Just random data for this test: data = np.random.randn(512,115) # filling the grid coordinates: for i in range(512): y[i,:]=np.arange(380,380+4*...

Python: Dynamically import module contents

I have lots of from myproject.settings import param1 from myproject.settings import ... scattered all over my project. Upon startup, I would like to load different "settings" module according to env var (for example export SETTINGS=myproject.settings2) I tried to put in the myproject.__init__.py someting like module_name = os.en...

about python __doc__ docstring

i want to show docstring of my function, but if i use like this @cost_time def func(): "define ...." blabla print func.__doc__ it will not show the docstring,just because i use some meta programming tricky, how can fix this? ...