python

Python and Postgresql

Hi all, if you wanted to manipulate the data in a table in a postgresql database using some python (maybe running a little analysis on the result set using scipy) and then wanted to export that data back into another table in the same database, how would you go about the implementation? Is the only/best way to do this to simply run the...

Problem with anchor tags in Django after using lighttpd + fastcgi

I just started using lighttpd and fastcgi for my django site, but I've noticed my anchor links are no longer working. I used the anchor links for sorting links on the page, for example I use an anchor to sort links by the number of points (or votes) they have received. For example: the code in the html template: ... {% load sorting...

httplib2 giving internal server error 500 with proxy

Following is the code and error it throws. It works fine without the proxy http = httplib2.Http() . When I try the same http proxy in Firefox, it works fine. Any pointers are highly appreciated! Usage : http = httplib2.Http(proxy_info = httplib2.ProxyInfo(socks.PROXY_TYPE_HTTP, '68.48.25.158', 25681)) main_url = 'http://www.mywebs...

SVN hook script conflict

I am trying to write a pre-commit hook script that will alter a specific svn-property of a folder/file. The script looks fairly similar to the one that is documented in the svn book. I figured out how to set/change the property of a node and when executing the binding function svn.fs.commit_txn the property of the node actually gets set...

emacs: pass arguments to inferior python shell during buffer evaluation

Hi there, recently I started using Emacs as a Python IDE, and it not quite intuitive... The problem I am struggling with right now is how to pass command line arguments to the inferior python shell when the buffer is evaluated with C-c C-c. Thanks for help. ...

[Python]Xml add a node from another xml document

Hi, I have two xml file: 1)model.xml 2)projectionParametersTemplate.xml I want to extract from 1) Algorithm Node with his child and put it in 2) I have wrote this code but it doesn't function. from xml.dom.minidom import Document from xml.dom import minidom xmlmodel=minidom.parse("/home/michele/Scrivania/d/model.xml") xmltempla...

Better error reporting mako

Is there a way to add tempate string which contains error to mako`s error trace? ...

Creating Threads in python

Hello, I have a script and I want one function to run at the same time as the other. Example code I have looked at: import threading def MyThread ( threading.thread ): doing something........ def MyThread2 ( threading.thread ): doing something........ MyThread().start() MyThread2().start() I am having trouble getting this ...

Gmail mail server

Hello, I used use Google’s slick interface to get my mail and It’s always going to be here: https://mail.google.com/a/yourdomainhere.com I want to write python script that send mail so i failed to configure server settings smtp = smtplib.SMTP('mail server should be what?', what is the port) smtp.login('[email protected]', '...

Adding anchors to h2 in text using python and regexp

I'm trying to add anchors to all h2's in my html, using python. This code will add those anchors, but I need to fill the name of the anchors too. Any idea if the name can be the number of the match in the loop or a slugified version of the text between the h2 tags? Here's the code so far: regex = '(?P<name><h2>.*?</h2>)' text = re.su...

jEdit+JythonInterpreter: how to import java class?

Hi, I'm running jEdit with the JythonInterprete and I have a .jar file called JavaTest.jar. JavaTest has a class called SampleJavaClass which has a method printerCount. From my .py file, I want to do: from javatest import SampleJavaClass class SampleClass(SampleJavaClass): def pymain(self): SampleJavaClass.printerCount(4) Java...

How to convert list into a string?

I have extracted some data from the file and want to write it in the file 2 but the program says 'sequence item 1: expected string, list found', I want to know how I can convert buffer[] i.e. string into sequence, so that it could be saved in file 2. file = open('/ddfs/user/data/k/ktrip_01/hmm.txt','r') file2 = open('/ddfs/user/data/k/...

Is it possible to make an accordion style check list in wxPython?

I want to make a checklist with a accordion style in a wxPython widget. I know about checklistbox, but I couldn't find anything in the official docs concerning it. Has anyone done this? ...

What is the difference between "a is b" and "id(a) == id(b)" in Python?

The id() inbuilt function gives... an integer (or long integer) which is guaranteed to be unique and constant for this object during its lifetime. The is operator, instead, gives... object identity So why is it possible to have two objects that have the same id but return False to an is check? Here is an example: >>> class ...

Why is Django testrunner not finding the tests I created?

I had been trying to add tests to a project I'm working on. The tests are in forum/tests/ When I run manage.py test it doesn't find any of the tests I created, on the tests in Django 1.2 I started with all my tests in their own package but have simplified down to just being in my tests.py file. The current tests.py looks like: ...

pycurl: how to reset a cookie session

Hello, everybody I'm using the following piece of code to get the content of a webpage from python script: #!/usr/bin/env python import pycurl import StringIO c = pycurl.Curl() c.setopt(pycurl.URL, "http://google.com") b = StringIO.StringIO() c.setopt( c.WRITEFUNCTION, b.write) #c.setopt(pycurl.COOKIESESSION, True); c.setopt(pycurl.CO...

Looking for: nosql (redis/mongodb) based event logging for Django

I'm looking for a flexible event logging platform to store both pre-defined (username, ip address) and non-pre-defined (can be generated as needed by any piece of code) events for Django. I'm currently doing some of this with log files, but it ends up requiring various analysis scripts and ends up in a DB anyway, so I'm considering throw...

Correct way to do timer function in Python

Hi. I have a GUI application that needs to do something simple in the background (update a wx python progress bar, but that doesn't really matter). I see that there is a threading.timer class.. but there seems to be no way to make it repeat. So if I use the timer, I end up having to make a new thread on every single execution... like : ...

wxPython formatting questions

I have an app I was working on to learn more about wxPython( I have been primarily been a scripter ). I forgot about it now I am opening it back up. It's a screen scraper, and I have it working almost the way I want it, going to build a regex parser to strip out the links in every scrape that I don't need. The questions I have are this. ...

way to fix number of concurrent sessions allowed at app level. django

Hi, How can I fix number of concurrent sessions allowed at app level? Basically I want a limit to how many concurrent requests to this url to keep the server from getting congested. I guess some middleware hack? Thanks. ...