Trouble with CGI code from Code Example 7.3 of the "Python Interactive CGI Tutorial"


On 21 ago, 20:10, Steve Holden wrote:
> Gabriel Genellina wrote:
>
> [...]working crystall balls are hard to find nowadays
>
> Well, judging by the OP's response you appear to be in possession of a
> pair :-)

Great-grandmother's legacy, and not for sale!

--
Gabriel Genellina

Posted On: Wednesday 7th of November 2012 01:31:23 PM Total Views:  332
View Complete with Replies

RELATED TOPICS OF Python Programming PROGRAMMING LANGUAGE




(relative) import trouble, sometimes it works, sometimes it doesn't...

hello, I'm running Python 2.5 and want my programs to run at least under Windows and Linux (preferable also Mac). So I guess I should always use relative paths. From most modules I can call a global function, that should import a dictionary from path deeper than the module itself. The import is done in the global function. In that global function, I get the modules path by SourceFile = sys._getframe(1).f_code.co_filename now to be sure to succeed the import (at least I was thinking this would always be successful :-( I need to 1- add the path of the module to be imported to sys.path (or do a dot import) 2- keep track of already done imports, to give a reload the next time (or maybe always do an import followed by an reload ) Now what I don't understand is what relative path should I use in 1: - relative to the main application - relative to the working directory were I started the application - relative to the current working directory - relative to the module that is doing the import - relative to the module that called the global function I would be pleased if someone could enlighten me, because this information is hard to find.
VIEWS ON THIS POST

207

Posted on:

Saturday 3rd November 2012
View Replies!

PYPI, some troubles

, 1. when I commit a new release to PYPI, I can use stored data (by my browser: Name, package summary, keywords etc), but in the last line (classification) I had to chose all those lines from the very beginning, moreover, if I click at one of them without pressing "CTRL" all my choices drops & I have to type it from the very beginning (I use Mozilla Firefox 3.0 but I don't think it's the matter). 2. Another issue: I have attached my source code (openopt0.19.tar.bz2 file), now I can see it in "files for openopt 0.19" section (http:// pypi.python.org/pypi) but easy_install can't find the package: # easy_install openopt Searching for openopt Reading http://pypi.python.org/simple/openopt/ Couldn't find index page for 'openopt' (maybe misspelled) Scanning index of all packages (this may take a while) Reading http://pypi.python.org/simple/ Reading http://pypi.python.org/simple/OpenOpt/ Reading http://scipy.org/scipy/scikits/wiki/OpenOpt No local packages or download links found for openopt error: Could not find suitable distribution for Requirement.parse('openopt') Does anyone know what shoul I do Thank you in advance, Dmitrey
VIEWS ON THIS POST

124

Posted on:

Saturday 3rd November 2012
View Replies!

Having trouble with tail -f standard input

, I have been working on a python script to parse a continuously growing log file on a UNIX server. The input is the standard in, piped in from the log file. The application works well for the most part, but the problem is when attempting to continuously pipe information into the application via the tail -f command. The command line looks something like this: tail -f | grep | python parse.py If I don't pipe the standard in to the python script, it displays any new entries immediately on the screen. However, if I pipe the information into the script, the sys.stdin.readline() doesn't get any new data until a buffer fills, after which it parses a block of new information all at once (output is fine). I need it to read the data in real-time instead of waiting for the buffer to fill. I have tried running the script with the -u parameter but that doesn't seem to be doing anything. Also, if I run the program against a text file and add a line to the text file (via cat >> ) it picks it up right away. I'm sure that it's just a simple parameter that needs to be passed or something along those lines but have been unable to find the answer. Any ideas would be appreciated.
VIEWS ON THIS POST

121

Posted on:

Saturday 3rd November 2012
View Replies!

Bit of List replacing trouble (newbie)

At the moment i'm doing a piece of work for school and I'm stuck at the moment. I have a list of words, for example: Sentence = ['A', 'dog', 'walked', 'across', 'the', 'street'] I have another list which I need to use to replace certain words, and its in the form of: synonyms = [ [canine, [dog, puppy, bulldog]], [ road, [street, avenue, court]] ] What the procedure must do is replace dog with canine, and street with road. Therefore if a word is in the sentence and appears on the right side of the list entry, replace it with the left entry. I can't seem to find a help file with what I'm after. I'm just wondering if anyone can help me on the right track on how to start this procedure, maybe not an answer but just a little help on how to get started as I'm complete stuck right now. -- View this message in context: http://www.nabble.com/Bit-of-List-re...p17397379.html Sent from the Python - python-list mailing list archive at Nabble.com.
VIEWS ON THIS POST

146

Posted on:

Saturday 3rd November 2012
View Replies!

How to troubleshoot hanging script?

Hi! I have a Pythonoob question. I have a script that hangs indefinitely at random times; the only thing to do at this point is to kill it. I'm looking for suggestions on how to troubleshoot and debug the problem. I'm not even sure of where exactly the script is hanging, though I suspect it is right around when it tries to read from a pipe (generated by popen). (I arrived at this guess by putting print statements all over the place, but I'm not sure this is a very reliable way to pinpoint the error.) So the first thing I'd like to do is find out exactly where the script is hanging. It would be nice if I could just hit Ctrl-C (which sends SIGINT from the terminal) when the script is hanging, to kill it and get a backtrace, but when this script hangs it becomes unresponsive to Ctrl-C! The only way to kill it is with something like % pkill -KILL my_script.py or even % pkill -TERM my_script.py ....or -ABRT or -QUIT. I tried to exploit this by adding this to the script: import signal def term_handler(signum, frame): raise KeyboardInterrupt signal.signal(signal.SIGTERM, term_handler) ....but this did not help at all; in fact, after this addition, the script no longer responded to pkill -TERM. TIA! Kynn -- NOTE: In my address everything before the first period is backwards; and the last period, and everything after it, should be discarded.
VIEWS ON THIS POST

122

Posted on:

Sunday 4th November 2012
View Replies!

trouble building Python 2.5.1 on solaris 10

When make gets to the _ctypes section, I am getting the following in my output: building '_ctypes' extension creating build/temp.solaris-2.10-i86pc-2.5/home/ecuser/Python-2.5.1/ Modules/_ctypes creating build/temp.solaris-2.10-i86pc-2.5/home/ecuser/Python-2.5.1/ Modules/_ctypes/libffi creating build/temp.solaris-2.10-i86pc-2.5/home/ecuser/Python-2.5.1/ Modules/_ctypes/libffi/src creating build/temp.solaris-2.10-i86pc-2.5/home/ecuser/Python-2.5.1/ Modules/_ctypes/libffi/src/x86 gcc -fPIC -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes -I. -I/home/ecuser/Python-2.5.1/./Include -Ibuild/ temp.solaris-2.10-i86pc-2.5/libffi/include -Ibuild/temp.solaris-2.10- i86pc-2.5/libffi -I/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/ src -I./Include -I. -I/usr/local/include -I/home/ecuser/Python-2.5.1/ Include -I/home/ecuser/Python-2.5.1 -c /home/ecuser/Python-2.5.1/ Modules/_ctypes/_ctypes.c -o build/temp.solaris-2.10-i86pc-2.5/home/ ecuser/Python-2.5.1/Modules/_ctypes/_ctypes.o gcc -fPIC -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes -I. -I/home/ecuser/Python-2.5.1/./Include -Ibuild/ temp.solaris-2.10-i86pc-2.5/libffi/include -Ibuild/temp.solaris-2.10- i86pc-2.5/libffi -I/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/ src -I./Include -I. -I/usr/local/include -I/home/ecuser/Python-2.5.1/ Include -I/home/ecuser/Python-2.5.1 -c /home/ecuser/Python-2.5.1/ Modules/_ctypes/callbacks.c -o build/temp.solaris-2.10-i86pc-2.5/home/ ecuser/Python-2.5.1/Modules/_ctypes/callbacks.o gcc -fPIC -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes -I. -I/home/ecuser/Python-2.5.1/./Include -Ibuild/ temp.solaris-2.10-i86pc-2.5/libffi/include -Ibuild/temp.solaris-2.10- i86pc-2.5/libffi -I/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/ src -I./Include -I. -I/usr/local/include -I/home/ecuser/Python-2.5.1/ Include -I/home/ecuser/Python-2.5.1 -c /home/ecuser/Python-2.5.1/ Modules/_ctypes/callproc.c -o build/temp.solaris-2.10-i86pc-2.5/home/ ecuser/Python-2.5.1/Modules/_ctypes/callproc.o /home/ecuser/Python-2.5.1/Modules/_ctypes/callproc.c: In function `_CallProc': /home/ecuser/Python-2.5.1/Modules/_ctypes/callproc.c:918: warning: implicit declaration of function `alloca' gcc -fPIC -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes -I. -I/home/ecuser/Python-2.5.1/./Include -Ibuild/ temp.solaris-2.10-i86pc-2.5/libffi/include -Ibuild/temp.solaris-2.10- i86pc-2.5/libffi -I/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/ src -I./Include -I. -I/usr/local/include -I/home/ecuser/Python-2.5.1/ Include -I/home/ecuser/Python-2.5.1 -c /home/ecuser/Python-2.5.1/ Modules/_ctypes/stgdict.c -o build/temp.solaris-2.10-i86pc-2.5/home/ ecuser/Python-2.5.1/Modules/_ctypes/stgdict.o gcc -fPIC -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes -I. -I/home/ecuser/Python-2.5.1/./Include -Ibuild/ temp.solaris-2.10-i86pc-2.5/libffi/include -Ibuild/temp.solaris-2.10- i86pc-2.5/libffi -I/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/ src -I./Include -I. -I/usr/local/include -I/home/ecuser/Python-2.5.1/ Include -I/home/ecuser/Python-2.5.1 -c /home/ecuser/Python-2.5.1/ Modules/_ctypes/cfield.c -o build/temp.solaris-2.10-i86pc-2.5/home/ ecuser/Python-2.5.1/Modules/_ctypes/cfield.o gcc -fPIC -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes -I. -I/home/ecuser/Python-2.5.1/./Include -Ibuild/ temp.solaris-2.10-i86pc-2.5/libffi/include -Ibuild/temp.solaris-2.10- i86pc-2.5/libffi -I/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/ src -I./Include -I. -I/usr/local/include -I/home/ecuser/Python-2.5.1/ Include -I/home/ecuser/Python-2.5.1 -c /home/ecuser/Python-2.5.1/ Modules/_ctypes/malloc_closure.c -o build/temp.solaris-2.10-i86pc-2.5/ home/ecuser/Python-2.5.1/Modules/_ctypes/malloc_closure.o gcc -fPIC -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes -I. -I/home/ecuser/Python-2.5.1/./Include -Ibuild/ temp.solaris-2.10-i86pc-2.5/libffi/include -Ibuild/temp.solaris-2.10- i86pc-2.5/libffi -I/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/ src -I./Include -I. -I/usr/local/include -I/home/ecuser/Python-2.5.1/ Include -I/home/ecuser/Python-2.5.1 -c /home/ecuser/Python-2.5.1/ Modules/_ctypes/libffi/src/prep_cif.c -o build/temp.solaris-2.10- i86pc-2.5/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/src/ prep_cif.o gcc -fPIC -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes -I. -I/home/ecuser/Python-2.5.1/./Include -Ibuild/ temp.solaris-2.10-i86pc-2.5/libffi/include -Ibuild/temp.solaris-2.10- i86pc-2.5/libffi -I/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/ src -I./Include -I. -I/usr/local/include -I/home/ecuser/Python-2.5.1/ Include -I/home/ecuser/Python-2.5.1 -c /home/ecuser/Python-2.5.1/ Modules/_ctypes/libffi/src/x86/ffi64.c -o build/temp.solaris-2.10- i86pc-2.5/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/src/x86/ ffi64.o gcc -fPIC -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes -I. -I/home/ecuser/Python-2.5.1/./Include -Ibuild/ temp.solaris-2.10-i86pc-2.5/libffi/include -Ibuild/temp.solaris-2.10- i86pc-2.5/libffi -I/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/ src -I./Include -I. -I/usr/local/include -I/home/ecuser/Python-2.5.1/ Include -I/home/ecuser/Python-2.5.1 -c /home/ecuser/Python-2.5.1/ Modules/_ctypes/libffi/src/x86/unix64.S -o build/temp.solaris-2.10- i86pc-2.5/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/src/x86/ unix64.o gcc -fPIC -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes -I. -I/home/ecuser/Python-2.5.1/./Include -Ibuild/ temp.solaris-2.10-i86pc-2.5/libffi/include -Ibuild/temp.solaris-2.10- i86pc-2.5/libffi -I/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/ src -I./Include -I. -I/usr/local/include -I/home/ecuser/Python-2.5.1/ Include -I/home/ecuser/Python-2.5.1 -c /home/ecuser/Python-2.5.1/ Modules/_ctypes/libffi/src/x86/ffi.c -o build/temp.solaris-2.10- i86pc-2.5/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/src/x86/ ffi.o /home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/src/x86/ffi.c:177: warning: function declaration isn't a prototype /home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/src/x86/ffi.c:194: warning: function declaration isn't a prototype gcc -fPIC -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict- prototypes -I. -I/home/ecuser/Python-2.5.1/./Include -Ibuild/ temp.solaris-2.10-i86pc-2.5/libffi/include -Ibuild/temp.solaris-2.10- i86pc-2.5/libffi -I/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/ src -I./Include -I. -I/usr/local/include -I/home/ecuser/Python-2.5.1/ Include -I/home/ecuser/Python-2.5.1 -c /home/ecuser/Python-2.5.1/ Modules/_ctypes/libffi/src/x86/sysv.S -o build/temp.solaris-2.10- i86pc-2.5/home/ecuser/Python-2.5.1/Modules/_ctypes/libffi/src/x86/ sysv.o Assembler: "/var/tmp//ccbsqiOB.s", line 236 : Syntax error Near line: ".section .note.GNU-stack,"",%progbits" my configure looks like this: ./configure --prefix=/home/ecuser/dev -- with-gcc --with-system-ffi any ideas
VIEWS ON THIS POST

232

Posted on:

Sunday 4th November 2012
View Replies!

Re: Teething troubles with Python on a Mac

On 03Aug2008 23:14, Avinash Vora wrote: >> You will likely cause more problems updating the system python than >> managing the two separate installations. > > That's sadly worrying. It shouldn't be. It is often useful to have multiple versions of stuff installed. Replacing the system stuff means playing in the vendor/distributor's namespace, and you may expect they to cheerfully and freely tread all over your changes if something in Software Update wants to. By keeping a separate Python install you know you are not damaging the system, and the system will not damage you. Personally I use python 2.5 from the macports stuff, which installs to /opt/local. Neatly out of the way. It's all very easy. >> OSX relies on the version of python they ship. > > I think that helps my point--there *are* bug fixes between major > versions despite the new language changes, and that can really only be a > good thing. No, it does not help your point. The OS may rely on a _bug_! It is best to keep the OS and the stuff it uses pristine, because the two parts are shaped to fit each other. They work now, and you're changing something that works. Whether an "upgrade" changes a bug or a feature is irrelevant - it changes behaviour. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Zombies don't get pumped. - Jake, in rec.climbing
VIEWS ON THIS POST

145

Posted on:

Sunday 4th November 2012
View Replies!

Having trouble with some lists in BeautifulSoup

Okay, what I want to do with this code is to got to thesaurus.reference.com and then search for a word and get the syns for it. Now, I can get the syns, but they are still in html form and some are hyperlinks. But I can't get the contents out. I am not that familiar with BeautifulSoup. So if anyone wants to look over this code(if you run it, it will make a lot more sense) and maybe help me out. side note: if you run it, a list object will print and what I am after is the part that starts: american... Heres the code: import urllib from BeautifulSoup import BeautifulSoup class defSyn: def __init__(self, word): self.word = word def get_syn(term): soup = BeautifulSoup(urllib.urlopen('http://thesaurus.reference.com/searchq=%s' % term)) balls = soup.find('table', {'width': '100%'}) print soup.prettify() for tabs in soup.find('table', {'width': '100%'}): yield tabs.find('td', {'colspan': '2'}) self.mainList = list(get_syn(self.word)) print self.mainList[2] if You have any further questions I would be happy to answer. -- View this message in context: http://www.nabble.com/Having-trouble...p18497409.html Sent from the Python - python-list mailing list archive at Nabble.com.
VIEWS ON THIS POST

129

Posted on:

Sunday 4th November 2012
View Replies!

pyqt4: trouble making custom widget appear in mainwindow

about 3 years ago I did a bit of Qt3 and 4 on C++, now I am trying to do something in python. A QMainWindow subclass as my mainwindow. Its basically a frame with no widgets of its own. Several QWidget subclasses each representing a mode of the program, these widgets should appear in the mainwindow depending on what part of the program is being used. I have made the main window and a couple of widgets with designer-qt4 and generate a Ui_Whatever.py with pyuic4 and subclass that. My problem is I cant get my widgets to appear in the main window. My MainWindow.py looks like (imports etc skipped): class MainWindow(QMainWindow, Ui_MainWindow): def __init___(self): QMainWindow.__init__(self) self.setupUi(self) def newTeamWizardMode(self): Widget = QWidget() self.newTeamWizard = CreateNewTeamWizard(Widget) self.newTeamWizard.setGeometry(QRect(0,0,90, 160)) self.newTeamWizard.setObjectName("newTeamWizard") self.newTeamWizard.show() My CreateNewTeamWizard is defined like so: class CreateNewTeamWizard(QWidget, Ui_CreateNewTeamWizard): def __init___(self, parent = None): QWidget.__init__(self, parent) self.setupUi(self) In my main program i make the main window and try and add the widget like this: app = Qt.QApplication(sys.argv) mainWindow = MainWindow() app.connect(app, Qt.SIGNAL("lastWindowClosed()"), app, Qt.SLOT("quit ()")) mainWindow.newTeamWizardMode() mainWindow.show() One thing i tried was changing the CreateNewTeamWizard in MainWindow.newTeamWizardMode to CreateNewTeamWizard(Widget, self) to provide the main window as the parent but I get the following error: self.newTeamWizard = CreateNewTeamWizard(Widget, self) TypeError: argument 2 of QWidget() has an invalid type I have looked for examples, but everything I have found is a bit too simple. Creating a single window or widget, displaying it as the programs main window and exiting when the window is closed. I havent found anything to tell me how to make a widget appear in a mainwindow how I want. Any tips If someone can point me to a nice open source program that uses pyqt4 that might help.
VIEWS ON THIS POST

147

Posted on:

Sunday 4th November 2012
View Replies!

Recursive loading trouble for immutables

I am currently building a system for serializing python objects to a readable file-format, as well as creating python objects by parsing the same format. It is more or less complete except for a single issue I just cannot figure out by myself: How to load data that specifies immutables that recursively reference themselves. There are only a few solutions I can think of. One: While loading recursive objects, I always create empty versions of objects (lists, dicts, classes) etc, and fill them in afterwards. This works fine for loading recursive lists and such, but as immutables are, well, immutable, this gets me nowhere with important datatypes like tuples. Two: Global replacement. If I dont remember incorrectly, PyPy has a function for simply globally replacing all references to a given object with another. This would make the loading code a piece of cake, although I assume this functionality doesn't exist in CPython This is the second time I've had good use for it. Three: Create transparent proxies everywhere. Just kidding. Four: Disallow immutable recursiveness. This is bad for two reasons. Firstly, it requires me to greatly increase the complexity of the loading code as I have to topsort all references to avoid recursiveness in immutables while at the SAME TIME allow mutables to be recursive. I can't imagine how unelegant the code will be. Secondly, there is nothing wrong with recursive tuples. To disallow them and work miles around them just because they can't be properly expressed in Python In any case I am stumped. It's the last piece of a module I am otherwise very pleased with. There must be a way. I certainly know most people on this list can get around python much better than I do, so, any ideas ---------------------------------------------------------------- Brought to you by Footard: http://www.footard.com Please report abuse/spam/scams to reportabuse at footard dot com
VIEWS ON THIS POST

140

Posted on:

Monday 5th November 2012
View Replies!

trouble with PAMIE

I'm using PAMIE to automate some web browsing. My problem is with the buttonClick() method. It seems to work unless the button is supposed to open a new window, in which case nothing happens. There is no error message. Any ideas Daniel
VIEWS ON THIS POST

155

Posted on:

Monday 5th November 2012
View Replies!

Re: PyDev 1.3.9 code compleition trouble

Vyacheslav Maslov wrote: > I use Pydev 1.3.9 and notice issue related to code completion. I give an > ...stuff deleted... > proposed also as well. Why this doesn't work You will have better luck asking this question on the Pydev forum: http://sourceforge.net/forum/forum.phpforum_id=293649 The SF forum is also mirrored on gmane as: gmane.comp.ide.eclipse.plugins.pydev.user Fabio provides an _amazing_ level of support for Pydev on this forum, I don't think he ever sleeps. Don.
VIEWS ON THIS POST

138

Posted on:

Monday 5th November 2012
View Replies!

PyDev 1.3.9 code compleition trouble

Hi! I use Pydev 1.3.9 and notice issue related to code completion. I give an example BaseClass.py: class BaseClass: def someMethod(x): return x+x DerivedClass.py: import BaseClass class DerivedClass(BaseClass.BaseClass): def newMethod(self): print self.someMethod(4) I try to use code completion in class DerivedClass inside method "newMethod", after typing "self." and pushing ctrl+space completion dialog propose substitution only for method "newMethod". However, i expect that method defined in BaseClass called "someMethod" should be proposed also as well. Why this doesn't work
VIEWS ON THIS POST

138

Posted on:

Monday 5th November 2012
View Replies!

trouble controlling vim with subprocess on windows machine

I am having trouble contolling vim with subprocess on a windows machine. It appears that vim comes up on the machine all right and it sometimes looks like it is doing the searchs what I am asking it to do but when I am asking it to load a file it doesn't do anything. Is there something I need to do to push the data through the pipe\t Here is a couple different ways I am trying to do it. def load_instrument(instr_name, csdname): "load an instrument using vim a path should be defined for vim currently I am doing that with the .bat file that loads the program" f = open('csdfile.tmp','w') my_path = "/dex tracker" cmd = ["gvim",csdname] vimin = subprocess.Popen(cmd,stdin=subprocess.PIPE)#.comunicate() [0] #, stdout = f, stderr = f, cwd = my_path ) #f.close #x = subprocess.Popen("clear").communicate(None)[0] innum = csr.return_unique_instr_number(csdname) - 1 cmd = """/;
VIEWS ON THIS POST

190

Posted on:

Monday 5th November 2012
View Replies!

Re: PIL DPI trouble

En Thu, 13 Sep 2007 23:50:39 -0300, Gary Bloom escribi: > I notice that the PIL has trouble playing with the DPI of other programs > and image standards: when I create a file with Paint Shop Pro or > Photoshop, the PIL routines can't properly recognize the DPI. Do you mean that PIL doesn't read the DPI attribute from the file, or shows a different value than expected > And when I create an image file (via the save method) of PIL, setting > the DPI, those same two programs can't read the DPI as set by them. Is > there a workaround for this Using which file format DPI is just an indication, a reference value. Changing it won't modify the image size in pixels, quality or resolution. Maybe you could post some sample code showing what you attempt to do. -- Gabriel Genellina
VIEWS ON THIS POST

152

Posted on:

Monday 5th November 2012
View Replies!

path backslash escaping trouble

Hi , I have these files; which are Merge Request (ClearCase) files that are created by a Perl CGI script (being re-written in Python, as the HTML/ JavaScript have been mixed with Perl, maintainability is zero) MergeType::::codefromlabel:::: BLname::::BUILDMODS:::: OldLname:::::::: BaseVersion::::6.9.1.24A:::: RequiredRelease::::6.10.1.3:::: Description:::::::: FixRelation:::::::: Dependencies:::::::: LpAffected::::No:::: CodeReview::::FirstName LastName:::: Testing::::Compile/Build;Designer;Smoketests;:::: OtherTesting:::::::: Vobs::::ipsupport;:::: Elements::::\ipsupport\ipbuild\Wizard\build.pl@@\main\buildmods\3:::: i read this whole file into a string so i can search for the value of Elements which is \ipsupport\ipbuild\Wizard\build.pl@@\main\buildmods\3 but this path is escaped \\ipsupport\\ipbuild\\Wizard\\build.pl@@\\main\\buildmods\\3 so when i try to escape a string containing that same path using any of the os.path escaping methods doesnt result in the correct escaped path. It either appends "C:\\" in front of the string with all the backslashes escaped or it converts the three(3) at then end to "x03" and a match doesnt occur! My question is, is there a function in Python that only escapes backslashes Cheers , En Mon, 09 Jul 2007 22:40:04 -0300, placid escribi: > I have these files; which are Merge Request (ClearCase) files that are > created by a Perl CGI script (being re-written in Python, as the HTML/ > JavaScript have been mixed with Perl, maintainability is zero) > > MergeType::::codefromlabel:::: > BLname::::BUILDMODS:::: > OldLname:::::::: > BaseVersion::::6.9.1.24A:::: > RequiredRelease::::6.10.1.3:::: > Description:::::::: > FixRelation:::::::: > Dependencies:::::::: > LpAffected::::No:::: > CodeReview::::FirstName LastName:::: > Testing::::Compile/Build;Designer;Smoketests;:::: > OtherTesting:::::::: > Vobs::::ipsupport;:::: > Elements::::\ipsupport\ipbuild\Wizard\build.pl@@\main\buildmods\3:::: > > i read this whole file into a string so i can search for the value of > Elements which is > \ipsupport\ipbuild\Wizard\build.pl@@\main\buildmods\3 > > but this path is escaped > \\ipsupport\\ipbuild\\Wizard\\build.pl@@\\main\\buildmods\\3 > > so when i try to escape a string containing that same path using any > of the os.path escaping methods doesnt > result in the correct escaped path. It either appends "C:\\" in front > of the string with all the backslashes escaped > or it converts the three(3) at then end to "x03" and a match doesnt > occur! You may be confused about the actual string contents: "a\\b" contains exactly 3 characters, the second being a single backslash. The \ is the escape character; to include an actual \ inside a string, you have to double it. Another way is to use raw string literals (supressing escape processing): r"a\\b" contains four characters. See section 3.1.2 in the Python tutorial or the Reference (more technical): http://docs.python.org/ref/strings.html -- Gabriel Genellina
VIEWS ON THIS POST

166

Posted on:

Monday 5th November 2012
View Replies!

flock trouble

I'm trying to implement a file server using the code below. However the locking doesn't work. I can delete while put'ing a file. Anyone got an idea about why best regards, seb #! /usr/bin/env python import Pyro.core, Pyro.naming from Pyro.errors import PyroError, NamingError import sys import urllib import os import fcntl class fileServer(Pyro.core.ObjBase): basePath = "/home/snot/diku/dist/opg2/files_to_serve" def __init__(self): Pyro.core.ObjBase.__init__(self) self.basePath = self.basePath.strip("..") if not os.path.isdir(self.basePath) or os.path.islink(self.basePath): raise "invalid path" def get(self, uri): f = open(self.basePath + uri, 'r+') fcntl.flock(f, fcntl.LOCK_SH) data = f.read() fcntl.flock(f, fcntl.LOCK_UN) f.close() return data def put(self, uri, payload): f = open(self.basePath + urllib.unquote_plus(uri), 'w') fcntl.flock(f, fcntl.LOCK_EX) f.truncate() f.write(payload) fcntl.flock(f, fcntl.LOCK_UN) f.close() def delete(self, uri): f = open(self.basePath + urllib.unquote_plus(uri), 'w') fcntl.flock(f, fcntl.LOCK_EX) os.unlink(self.basePath + uri) fcntl.flock(f, fcntl.LOCK_UN) f.close() try: Pyro.core.initServer() daemon = Pyro.core.Daemon() locator = Pyro.naming.NameServerLocator() print 'Searching for Name Server...' try: ns = locator.getNS() except Pyro.errors.PyroError, message: print message sys.exit(1) daemon.useNameServer(ns) try: ns.unregister("fileServer") except NamingError: pass uri = daemon.connect(fileServer(), "fileServer") print "The daemon runs on port:", daemon.port print "The object's uri is:", uri daemon.requestLoop() except KeyboardInterrupt: ns.unregister("fileServer") print "ctrl + c pressed"
VIEWS ON THIS POST

125

Posted on:

Wednesday 7th November 2012
View Replies!

MoinMoin: trouble after install

I've installed MoinMoin easily enough, but i have two problems now. 1) Some pages, namely the initial FrontPage, fail to load completely.... 2) It seems after logging in, if I navigate away from the login page, I get logged out immediately. I'm runing 1.13 on Fedora 9 with Apache 2 and ReWriteRules... all seemed well initially...
VIEWS ON THIS POST

126

Posted on:

Wednesday 7th November 2012
View Replies!

trouble with PAMIE

I'm trying to use PAMIE to automate some web browsing. My problem is with the buttonClick() method; it doesn't seem to work when the button is supposed to open a new window. For example, I can use it to submit a username and password and advance to the next page but it fails on a button that opens a PDF Preview in a new window. There is no error message. Any ideas
VIEWS ON THIS POST

130

Posted on:

Wednesday 7th November 2012
View Replies!

trouble with PAMIE

I'm trying to use PAMIE to automate some web browsing. My problem is with the buttonClick() method; it seems to work unless the button is supposed to open a new window. Specifically, the button is supposed to open a PDF Preview in a new window. Any ideas Daniel
VIEWS ON THIS POST

129

Posted on:

Wednesday 7th November 2012
View Replies!