python

making more rows in a row of treeview!

I wanna make sth like this in transmission: [link text]here1 (also in pidgin too, Status under IDs) can anyone show me a sample code here? ...

Interactive Stacked Bar Chart using MatplotLib python

Dear All, I need to create a stacked bar chart using matplotlib. Each bar should be a stack of the parameters I am measuring. However, I want it to be interactive or dynamic so as when I click on one of the parameters (A,B,C) for example in the legend, it should make that parameter at the bottom of the stack so as we could have a better...

How to deploy a python webapp with dependencies using virtualenv ?

Hi, I'm looking for a way to automate deployment of web applications written in Python to a server. I would like to use virtualenv to have a clean environment for this application. However, I am wondering how to manage dependencies when deploying to the server ? In development, I have a virtualenv in which I install external libraries...

Python, Webbrowser and Gmail

Hey friends. I want to open Gmail but with a particular account. My python script has a list of gmail accounts and i want the one to open in gmail which has been clicked/selected. I tried using the credentials in the URL but am not happy with that as I don't want to put the users password in the URL + it doesn't work :). I'm using webbr...

No module named django.core

Hi, I'm following the step by step guide here and I hit an error at the "Create Django Project" step when I try the command; django-admin.py startproject myproject The error: Traceback (most recent call last): File "/usr/local/bin/django-admin.py", line 2, in from django.core import management ImportError: No module ...

Two processes reading/writing to the same file Python

I have one process who's reading from a file (using file.read()) and one process who's writing to the same file (file.write()). The problem is it doesn't work - I get no errors but they can't operate at the same time. I've tried making the read and write operations none-blocking and then flushing the stream, as follows: fcntl.fcntl(file...

How should I share and store data in a small multithreaded python application?

Hi all, I'm writing a small multithreaded client-side python application that contains a small webserver (only serves page to the localhost) and a daemon. The webserver loads and puts data into a persistent "datastore", and the daemon processes this data, modifies it and adds some more. It should also takes care of the synchronization w...

Can iterator be restored and can its value/status be assigned?

Hi All, I have below snippet which use the generator to give the new ID ... def __init__(self, id_generator = None): if id_generator is None: id_generator = 0 if isinstance(id_generator, int): import itertools self._generator = itertools.count(id_generator) else: self....

Python file.read() grabs more data than necessary, under the hood.

cat file_ro.py import sys def file_open(filename): fo=open(filename,'r') fo.seek(7) read_data=fo.read(3) fo.close() print read_data file_open("file.py") But strace says readlink("file_ro.py", 0x7fff31fc7ea0, 4096) = -1 EINVAL (Invalid argument) getcwd("/home/laks/python", 4096) = 18 lsta...

append a particular column from a csv file to another using python

hi, I'll explain my whole problem: I have 2 csv files: project-table.csv (has about 50 columns) interaction-matrix.csv (has about 45 columns) I want to append the string in col[43] from project-table.csv with string in col[1] of interaction-matrix.csv with a dot(.) in between both the strings next, interaction-matrix.csv has...

python.exe is getting crashed at time of frame close

I am making an application using wxpython in which i have imported some modules and added the some widgets but when i am closing the application window ie Frame(wxFrame) python.exe getting crashed and showing the following message "python.exe get encountered a problem and need to be close... Tell microsoft donttell smt smt". My app is ...

wx.CreateStatusBar() without the resize handle

I am creating a wx.Frame that cannot be resized. How do I disable the size grip at the right side of a status bar? Quoting http://docs.wxwidgets.org/2.6/wx_wxstatusbar.html#wxstatusbar : Window styles wxST_SIZEGRIP -- On Windows 95, displays a gripper at right-hand side of the status bar. Translating to wxPython, it should read ...

How do I debug code that segfaults unless run through gdb?

That's a single threaded code. In particular: ahocorasick Python extension module (easy_install ahocorasick). I isolated the problem to a trivial example: import ahocorasick t = ahocorasick.KeywordTree() t.add("a") When I run it in gdb, all is fine, same happens when I enter these instructions into Python CLI. However, when I try to...

Pydev relative path

Hello, I installed eclipse with pydev plugin. I need to run my existing project on eclipse. But there are relative paths to the files inside my code. I expect from eclipse to append relative paths to the project's default directory. Instead, it appends the relative path to the directory where Eclipse is installed. I could not find a way...

RestrictedPython on Google AppEngine (GAE)

I'm looking for a way to execute user submitted python code in GAE in a secure fashion (much stricter then the GAE sandbox). RestrictedPython would certainly fit the shoe, being used in Zope for the exakt same purpose. But RestrictedPython relies on modifying the AST (abstract syntax tree) which means loading modules from the compiler ...

How to guarantee two related models get saved?

How do I guarantee data only gets saved when the related objects are both filled with data? class A(models.Model): title = models.CharField(max_length=255) slug = models.SlugField() class B(A): author = models.CharField(max_length=255) url = models.URLField() I insert data by accessing model B: b = B() b.title = 'ti...

sparse file usage in python

I'm creating sparse files in python as follows: >>> f = open('testfile', 'ab') >>> f.truncate(1024000) >>> f.close() when the file is done, it takes up 0 disk space, but its inode size is set to my truncated value (1000K): igor47@piglet:~/test$ ls -lh testfile -rw-r--r-- 1 igor47 igor47 1000K 2010-07-09 04:02 testfile igor47@piglet:...

why does my pygtk application crash when copying text on a clipboard?

Hi all, I'm writing a python application using pygtk. I have a main thread who occasionally calls another thread that is supposed to build a string and then copy it on the clipboard before dying. My "slave" thread looks pretty much like this: class Slave(threading.Thread): def run(self): s = build_string() c = gtk.Cl...

Continue loading after IntegrityError

In python, I am populating a SQLITE data base using the importmany, so I can import tens of thousands of rows of data at once. My data is contained as a list of tuples. I had my database set up with the primary keys where I wanted them. Problem I ran into was primary key errors would throw up an IntegrityError. If I handle the except...

conditionally including queries in an advanced query in zope

I'm building a quite thorough searching mechanism for a zope site. There are lots of different ways of searching, and because it might want to search for multiple values on the same index (and match all of them) I need to do it using AdvanceQuery. I've built my queries like this: if self.text(): text_query = And() for t in self....