python

Amazon S3cmd crashes on some large uploads

I routinely upload large bzipped sql files to S3 and have been noticing it crashing lately with this error. What might be causing this? Its always the same files that crash, but I am able to upload larger ones without a problem so it doesnt seem to be a size limit. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! An unexpected error has oc...

SQLAlchemy override types.DateTime on raw sql expressions

is it possible to override the default type.DateTime behaviour when using sqlalchemy with raw sql expressions? for example when using myconnection.execute(text("select * from mytable where mydate > :mydate), {'mydate': mypythondatetimeobject)} , i would like to have type.DateTime to automatically strip the TimeZone from the DateTime ...

python twitter oauth example?

I'm having problems to find a simple python twitter oauth example wich show how to post a user status on Twitter. Can you help me? ...

how do I get variables from one wx notebook page to a different wx notebook page?

I am wondering how one would get a variable from one page to another from a wx notebook. I am thinking there should be some way to reference a variable if I know the variable name and page id. For example if I had the following code, how would I reference variable x from panel y and vice versa import wx class PanelX(wx.Panel): def...

I Need a little help with Python, Tkinter and threading

I have a Python script which uses Tkinter for the GUI. My little script should create a Toplevel widget every X seconds. When I run my code, the first Toplevel widget is created successfully, but when it tries to create a second one the program crashes. What I am doing is using the after method to call the function startCounting every ...

geodjango syncdb errors. From geodjango tutorial.

I have followed the geodjango installation(windows XP) and tutorial to perfection I am running django 1.2 When I get to syncdb and run I receive the following. raise ImproperlyConfigured(error_msg) django.core.exceptions.ImproperlyConfigured:'django.db.backends.postgis' isn an available database backend. Try using django.db.backend...

Calling python script from excel/vba

Hello guys, I have a python code that reads 3 arguments (scalars) and a text files and then returns me a vector of double. I want to write a macro in vba to call this python code and write the results in one of the same excel sheet. I wanted to know what was the easiest way to do it, here are some stuffs that I found: - call the shell() ...

Problem with Django/Dajaxice and international characters

Hi, I am having a problem using Djajaxice with international characters... I have a django template...in that template is the following select: <select name="region" id="id" onchange="Dajaxice.crc.regions('my_callback',{'data':this.value});"> <option value="" selected="selected" ></option> {% for region in regions ...

Python unix timestamp conversion and timezone

Hey all! Ive got timezone troubles. I have a time stamp of 2010-07-26 23:35:03 What I really want to do is subtract 15 minutes from that time. My method was going to be a simple conversion to unix time, subtract the seconds and convert back. Simple right? My problem is that python adjusts the returned unix time using my local timezo...

Which is the closest Python equivalent to Perl::Tidy?

Coming from Perl I've been used to hitting C-c t to reformat my code according to pre-defined Perl::Tidy rules. Now, with Python I'm astonished to learn that there is nothing that even remotely resembles the power of Perl::Tidy. PythonTidy 1.20 looks almost appropriate, but barfed at first mis-aligned line ("unexpected indent"). In part...

How to use named parameters in Python methods that are defaulting to a class level value?

Usage scenario: # case #1 - for classes a = MyClass() # default logger is None a = MyClass(logger="a") # set the default logger to be "a" a.test(logger="b") # this means that logger will be "b" only inside this method a.test(logger=None) # this means that logger will be None but only inside this method a.test() # here logger should defa...

how to replicate parts of code in python into C to execution faster??

i have prepared a project in python language ie a TEXT TO SPEECH synthesizer. Which took a total on 1500 lines of code. But there few parts of code due to which it is taking so much time to run the code, i want to replace that parts of code in C/c++ lang so that it runs faster. So i want to know how can i run these parts of code in C++ ...

Displaying QComboBox text rather than index value in QStyledItemDelegate

So I have a model and one of the columns contains a country. However because I want to display a combo box to choose the country from a list of options, I don't store the country name in the model directly. Instead I store an index value into a list of allowable countries. This allows me to use a QComboBox in my form view as recommended ...

programmatically converting kml to image

Are there any open source libraries (preferably python) that will convert a kml file to an image file? I have an open source web-based application that allows users to draw shapes on a Google Earth Map, and I would like to provide them with a pdf that contains their map with the shapes that they have drawn. Right now the users are ...

How do you directly write to a request body in Python

I am currently implementing code to call out to an API where the post request body needs to contain several columns of data in csv format. e.g. Col1, Col2, Col3 1, 2, 3 4, 5, 6 etc, with the content type header is set to 'text/csv' How do I directly write to the request body? I have a coworker who is doing the same thing as I am...

Querying for not None

I have a model with a reference property, eg: class Data(db.Model): x = db.IntegerProperty() class Details(db.Model): data = db.ReferenceProperty(reference_class = Data) The data reference can be None. I want to fetch all Details entities which have valid data, ie for which the reference property is not None. The following ...

is there a way to use im.putpixel rather than im.paste

srcImage.paste(letters['H'], (10,15)) The above code will paste the letter H on the image (srcimage). letters is dict which contains the font images.. I cannot use paste in my assignment but i can use getpixel, load, putpixel, and save. I tried this but this is giving error: srcImage.putpixel((10,15),letters['H']) Error is: File "C:\...

How to read lines from a file in python starting from the end.

hello, I need to know how to read lines from a file in python so that I read the last line first and continue in that fashion until the cursor reach's the beginning of the file. Any idea's? ...

Get read-only objects with session object

Hello, I have a complex database where user object is related almost to every table in some way. In a previous post, I asked how to get read-only objects. I found out I could use the option "joinedload" when I query database. It's working fine, but I have another problem. These are my tables: class User(rdb.Model): """Set up user...

How to I determine the default value for a given function parameter at runtime?

Using python 2.4, I'm attempting to identify, at runtime, which of an arbitrary function's arguments have default values. Unfortunately, although I can find what the default values are, I can't seem to get a handle on which parameters they correspond to. For example: def foo(a, b, c=5): return a + b + c import inspect inspect.getar...