python

Google App Engine - Tracking which indexes are used

I have a App Engine/Python/Django application which has grown and been modified over the past year and currently has 175 indexes. The problem is that I have not been thourough in cleaning up/removing indexes that are no longer needed. Now, I am not sure which indexes are active and which are essentially dead, but I am guessing that abou...

Django + IIS + ?

I need to run a django app on windows under either IIS6 or IIS7 (yes, I don't know the exact requirements right now). What I did: I've tried to set up a working environment on my windows 7 (so its IIS7 for now) machine. I've followed the instructions at django trac using PyISAPIe. What came out of it: Apparently, either I am doing some...

How do you get the last arrow key pressed using curses?

I'm writing a Python snake game using curses, but am having some trouble controlling the snake, my current code for controlling the snake is placed inside the main loop and looks like this: while True: char = screen.getch() if char == 113: exit() # q elif char == curses.KEY_RIGHT: snake.update(RIGHT) elif char == curses...

How can I call a particular base class method in Python?

Let's say, I have the following two classes: class A(object): def __init__(self, i): self.i = i class B(object): def __init__(self, j): self.j = j class C(A, B): def __init__(self): super(C, self).__init__(self, 4) c = C() c will only have the i attribute set, not the j. What should I write to set ...

python failed to call flash loaded html page

I tried to render html page which contains flash content. But it not responding. Loads endless. Text and image contents are OK. Here is my code. self.response.out.write(template.render('ieerror.html', dict())) html file contains: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>flash content</title>...

ping a server thru a specific port (fsockopen) in php

function checkServer($domain, $port=80) { global $checkTimeout, $testServer; $status = 0; $starttime = microtime(true); $file = @fsockopen ($domain, $port, $errno, $errstr, $checkTimeout); $stoptime = microtime(true); if($file) { fclose($file); $status = ($stoptime - $starttime) * 1000; $status = floor($status); } else...

Write a script to do content filtering with postfix

How can i write in python or ruby a script to do content filtering in postfix via smtp or uucp (not pipe)? There is some examples? ...

What's wrong with this gzip format?

I use the following python code to download web pages from servers with gzip compression: url = "http://www.v-gn.de/wbb/" import urllib2 request = urllib2.Request(url) request.add_header('Accept-encoding', 'gzip') response = urllib2.urlopen(request) content = response.read() response.close() import gzip from StringIO import StringIO ht...

Adding custom action to UserModel's Admin page

Is there any possibility to create custom action in admin page for django UserModel? I want automatize adding user to group (like adding him to staff, set some extra values, etc.), and of course create actions that take these changes back. Thanks for your help. ...

Calling Java from Python

What is the best way to call java from python? (jython and RPC are not an option for me). I've heard of JCC: http://pypi.python.org/pypi/JCC/1.9 a C++ code generator for calling Java from C++/Python But this requires compiling every possible call; I would prefer another solution. I've hear about JPype: http://jpype.sourceforge.net/ tu...

Simple Django form / model save question

I want to set the BooleanField inuse to True when I save the ModelForm (I'm using a form outside of the admin area) and I'm unsure how to do it. Models: class Location(models.Model): place = models.CharField(max_length=100) inuse = models.BooleanField() class Booking(models.Model): name = models.CharField(max_length=100, v...

Installing SetupTools on 64-bit Windows

I'm running Python 2.7 on Windows 7 64-bit, and when I run the installer for setuptools it tells me that Python 2.7 is not installed. The specific error message is: `Python Version 2.7 required which was not found in the registry` My installed version of Python is: `Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (A...

Open Source Queue that works with Java, PHP and Python

I'm currently in the market for a new queue system for jobs we have in our system. I've tried beanstalk but it's been unable to keep up with the load. I'm looking for a simple system to get up and running that I can put pieces of data in from producers and have consumers in Java, PHP and Python pull data off and process it. Ideally I'd...

How do I print a list of strings, when I can't know the char encoding in advance?

I am retrieving a list of names from a webservice using a client I've written in Python. Upon retrieving the list, I encode each name to unicode and then print each of them to stdout. When I get to the name "Ólafur Jóhann Ólafsson", I get the following error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ...

Learning Java from Python

I currently am pretty sufficient in python, but I need to learn Java. Are there any books that would be specifically tailored to someone like me? Also, do you have any tips, or just any great Java books in general? ...

What is the best way to do automatic attribute assignment in Python, and is it a good idea?

Instead of writing code like this every time I define a class: class Foo(object): def __init__(self, a, b, c, d, e, f, g): self.a = a self.b = b self.c = c self.d = d self.e = e self.f = f self.g = g I could use this recipe for automatic attribute assignment. class Foo(obj...

difficulty in installing SciPy and Numpy in Ubuntu(9.04)?

HI folks. I have difficulty in installing these items in Ubuntu.......plz help me as soon as possible.iam experiencing errors such as no module name found......sometimes certain libraries are not found.......plz folks can all of u state the basic libraries required for installing these items and where to find them ...

How to Set Call Back For Enter key of GtkTextView?

how can I set call back on enter key of GtkTextView Widget and set TextView to work like gtk.entry (single-line)? ...

What's the difference between "browser posting" and "program posting"?

I've asked one question about this a month ago, it's here: http://stackoverflow.com/questions/3362399/post-method-to-communicate-directly-with-a-server. And I still didn't get the reason why sometimes I get 404 error and sometimes everything works fine, I mean I've tried those codes with several different wordpress blogs. Using firefox...

Subdomains vs folders/directories

Hi all, I'm currently building a web application and I would like my users to have their own URLs to identify them. I could either do this using subdomains or using folders and am wondering what are the advantages and disadvantages of either one. I really like the folder solution because my URL mapping would be fairly easy. I have read...