python

Getting raw post data in Google App Engine Python API

Hi, I am trying to get raw data sent as post to Google App engine, using self.request.get('content'), but in vain. It returns empty. I am sure the data is being sent from the client, coz I checked with another simple server code. Any idea what I am doing wrong? I am using the following code on the client side generating the POST call (...

Django version selection

Greetings, I am currently working on a long term project that uses Django 1.1.1, and we are planning to release it around march of 2010. Now while surfing I came upon to this article which says the planned release date of Django 1.2.0 is March 9, 2010. Now I am a bit confused. If I should continue developing under 1.1.1 or start develo...

How to test a folder for new files using python

Hello How would you go about testing to see if 2 folders contain the same files, and then to be able to manipulate ONLY the file which is new. A = listdir('C:/') B = listdir('D:/') If A==B ... I know this could be used to test if directories are different but is there a better way? And if A and B are the same, except B has one more ...

What are the functions / AT commands to reconnect a disconnected GSM modem?

I hava a GSM modem that disconnect after a while, maybe because of low signal. Am just wondering is there an AT command that can detect the disconnection and re-establish a reconnection. Is there a way in code (preferably python) i can detect the disconnection and re-establish a reconnection? Gath ...

Python, IMAP and GMail. Mark messages as SEEN

I have a python script that has to fetch unseen messages, process it, and mark as seen (or read) I do this after login in: typ, data = self.server.imap_server.search(None, '(UNSEEN)') for num in data[0].split(): print "Mensage " + str(num) + " mark" self.server.imap_server.store(num, '+FLAGS', '(SEEN)') The f...

What behaviour is preferred? (Embedding Python)

I'm embedding Python into an application. MyClass.name is a property of str type: >>> foo = MyClass() >>> foo.name 'Default Name' Should I allow users to do this: >>> foo.name = 123 >>> foo.name '123' or not? >>> foo.name = 123 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: name must be a strin...

ImageField not failing at IOError exception

Hay, i have a model which saves 2 images class Picture(models.Model): picture = models.ImageField(upload_to=make_filename) thumbnail = models.ImageField(upload_to=make_thumb_filename) car = models.ForeignKey('Car') created_on = models.DateField(auto_now_add=True) updated_on = models.DateField(auto_now=True) def ...

Efficent way to bulk insert with get_or_create() in Django (SQL, Python, Django)

Is there a more efficent way for doing this? for item in item_list: e, new = Entry.objects.get_or_create( field1 = item.field1, field2 = item.field2, ) ...

Site name appearing in django URLs

I'm having an issue where a call to the url template tag in Django is appending the site name (I don't want it in there.) Let's say that the site name is 'mysite'. So for example: <a href="{% url myapp.views.myview "myparam" %}">Link text</a> is producing: <a href="/mysite/foo/bar">Link text</a> when I want it to produce: <a hre...

Class Inheritance

Hello, I am trying to get completely to grips with class inheritence in Python. I have created program's with classes but they are all in one file. I have also created scripts with multiple files containing just functions. I have started using class inheritence in scripts with multiple files and I am hitting problems. I have 2 basic sc...

py2exe twisted outcoming udp packet

Hi all, I've developed an application for Windows that use wxPython and twisted. The issue is that if I run the app using the Python interpreter everything is OK (I could receive and transmit UDP packets). If I build a py2exe app I can only receive UDP packets. I have no error, the app is responsive but tx packets are not transmitted ...

How to create PDF files in Python

Hi, I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images. Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file? ...

How to run command line python script in django view?

I have a .py file that a php file runs like this: $link = exec(dirname(__FILE__) . /xxx.py ' .excapeshellarg($url) . '2>&1', $output, $exit_code); I want to run the xxx.py in my django view and asign the output to a variable. The xxx.py file has a def main(url) function and if __name__ == '__main__': at the bottom. Is there a way I c...

How to create graphs in Delphi application

I need to create graphs on the fly about specific process, with some informative texts and colors. In the Unix world there's Graphviz including 'dot' for layout generation, is there something similar which could be used with Delphi? I'm using Delphi 2007. Also Python alternative could be considered, but I'd prefer pure Delphi in this ...

In python, what is more efficient? Modifying lists or strings?

Regardless of ease of use, which is more computationally efficient? Constantly slicing lists and appending to them? Or taking substrings and doing the same? As an example, let's say I have two binary strings "11011" and "01001". If I represent these as lists, I'll be choosing a random "slice" point. Let's say I get 3. I'll Take the...

Passing param to DB .execute for WHERE IN... INT list

With Python's DB API spec you can pass an argument of parameters to the execute() method. Part of my statement is a WHERE IN clause and I've been using a tuple to populate the IN. For example: params = ((3, 2, 1), ) stmt = "SELECT * FROM table WHERE id IN %s" db.execute(stmt, params) But when I run into a situation where the parameter...

Sharing scripts that require a virtualenv to be activated

I have virtualenv and virtualenvwrapper installed on a shared Linux server with default settings (virtualenvs are in ~/.virtualenvs). I have several Python scripts that can only be run when the correct virtualenv is activated. Now I want to share those scripts with other users on the server, but without requiring them to know anything ...

cron job and Long process problem

Via django iam launching a thread (via middle ware the moment the first request comes) which continously fetches the twitter public steam and puts it down into the database.Assume the thread name is twitterthread. I also have have several cron jobs which periodically interacts with other third party api services. Observed the following...

Python strange exception. Have I found my first Python bug or is this a noob mistake?

Let me start by saying, I also get the same error whey defining __init__ and running super()'s __init__. I only simplified it down to this custom method to see if the error still happened. import HTMLParser class Spider(HTMLParser): def spamfoo(self): print('some random non-overriding method') This alone in a module rais...

Python: ball isn't defined

I get this error: Traceback (most recent call last): File "D:/Python26/PYTHON-PROGRAMME/049 bam", line 9, in <module> ball[i][j]=sphere() NameError: name 'ball' is not defined when I run this code. But the ball is defined ( ball[i][j]=sphere() ). Isn`t it? #2D-wave #VPython from visual import * #ball array #ready for i in ran...