python

Running a python script in background from a CGI

I have a python CGI which runs some script in the background and shows the stdout in the html page. I run the script when the user clicks some button in the page. My problem is when the script starts running the page becomes busy and the user can't use the other client side features in the page. What I want is: The script should run in...

How do I create self-relationships in polymorphic inheritance in Elixir and Pylons?

I am new to programming and am following the example in the Pylons documentation on creating a Wiki. The database I want to link to the wiki was created with Elixir so I rewrote the Wiki database schema and have continued from there. In the wiki there is a requirement for a Navigation table which is inherited by Pages and Sections. A s...

Logical python question - handling directories and files in them

Hello! I'm using this function to extract files from .zip archive and store it on the server: def unzip_file_into_dir(file, dir): import sys, zipfile, os, os.path os.makedirs(dir, 0777) zfobj = zipfile.ZipFile(file) for name in zfobj.namelist(): if name.endswith('/'): os.mkdir(os.path.join(dir, name...

error :: UnicodeDecodeError

i am getting UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 104: ordinal not in range(128) i am using intgereproparty,stringproparty,datetimeproparty ...

How do I create a python module from a fortran program with f2py?

I am trying to read some smps files with python, and found a fortran implementation, so I thought I would give f2py a shot. The problem is that I have no experience with fortran. I have successfully installed gfortran and f2py on my Linux box and ran the example on thew f2py page, but I have some trouble compiling and running the large ...

Problem in understanding connectSlotsByName() in pyqt???

Hi all, I couldn't understand the connectSlotsByName() method which is predominently used by pyuic4.. As far the class is single in a PyQt file it's ok since we can use self which will be associated with a single object throughout.. But when we try to use various classes from different files the problem and the need to use connectSlotsB...

Access from web-interface to the shared object inside server daemon

I have one server daemon (written on python) interacted with several clients on other machines through TCP/IP sockets. Every client is sending some stat information to the server every sec. I try to find way show this stat information on web (using Django, for example). Now I know only 2 not simple potential ways: using DB for temp...

Python: 'break' outside loop

Hi, in the following python code: narg=len(sys.argv) print "@length arg= ", narg if narg == 1: print "@Usage: input_filename nelements nintervals" break I get: SyntaxError: 'break' outside loop Why? Thanks ...

Discovery of web services using Python

Hello, I have several devices on a network. I am trying to use a library to discover the presence and itentity of these devices using Python script, the devices all have a web service. My question is, are there any modules that would help me with this problem as the only module I have found is ws-discovery for Python? And if this is t...

cv.SaveImage in openCV

Hi, I'm trying to learn how to use opencv in python and having some difficulties, and also I'm a newbie at python too. Here is my question : I want to convert a jpg file tp png. Simple and clear. But when I run this code : from opencv import _cv from opencv.highgui import cvSaveImage, cvLoadImage cvSaveImage("bet.jpg",cvLoadImage(...

how to set wxPython main frame bottom right on screen?

For better description, +-----------------------+ | Desktop (screen) | | | | | | +----------+ | | | wxPython | | | | App. | | | | | | | | | | | +----------+ | +-----------------------+ Look at WxPython App., whi...

Is it possible to change the model name in the django admin site?

Hello, I am translating a django app and I would like to translate also the homepage of the django admin site. On this page are listed the application names and the model class names. I would like to translate the model class name but I don't find how to give a user-friendly name for a model class. Does anybody know how to do that? ...

I want to select the distict value from models field and then update them (django)

I have models... class Item(models.Model): name = models.CharField('Item Name', max_length = 30) item_code = models.CharField(max_length = 10) color = models.CharField(max_length = 150, null = True, blank = True) size = models.CharField(max_length = 30, null = True, blank = True) fabric_code = models.CharField(max_le...

Python: using a regular expression to match one line of HTML

This simple Python method I put together just checks to see if Tomcat is running on one of our servers. import urllib2 import re import sys def tomcat_check(): tomcat_status = urllib2.urlopen('http://10.1.1.20:7880') results = tomcat_status.read() pattern = re.compile('<body>Tomcat is running...</body>',re.M|re.DOTALL) ...

Get the dictionary values for every key in a list

Let's say I have a list: a = ['apple', 'carrot'] and a dictionary: d ={'apple': [2,4], 'carrot': [44,33], 'orange': [345,667]} How can I use the list a as a key to lookup in the dictionary d? I want the result to be written to a comma-separated textfile like this apple, carrot 2, 44 4, 33 Corrected the a-list ...

Is it possible to renice a subprocess ?

I know about os.nice() it works perfect for parent process, but I need to do renice of my child subprocesses. I found way to do this, but it seems to be not very handy and too excessive: os.system("renice -n %d %d" % ( new_nice, suprocess.pid ) ) And it isn't return resulting nice level after renicing. Is there more clean way to reni...

Simple image server

I have a bunch of images that I need others to browse via a web browser in pretty much the same way as Apache-Gallery. I'd be able to dump all my images in a directory so that users hitting: http://server:port/directory would see small thumbnails and selecting an image would load it full size on a page with options to browse the prev...

Python in-memory zip library

Is there a Python library that allows manipulation of zip archives in memory, without having to use actual disk files? The ZipFile library does not allow you to update the archive. The only way seems to be to extract it to a directory, make your changes, and create a new zip from that directory. I want to modify zip archives without di...

python FancyURLopener timeout

Hi, is there a way to set connection timeout for FancyURLopener()? I'm using FancyURLopener.retrieve() to download a file, but sometimes it just stucks and that's all... I think this is because it's still trying to connect and it's not possible. So is there a way to set that timeout? Thanks for every reply ...

concatenate multi values in one record without duplication

I have a dbf table like below which is the result of one to many join from two tables. I want to have unique zone values from one Taxlot id field. table name: input table tid ----- zone 1 ------ A 1 ------ A 1 ------ B 1 ------ C 2 ------ D 2 ------ E 3 ------ C Desirable output table table name: input table tid ----- zone 1 ------ A,...