python

What is the best approach for creating an agent framework in python for flexible script distribution and data collection

What I am trying to do: I have hundreds of servers with very large log files spread out at dozens of different clients. I am creating nice python scripts to parse the logs in different ways and would like to aggregate the data I am collecting from all of the different servers. I would also like to keep the changing scripts centralized...

Handle sys.exit() in cherrypy service

When you start/stop a python cherrypy service (compiled with py2exe), this works fine When I get a sys.exit() call (from my error handler), cherrypy quits, but the service remains hanging. Code: import cherrypy import win32serviceutil import win32service import sys SERVICE = None class HelloWorld: """ Sample request handler clas...

Can bin() be overloaded like oct() and hex() in Python 2.6?

In Python 2.6 (and earlier) the hex() and oct() built-in functions can be overloaded in a class by defining __hex__ and __oct__ special functions. However there is not a __bin__ special function for overloading the behaviour of Python 2.6's new bin() built-in function. I want to know if there is any way of flexibly overloading bin(), an...

Getting distutils to install prebuilt compiled libraries?

I manage an open source project (Remix, the source is available there) written in python. We ask users to run python setup.py install to install the software. Recently we added a compiled C++ package (a port of SoundTouch -- go to trunk/externals in the source to see it.) We'd like the setup.py file that installs the base Remix libraries...

Automate SSH login under windows.

Hello guys, I want to be able to execute openssh with some custom arguments and then be able to automatically login to the server. I want that my script will enter the password if needed and inject 'yes' if I'm prompted to add the fingerprint to the known hosts. I've found SharpSsh for C# that do that, but I also need to use -D parame...

pygtk loading a flow of image in only one pixbuf

Hello, I'm trying to embed a chartdrawer library that can only give me a bmp image in a buffer. I'm loading this image and have to explicitly call delete on the newly created pixbuf and then call the garbage collector. The drawing method is called each 50ms calling the garbage collector is realy CPU consuming. Is there a way to have...

Large Sqlite database search

How is it possible to implement an efficient large Sqlite db search (more than 90000 entries)? I'm using Python and SQLObject ORM: import re ... def search1(): cr = re.compile(ur'foo') for item in Item.select(): if cr.search(item.name) or cr.search(item.skim): print item.name T...

python web framework large project

Hi Everyone, I need your advices to choose a Python Web Framework for developing a large project: Database (Postgresql)will have at least 500 tables, most of them with a composite primary key, lots of constraints, indexes & queries. About 1,500 views for starting. The project belongs to the financial area. Alwasy new requirements are c...

App Engine Datastore IN Operator - how to use?

Reading: http://code.google.com/appengine/docs/python/datastore/gqlreference.html I want to use: := IN but am unsure how to make it work. Let's assume the following class User(db.Model): name = db.StringProperty() class UniqueListOfSavedItems(db.Model): str = db.StringPropery() datesaved = db.DateTimeProperty() clas...

Number of visitors in Django

In Django, how can I see the number of current visitors? Or how do I determine the number of active sessions? Is this a good method? use django.contrib.sessions.models.Session, set the expiry time short. Every time when somebody does something on the site, update expiry time. Then count the number of sessions that are not expired. ...

Python Video Framework

Hi, I'm looking for a Python framework that will enable me to play video as well as draw on that video (for labeling purposes). I've tried Pyglet, but this doesn't seem to work particularly well - when drawing on an existing video, there is flicker (even with double buffering and all of that good stuff), and there doesn't seem to be ...

How to import a module from a directory on level above the current script

For my Python application, I have the following directories structure: \myapp \myapp\utils\ \myapp\utils\GChartWrapper\ \myapp\model\ \myapp\view\ \myapp\controller\ One of my class in \myapp\view\ must import a class called GChartWrapper. However, I am getting an import error... myview.py from myapp.utils.GChartWrapper import * He...

Is there a python ftp library for uploading whole directories (including subdirectories)?

Heyas So I know about ftplib, but that's a bit too low for me as it still requires me to handle uploading files one at a time as well as determining if there are subdirectories, creating the equivalent subdirectories on the server, cd'ing into those subdirectories and then finally uploading the correct files into those subdirectories. ...

Why does declaring a descriptor class in the __init__ function break the descriptor functionality?

In class B below I wanted the __set__ function in class A to be called whenever you assign a value to B().a . Instead, setting a value to B().a overwrites B().a with the value. Class C assigning to C().a works correctly, but I wanted to have a separate instance of A for each user class, i.e. I don't want changing 'a' in one instance of C...

Django: How to sort a ModelForm's Many2ManyField (Select Tag) according to the object's __unicode__() value?

As stated in the title. ...

Know any creative ways to interface Python with Tcl?

Here's the situation. The company I work for has quite a bit of existing Tcl code, but some of them want to start using python. It would nice to be able to reuse some of the existing Tcl code, because that's money already spent. Besides, some of the test equipment only has Tcl API's. So, one of the ways I thought of was using the sub...

ctypes in Python 2.6 help

I can't seem to get this code to work, I was under the impression I was doing this correctly. from ctypes import * kernel32 = windll.kernel32 string1 = "test" string2 = "test2" kernel32.MessageBox(None, string1, string2, MB_OK) ** I tried to change it to Message...

How to distinguish field that requires null=True when blank=True is set in Django models?

Some model fields such as DateTimeField require null=True option when blank=True option is set. I'd like to know which fields require that (maybe dependent on backend DBMS), and there is any way to do this automatically. ...

Using Django JSON serializer for object that is not a Model

Is it possible to use Django serializer without a Model? How it is done? Will it work with google-app-engine? I don't use Django framework, but since it is available, I would want to use its resources here and there. Here is the code I tried: from django.core import serializers obj = {'a':42,'q':'meaning of life'} serialised = seri...

Winpdb and Python extension modules

I have built 2 Python extension modules using Visual Studio 2008. I wrote a small test application in Python that imports the modules' functionality and exercises some of it. I can debug the extensions via this small test app using Visual Studio but I want to also debug the test app itself with Winpdb. When I start my small app with Winp...