python

Python: Access a MySQL db without MySQLdb module.

Is there another way to connect to a MySQL database with what came included in the version of Python (2.5.1) that is bundled with Mac OS 10.5.x? I unfortunately cannot add the the MySQLdb module to the client machines I am working with...I need to work with the stock version of Python that shipped with Leopard. ...

Provide a proxy to a SOAP server

I have a client application that needs to access a 3rd party SOAP server. The difficultly is that there are additionally these two requirements: a) Requests can be scheduled so they may need to be delayed before being sent to the SOAP server for X seconds b) Requests need to be modified to add authentication headers So the solution r...

Google apps login in django

Hello world, I'm developing a django app that integrates with google apps. I'd like to let the users login with their google apps accounts (accounts in google hosted domains, not google accounts) so they can access their docs, calendar, and whatnot. In order to do it, I downloaded and started using django_openid_auth (and thus, python-...

Genshi TemplateSyntaxError on python block where it should work

<?python class += 1 ?> One really simple line of code which definitely should work, but still it gives me this error: TemplateSyntaxError: invalid syntax (file.html, line 22) I shorted the filepath for readability, but that's the exact error. I'm definitely sure it should work, as I've used <?python i += 1 ?> In another file,...

How does this decorator make a call to the 'register' method?

I'm trying to understand what is going on in the decorator @not_authenticated. The next step in the TraceRoute is to the method 'register' which is also located in django_authopenid/views.py which I just don't understand because I don't see anywhere that register is even mentioned in signin() How is the method 'register' called? def n...

Using ECF shared editing with Python

I can use the shared editing feature of ECF with Java fine perfectly fine. When I try to do it with Python files it also works, but there is no syntax highlighting. I installed PyDev to get syntax highlighting, but then the context menu does not have the "share editor" option. I removed PyDev and the option came back. I installed Dynami...

Python: Getting INVALID response from PayPal's Sandbox IPN, slowly going insane...

...

Python & sql server

What is the best way to access sql server from python is it DB-API ? Also could someone provide a such code using the DB-API how to connect to sql server from python and excute query ? ...

Python: Why does right shift >> round down and where should it be used?

I've never used the >> and << operators, not because I've never needed them, but because I don't know if I could have used them, or where I should have. 100 >> 3 outputs 12 instead of 12.5. Why is this. Perhaps learning where to best use right shift will answer that implicitly, but I'm curious. ...

Using python to run other programs

I have a command that works great on the command line. It has lots of arguments like cmd --thing foo --stuff bar -a b input output I want to run this from python and block waiting for it to complete. As the script prints things to stdout and stderr I want it to be immediately shown to the user. What is the right module for this? I'v...

[Django] In model save() how to get all field starting with 'foo'

Hi, I've this django model: from django.db import models class MyModel(models.Model): foo_it = model.CharField(max_length=100) foo_en = model.CharField(max_length=100) def save(self): print_all_field_starting_with('foo_') super(MyModel, self).save() So I want to get all field starting with foo (as an exam...

python logging to database

I'm seeking a way to let the python logger module to log to database and falls back to file system when the db is down. So basically 2 things: How to let the logger log to database and how to make it fall to file logging when the db is down. ...

How to plot the lines first and points last in matplotlib

I have a simple plot with several sets of points and lines connecting each set. I want the points to be plotted on top of the lines (so that the line doesn't show inside the point). Regardless of order of the plot and scatter calls, this plot comes out the same, and not as I'd like. Is there a simple way to do it? import math import ...

Would using a WSDL to generate REST clients be the wrong direction?

I'm out to create a fairly simple web service for intranet use. The service will ultimately be the interface to a DB that will allow me to keep track of what the various internal tools within the company are doing. I'm thinking I want a web service so that various tools (and thus different languages) within the organization can easily ...

How can I use the Whirlpool hash with Django authentication ?

We have a system written in PHP where account passwords are stored as the first 128 chars of a whirlpool hash of the password. I'd like to transition to handling the logins with Django without changing the database or asking users to change their passwords. Also, I'd prefer to stick with whirlpool vs. the less secure hashes Django has b...

Efficiently reading a csv file with windows newline on linux in Python

The following is working under windows for reading csv files line by line. f = open(filename, 'r') for line in f: Though when copying the csv file to a linux server, it fails. It should be mentioned that performance is an issue as the csv files are huge. I am therefore concerned about the string copying when using things like strip....

What is the best way to parse C++ class architecture in Python?

I want to parse c++ sources in Python. Namely, information about the structure of the classes. I need to construct some object in Python that should contain information about c++ class. Something like this: [namespace] function name [: parent] [constructor([parameters])] [destructor([parameters])] public methods([parameters]) private...

Python Daemon To Watch A Folder And Update A Database.

This is specifically geared towards managing mp3s but should easily work for any directory structure with a lot of files. I want to find or write a daemon (preferably in Python) that will watch a folder with many subfolders that should all contain X number of mp3s. Any time a file is added, updated or delete it should reflect that in a...

How do I find missing dates in a list of sorted dates?

In Python how do I find all the missing days in a sorted list of dates? ...

How to generate a module object from a code object in Python

Given that I have the code object for a module, how do I get the corresponding module object? It looks like moduleNames = {}; exec code in moduleNames does something very close to what I want. It returns the globals declared in the module into a dictionary. But if I want the actual module object, how do I get it? EDIT: It looks like y...