python

Django Templates Variable Resolution

Hey there, it's been a week with Django back here so don't mind me if the question is stupid, though I searched over stackoverflow and google with no luck. I've got a simple model called Term (trying to implement tags and categories for my news module) and I have a template tag called taxonomy_list which should output all the terms assi...

How to get UID of mail in All Maill folder if I have UID of this mail in inbox using imaplib? (GMail)

How to get UID of mail in All Maill folder if I have UID of this mail in inbox using imaplib? As you know the google store mails in the two instances in All Mail and in inbox I whant to move this to mail in trash folder using imaplib ...

unable to convert pdf to text using python script

i want to convert all my .pdf files from a specific directory to .txt format using the command pdftotext... but i wanna do this using a python script... my script contains: import glob import os fullPath = os.path.abspath("/home/eth1/Downloads") for fileName in glob.glob(os.path.join(fullPath,'*.pdf')): fullFileName = os.path.join...

How create an Executable file + Launcher in Ubuntu from a python script ?

I have created a simple program in python. Now I want trasform this script in an executable program ( with hidden source code if possible ) and when I click 2 times on it, the program install itself on the ubuntu ( in the /usr/lib or /usr/bin I think ) and it will create a new launcher in the Application -> Game menu. How can I do that ...

Uploading images from a django application to a Google AppEngine application

I am not running Django on AppEngine. I just want to use AppEngine as a content delivery network, basically a place I can host and serve images for free. It's for a personal side project. The situation is this: I have the URL of an image hosted on another server/provider. Instead of hotlinking to that image its better to save it on AppE...

Help with zc.buildout script to install Satchmo

Im trying to re-create a this satchmo environment using a buildout script: [buildout] parts = django satchmo eggs = pycrypto PIL pyyaml trml2pdf sorl-thumbnail django-registration django-caching-app-plugins django-threaded-multihost django-signals-ahoy django-keyedcache django-livesettings django satchmo Sphinx docutils extensions = ...

What are important languages to learn to understand different approaches and concepts?

When all you have is a pair of bolt cutters and a bottle of vodka, everything looks like the lock on the door of Wolf Blitzer's boathouse. (Replace that with a hammer and a nail if you don't read xkcd) I currently program Clojure, Python, Java and PHP, so I am familiar with the C and LISP syntax as well as the whitespace thing. I know i...

How to migrate a CSV file to Sqlite3 (or MySQL)? - Python

Hi folks, I'm using Python in order to save the data row by row... but this is extremely slow! The CSV contains 70million lines, and with my script I can just store 1thousand a second. This is what my script looks like reader = csv.reader(open('test_results.csv', 'r')) for row in reader: TestResult(type=row[0], name=row[1], res...

easiest way to make a live 3d scene, a bit like a simple game (for simulator visualisation purposes)

I am building a ship simulator that will produce accurate position and orientation values for a prototype hull design in some defined sea-state. In terms of programming, I have 2 arrays (vectors) in MATLAB containing the position and acceleration values for x, y, z, yaw, pitch and roll. Because the visualisations in MATLAB are a bit cru...

Non biased return a list of n random positive numbers (>=0) so that their sum == total_sum

I'm either looking for an algorithm or a suggestion to improve my code to generate a list of random numbers that their sum equals some arbitrary number. With my code below, it'll always be biased as the first numbers will tend to be higher. Is there a way to have the number selection more efficient? #!/usr/bin/python ''' Generate a...

determing file object size before using file object

I am attempting to determine the size of a downloaded file in python before parsing and manipulating it with BeautifulSoup. (I intend to update to ElementTree soon, but having briefly played with it, it does not solve the problem I am posing here, as far as I can see). import urllib2, BeautifulSoup query = 'http://myexample.file.com/fil...

Unpack BinaryString sent from JavaScript FileReader API to Python

I'm trying to unpack a binary string sent via Javascript's FileReader readAsBinaryString method in my python app. It seems I could use the struct module for this. I'm unsure what to provide as as the format for the unpack exactly. Can someone confirm this is the right approach, and if so, what format I should specify? According to th...

add a callback from a growl event with python

I'd like to register events from growl notifications from spotify with python. Perhaps someone could point me in the right direction? ...

How to programmatically exit pdb started in eval() or exec without showing output

In my python code I have this line: try: result = eval(command, self.globals, self.locals) except SyntaxError: exec(command, self.globals, self.locals) The command variable can be any string. Hence the python debugger pdb may be started in eval/exec and still be active when eval/exec is returning. What I want to do is make sur...

Python: getting an object's “attribute/method/property” either as a parameter to a method or as a property.

In the WMI module (yeah, my boss wants me to program in Windows — but at least it’s not in COBOL), it seems that you can access a WMI value either by passing it’s name as a string parameter of a method, blabla=wmithingy().getvalue('nameOfValue') or as a property/method: blabla=wmithingy().nameOfValue() Am I dreaming, smoking bad w...

How can I make Python/Sphinx document object attributes only declared in __init__?

I have Python classes with object attributes which are only declared as part of running the constructor, like so: class Foo(object): def __init__(self, base): self.basepath = base temp = [] for run in os.listdir(self.basepath): if self.foo(run): temp.append(run) self.avail...

Multiple communication channels with Twisted Python

I am currently researching the Twisted framework as a way of implementing a network-based backup application, and I would like to achieve something that I cannot find any examples of on the net. I plan to implement the system using the Perspective Broker, but I will also need a way of transferring binary files from the client to the ser...

Basic Python file searching and I/O

Hello, I'm trying to complete a simple task in Python and I'm new to the language (I'm C++). I hope someone might be able to point me in the right direction. Problem: I have an XML file (12mb) full of data and within the file there are start tags 'xmltag' and end tags '/xmltag' that represent the start and end of the data sections I w...

Uploading an Image via readAsBinaryString() in JavaScript

Is there some offset I should be accounting for when I upload an image in this manner? If i simple send the file, I can write it back out as a valid JPG but if I write the data submitted via readAsBinaryString, the file is approximately 50% larger and corrupt. Any thoughts? here's the javascript: var file = e.dataTransfer.files[0]; ...

How do I re-route network traffic using Python?

Small apps like Freedom and Anti-social have created quite a stir lately. They cut you off from the internet either entirely or just block social networking sites in order to discourage procrastination and help you exert self control when you really want to get some work done. I looked at the available options and also at some Google Ch...