python

How do I delay a task using Celery ?

Not talking about the delay method. I want to be able to get a task, given it's task_id and change it's ETA on the fly, before it is executed. For now I have to cancel it, and re-schedule one. Troublesome if the scheduled process involve a lot of stuff. ...

How do I choose a task_id using celery?

For now I get a task_id from the async_result and have to save it the get it back later. Would be better if I knew what the task_id what made of so I can calculate it back instead of pulling from the DB. E.G: set a task with task_id=("%s-%s" % (user_id, datetime)). ...

Using Python class as a data container

Sometimes it makes sense to cluster related data together. I tend to do so with a dict, e.g., self.group = dict(a=1, b=2, c=3) print self.group[a] One of my colleagues prefers to create a class class groupClass(object): def __init__(a, b, c): self.a = a self.b = b self.c = c self.group = groupClass(1, 2, ...

python : read a line, then instantiate a class named in the line

Hi, I'm sorry if I wasn't clear enough in the title, don't hesitate to correct it if you find a better way to express that: I have a file where there are class names, i.e.: classa classb classb classc classc classc Then I want to read it line by line and to dynamically create that class. I would do something like that in php: while...

Django Admin "Helper" Functionality Not Working on Server

In my localhost Django administrator I am able to fill-in Date and Time fields by clicking on the little "Date" and "Time" helper icons next to my pub_date field. However, the same administrator on my Server does NOT show these icons. The server-side admin also doesn't pop open a pop-up window for the little "+" plus sign for fields in r...

Python - SqlAlchemy. How to relate tables from different modules or files?

I have this class in one file and item class in another file in the same module. If they are in different modules or files when I define a new Channel, I got an error because Item is not in the same file. How can I solve this problem? If both classes are in the same file, I don't get any error. ChannelTest.py from ItemTest import Item ...

Is it considered bad practice to use a widgets title attribute to refer to it?

Would it be considered bad practice to use a widgets title attribute to refer it? For example I have a number of custom radioBoxCtrls on a panel I only ever need to get/set all the values at once so the container class(a panel) for the radioBoxCtrls objects has the following methods get_options() set_options() To set options for...

Iterating variables to change its features in Python

I assigned values with setattr() function in a loop: for i in range(30): for j in range(6): setattr(self, "e"+str(i)+str(j), Entry(self.top)) , then I want to apply .grid() func. to all these variables with a loop. For example, self.e00.grid(row= 0, column= 0) How can I do that? ...

How to make request whith Q() object. Django!

There is code and Tracebeck. What I'm doing wrong? media=MediaObject.objects.get( Q(on_air__range=(strt_time,end_time)), Q(channel=3), Q(name__icontains="qwwwwwww".decode('utf-8')|Q(name__icontains="cccccccc dddddd".decode('utf-8'))) ) Traceback (most recent call last): File "C:\Documents and Settings\POLINOM\web\...

What is the difference between lists and tuples in Python?

Which is more efficient? What is the typical use of each? ...

How can I create a session-local cookie-aware HTTP client in Django?

I'm using a web service backend to provide authentication to Django, and the get_user method must retain a cookie provided by the web service in order to associate with a session. Right now, I make my remote calls just by calling urllib2.urlopen(myTargetService) but this doesn't pass the cookie for the current session along. I have crea...

How to fix pdb in Aquamacs on Mac OS X?

I'm developing a django app using aquamacs as my ide. Pdb isn't working since upgrading to emacs 23.2.1 using python 2.6.1. When I invoke pdb like this: M-x pdb Run pdb (like this): pdb ./manage.py runserver The gud-manage.py frame appears with this message (and nothing more) - Current directory is /path/to/my/source/ It isn't resp...

win32api vs Python

What are the Pro's and Con's of using win32api for I/O and other things instead of simply Python, if both have a specific function for it I mean, using PyWin32 vs Win32Api ...

debugging in python

i am using the python shell to try to do debugging i set a breakpoint i did: >>> import pdb >>> import mymodule >>> pdb.run('mymodule.test()') but it is just running my program without stopping at the breakpoint! what am i donig wrong? ...

python: casting to upper and finding string

i am getting stuck on this line: row[1].upper().find('CELEBREX',1) (this is returning -1) it seems to not find CELEBREX even though it is there row[1] = 'celebrex, TRAMADOL' am i casting to UPPER incorrectly? ...

teamplayer and pyhook interacting strangely

I'm using teamplayer, which lets you connect more mice to your computer to be used simultaneously. I'm also using pyHook to capture mouse events, with the following code: import pyHook import pythoncom def onclick(event): # called when mouse events are received print 'MessageName:',event.MessageName print 'Message:',event.Message...

Convert multiline string to single line string

Hi, I'm using Google App Engine and I need to put a multiline string in the datastore. Unfortunately, GAE does not allow that. I need this string to be multiline, so is there any way to convert a multiline string to a single line string and store it? ...

Using a remote stylesheet that includes other stylesheets with relative paths

I'd like to do an XSL transform on a DocBook document using lxml.etree.XSLT. Although the documentation mentions that etree.XSLT() takes a first parameter of xslt_input, I can't seem to find any docs on what this parameter is meant to be. Passing it a file that is open for reading seems to work; passing it a filename in a string does n...

A forgiving dictionary

I am wondering how to create forgiving dictionary (one that returns a default value if a KeyError is raised). In the following code example I would get a KeyError; for example a = {'one':1,'two':2} print a['three'] In order not to get one I would 1. Have to catch the exeption or use get. I would like to not to have to do that with m...

Passing an array of long strings ( >4000 bytes) to an Oracle (11gR2) stored procedure using cx_Oracle

Hello, We need to bulk load many long strings (>4000 Bytes, but <10,000 Bytes) using cx_Oracle. The data type in the table is CLOB. We will need to load >100 million of these strings. Doing this one by one would suck. Doing it in a bulk fashion, ie using cursor.arrayvar() would be ideal. However, CLOB does not support arrays. BLOB, LOB,...