python

Error Installing Gitosis on Fedora Core

I'm trying to follow these instructions on installing gitosis: http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way and these: http:// www.webtop.com.au/installing-git-and-gitosis-on-fedora-10 And at the point where I need to clone the gitosis-admin.git repository from the server I'm setting up, I am receivi...

SVN serve and PySVN Error message: Expected FS format between '1' and '3'; found format '4'

For research purposes, I copied a SVN repo to my Windows machine using svnsync so I can replay on my machine without loading the actual server. I've been using PySVN in scripts to control the revision number I want the repo to be in and have been using it fine so far. Now I got a repo from a different project and svnsync got it fine. Wh...

Wrap C++ lib with Cython

I'm new to Cython and I'm tring to use Cython to wrap a C/C++ static library. I made a simply example as following. Test.h: #ifndef TEST_H #define TEST_H int add(int a, int b); int multipy(int a, int b); #endif Test.cpp #include "test.h" int add(int a, int b) { return a+b; } int multipy(int a, int b) { return a*b; } ...

Graceful exiting of a program in Python?

Hey all, I have a script that runs as a while True: doStuff() What is the best way to communicate with this script if I need to stop it but I don't want to kill it if it is in the middle of an operation? Thanks! ...

iterable long-object?

Hello! This is a problem from euler-project. No.13 import math #no.13 sum = [] number = 0 a = 3710728753390210279879799822083759024651013574025046376937677490009712648124896970078050417018260538743249861995247410594742333095130581237266173096299194221336357416157252243056330181107240615490825023067588207539346171171980310421047513778...

name 'times' is used prior to global declaration - But IT IS declared!

I'm coding a small program to time and show, in a ordered fashion, my Rubik's cube solvings. But Python (3) keeps bothering me about times being used prior to global declaration. But what's strange is that IT IS declared, right on the beggining, as times = [] (yes, it's a list) and then again, on the function (that's where he complains) ...

WMI querying issues in Python

I've recently been working on a Squish test script, and trying to do something like what's described in the solution at: http://stackoverflow.com/questions/938733/python-total-memory-used/938800#938800 The relevant snippets from my code are as follows: def measureMemory(): w = wmi.WMI('.') result = w.query("SELECT WorkingSet FR...

Google App Engine -- Java or Python?

I noticed that this was asked in the following post. Has anyone used both and can conclusively tell me which is better? It seems like python might be a little easier to implement and faster? ...

App Engine urlfetch is raising exceptions when i think it should not be

I've written my first Python application with the App Engine APIs, it is intended to monitor a list of servers and notify me when one of them goes down, by sending a message to my iPhone using Prowl, or sending me an email, or both. Problem is, a few times a week it notifies me a server is down even when it clearly isn't. I've tested it...

Search_fields in django python

I was wondering how I am able to use a foreign key to preform a search for example class Product(models.Model): name = models.CharField(max_length = 127) description = models.TextField() code = models.CharField(max_length = 127) def __unicode__(self): return self.name + " - " + self.code class ProductLot(models...

PyQt post installation question

I successfully installed PyQt in both mac and PC. To do so I had to install mingw (on PC), Xcode (on MAC) and Qt4.6 library. Now that I have PyQt working perfectly, I would like to uninstall mingw, Xcode and Qt Library from both mac and PC. I know I can remove Xcode and mingw, but what care should I take before removing Qt library. I k...

Escape SQL "LIKE" value for Postgres with psycopg2

Does psycopg2 have a function for escaping the value of a LIKE operand for Postgres? For example I may want to match strings that start with the string "20% of all", so I want to write something like this: sql = '... WHERE ... LIKE %(myvalue)s' cursor.fetchall(sql, { 'myvalue': escape_sql_like('20% of all') + '%' } Is there an existi...

Can you separate python projects logically into separate files/classes like in C#/Java?

I'm looking to develop a project in python and all of the python I have done is minor scripting with no regard to classes or structure. I haven't seen much about this, so is this how larger python projects are done? Also, do things like "namespaces" and "projects" exist in this realm? As well as object oriented principles such as in...

Pythonic way to create a numpy array from a list of numpy arrays

Hello, I generate a list of one dimensional numpy arrays in a loop and later convert this list to a 2d numpy array. I would've preallocated a 2d numpy array if i knew the number of items ahead of time, but I don't, therefore I put everything in a list. The mock up is below: >>> list_of_arrays = map(lambda x: x*ones(2), range(5)) >>> l...

Passing C function pointers between two python modules

I'm writing an application working with plugins. There are two types of plugins: Engine and Model. Engine objects have an update() method that call the Model.velocity() method. For performance reasons these methods are allowed to be written in C. This means that sometimes they will be written in Python and sometimes written in C. The p...

pydev issue with gobject

It seems that Pydev (1.5.4) on Eclipse (3.5.1) with Python 2.6 isn't able to correctly cross-reference the package gobject. Putting import gobject works OK but any more than that (e.g. class X(gobject.GObject) causes Pydev to report "unresolved reference" errors. What could be the problem? Note that every other package I use doesn't t...

Python win32 service

Hey guys, I am fairly new to python, and have no experience with writing services for windows. I have tried to hack together a windows service based on afew tutorials i have found out there. I need this service to constantly monitor a directory for changes and when it sees a change it runs a script. Here is what i have so far: import ...

CherryPy changes my response code

In my python application using mod_wsgi and cherrypy ontop of Apache my response code get changed to a 500 from a 403. I am explicitly setting this to 403. i.e. cherrypy.response.status = 403 I do not understand where and why the response code that the client receives is 500. Does anyone have any experience with this problem> ...

Handling a Python exception that occurs within an except clause

I have some code in a Python except clause that is intended to do some logging, but the logging code might itself cause an exception. In my case, I'd like to just ignore any second exception that might occur, and raise the original exception. Here is a very simplified example: try: a = this_variable_doesnt_exist except: try: ...

Can I work around this ManyToManyField problem?

Ok, so I posted a question recently regarding an error when adding a ManyToManyField The Models are the ones below class MagicType(models.Model): name = models.CharField(max_length=155) parent = models.ForeignKey('self', null=True, blank=True) class Spell(models.Model): name = models.CharField(max_length=250, db_index=...