Re: [Tutor] Running a dos program with python

2010-03-10 Thread Martin Walsh
Armstrong, Richard J. wrote: > Hello all, > > This is my first post to the Tutor@python.org > mailing list. I am in the process of switching from Matlab to Python and > there is one task that I am having a hard time doing and cannot find the > answer on the web. I want to

Re: [Tutor] accessing Postgres db results by column name

2010-04-09 Thread Martin Walsh
Serdar Tumgoren wrote: > Hey everyone, > > Ricardo was nice enough to post his solution as a recipe on ActiveState. > For anyone interested in bookmarking it, here's the link: > > http://code.activestate.com/recipes/577186-accessing-cursors-by-field-name/ > > Serdar > I really like Ricardo's s

Re: [Tutor] PIL problem

2010-05-07 Thread Martin Walsh
Jim Byrnes wrote: > Running Unbuntu 9.10. The Synaptic Pkg Mgr reports python-imaging - > 1.1.6-3ubuntu1 - Python Imaging Library is installed. > > But trying to import PhotoImage gives these results: > > from ImageTk import PhotoImage > Traceback (most recent call last): > File "", line

Re: [Tutor] Help with choices for new database program

2010-07-03 Thread Martin Walsh
On 07/03/2010 10:25 AM, Jim Byrnes wrote: > Jeff Johnson wrote: [snip] >> http://dabodev.com/ >> >> Please check it out. And go to www.leafe.com and subscribe to the >> dabo-user email list. > > I would like to try out Dabo, but I don't see it in the Ubuntu > repositories and I would like to avo

Re: [Tutor] Reply All Dilemma of This List

2009-02-10 Thread Martin Walsh
Wayne Watson wrote: > I belong to many, many forums, Yahoo Groups, (Usenet) newsgroups, and > mail lists. Probably 100 or more. I think it's fair to say that none of > them but this one has an implicit "Reply All". For newsgroups and mail > lists, I just press my Mozilla Seamonkey mailer Reply butt

Re: [Tutor] Changing the Attribute of a Variable

2009-02-18 Thread Martin Walsh
Marc Tompkins wrote: > Also - config_var_list is a tuple of lists. (I'm guessing you intended > to make it a list of lists - that's what the name indicates, after all - > but putting it between "( )" makes it a tuple.) Sound advice, but a subtle clarification is warranted I think. It's the comm

Re: [Tutor] Simple CGI script and Apache configuration

2009-02-23 Thread Martin Walsh
wormwood_3 wrote: > Hello all, Hi Sam, > I'll try to give as much detail as I can, but this is a somewhat vague > problem. I have a very simple script that I would like to implement as a > CGI script, just so I can hit a URL and get some output. However, after > following a number of tutorials, I

Re: [Tutor] Simple CGI script and Apache configuration

2009-02-23 Thread Martin Walsh
wormwood_3 wrote: > Thanks for all the suggestions! I tried to go through them, and will > relate what results I encountered. I changed my Apache config to: > > > AllowOverride None > Options ExecCGI > Order allow,deny >

Re: [Tutor] Simple CGI script and Apache configuration

2009-02-24 Thread Martin Walsh
wormwood_3 wrote: > I wasn't sure if that was needed, so I took it out, sorry about that. I put > > ScriptAlias /cgi-bin/ "/var/www/samuelhuckins.com/cgi-bin/" > > in place, reloaded, and it works! I think the problem throughout was > that I was mixing up what was necessary between CGI and mod_p

Re: [Tutor] re.format a file

2009-02-26 Thread Martin Walsh
A.T.Hofkamp wrote: > prasad rao wrote: >> helloThank you Lie and Kent. >> I forgot about newline character and the fact that string can be sliced. >> Thanks for your timely help >> BTW I have gone through the Python library reference and find no >> examples >> in fileinput module. > > The filein

Re: [Tutor] probelm pyhton shell doesnt open help please

2009-03-08 Thread Martin Walsh
mustafa akkoc wrote: > > it gives this message socket error > IDLE's subprocess didn't make a connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection. IIRC, this was once a known issue with IDLE when combined with the windows firewall service,

Re: [Tutor] merging dictionary values based on key

2009-03-12 Thread Martin Walsh
> greg whittier wrote: >> On Thu, Mar 12, 2009 at 4:24 PM, ski wrote: >> mylist = [{'a': 'x123', 'b':'12'}, {'a': 'x234', 'b': 'd33', 'c': >> 'a23'}, {'a': 'x234', 'c': 'XX123'} ] >>> where mylist has nth number of dictionaries and i want to merge the >>> values >>> of the keys that a

Re: [Tutor] Modifying Grayson's Example 5_14

2009-03-16 Thread Martin Walsh
Wayne Watson wrote: ... > it. It works pretty well, but puts up a a few probably top level > windows that are blank. How do I get around them, and is there anything ... > > root = Tk() Try adding this, root.withdraw() > dialog = GetPassword(root) HTH, Marty

Re: [Tutor] Modifying Grayson's Example 5_14

2009-03-17 Thread Martin Walsh
> Martin Walsh wrote: >> Wayne Watson wrote: >> >> >> >>> it. It works pretty well, but puts up a a few probably top level >>> windows that are blank. How do I get around them, and is there anything >>> >> >> &g

Re: [Tutor] Fun with Label and Entry--Why NoneType?

2009-03-17 Thread Martin Walsh
Wayne Watson wrote: > The program below is derived from an example in Grayson for showing how > one might a dialog for entering passwords. The structure seems just like > the original, down to the use of self, Label and Entry plus . Yet the > print "here" statement produces: > here None > I'm

Re: [Tutor] Executing a C Program from RH Linux in Python for Win

2009-03-18 Thread Martin Walsh
Wayne Watson wrote: > If you can execute a C program compiled on a Linux with SWIG, then > that's what I'm looking for. There's really no RH dependency according > to the above posts. If it were compiled on Debian or Ubuntu, it appears > it would not make any difference. That is, one could execute

[Tutor] PyCon Videos

2009-04-16 Thread Martin Walsh
Hi All, Not sure if it's common knowledge, particularly for those who didn't make it to PyCon this year, but all of the talks were recorded and will be available online in good time, thanks to Carl Karsten and his merry band of A/V volunteers. I can't even begin to grasp how much work is required

Re: [Tutor] list to string and string to list

2009-04-16 Thread Martin Walsh
johnf wrote: > On Thursday 16 April 2009 05:04:39 pm Alan Gauld wrote: >> "johnf" wrote >> I want to save the list to the field and when I retrieve the string convert it back to a list. But this does NOT work. mylist=[1,2,3,4] mystr=str(mylist) newlist=

Re: [Tutor] list to string and string to list

2009-04-16 Thread Martin Walsh
Martin Walsh wrote: > johnf wrote: >> On Thursday 16 April 2009 05:04:39 pm Alan Gauld wrote: >>> "johnf" wrote >>> >>>>> I want to save the list to the field and when I retrieve the string >>>>> convert >>>>

Re: [Tutor] Sending a disconnect after openssl s_client command?

2009-04-20 Thread Martin Walsh
Kayvan Sarikhani wrote: > Tutors, > > I'm working on a script to verify whether a particular website > supports SSLv2 via the following: > > --- BEGIN --- > #!/usr/bin/python > import os, re > > checkssl_out = open('checkssl.txt','w') > > website = 'somewebsitename' > sslv2 = 'Protocol : SSL

Re: [Tutor] String Encoding problem

2009-04-20 Thread Martin Walsh
Matt wrote: > Hey everyone, > > I'm hoping someone here can help me solve an odd problem (bug?). I'm > having trouble with string encoding, object deletion, and the xml.etree > library. If this isn't the right list to be posting this question, > please let me know. I'm new to Python and don't know

Re: [Tutor] String Encoding problem

2009-04-20 Thread Martin Walsh
Forwarding to the list. Matt, perhaps you can repost in plain text, my mail client seems to have mangled your source ... Strax-Haber, Matthew (LARC-D320) wrote: >> *From: *Martin Walsh >> >> The environment available to __del__ methods during program termination >> is w

Re: [Tutor] PDF to text conversion

2009-04-21 Thread Martin Walsh
Robert Berman wrote: > Hello Emad, > > I have seriously looked at the documentation associated with pyPDF. This > seems to have the page as its smallest element of work, and what i need > is a line by line process to go from .PDF format to Text. I don't think > pyPDF will meet my needs but thank y

Re: [Tutor] Sending a disconnect after openssl s_client command?

2009-04-21 Thread Martin Walsh
Kayvan Sarikhani wrote: > On Mon, Apr 20, 2009 at 1:17 PM, Martin Walsh <mailto:mwa...@mwalsh.org>> wrote: > > from subprocess import Popen, PIPE > > openssl_cmd = 'openssl s_client -ssl2 -connect somewebsitename:443' > openssl = Popen( >

Re: [Tutor] finding mismatched or unpaired html tags

2009-04-28 Thread Martin Walsh
A.T.Hofkamp wrote: > Dinesh B Vadhia wrote: >> I'm processing tens of thousands of html files and a few of them >> contain mismatched tags and ElementTree throws the error: >> >> "Unexpected error opening J:/F2/663/blahblah.html: mismatched tag: >> line 124, column 8" >> >> I now want to scan each

Re: [Tutor] finding mismatched or unpaired html tags

2009-04-28 Thread Martin Walsh
appears to contain the line number. You'd only get one error per file per run, but you can run it until there are no errors remaining. I hope that makes sense. HTH, Marty > > > > Message: 7 > Date:

Re: [Tutor] Add newline's, wrap, a long string

2009-04-28 Thread Martin Walsh
David wrote: > I am getting information from .txt files and posting them in fields on a > web site. I need to break up single strings so they are around 80 > characters then a new line because when I enter the info to the form on > the website it has fields and it errors out with such a long string

Re: [Tutor] Add newline's, wrap, a long string

2009-04-28 Thread Martin Walsh
David wrote: > vince spicer wrote: >> first, grabbing output from an external command try: >> >> import commands >> >> USE = commands.getoutput('grep USE /tmp/comprookie2000/emege_info.txt >> |head -n1|cut -d\\"-f2') >> >> then you can wrap strings, >> >> import textwrap >> >> Lines = textwrap.wr

Re: [Tutor] Add newline's, wrap, a long string

2009-04-29 Thread Martin Walsh
David wrote: > Martin Walsh wrote: >>> ... but, you don't need to use subprocess at all. How about (untested), >>> >>> # grep USE /tmp/comprookie2000/emerge_info.txt |head -n1|cut -d\" -f2 >>> infof = open('/tmp/comprookie2000/emerge_info

Re: [Tutor] Add newline's, wrap, a long string

2009-04-29 Thread Martin Walsh
Sander Sweers wrote: > 2009/4/29 David : >> Here is the whole program so far, what it does is it logs into a druple web >> site and posts. I would like to make it better, as you can see I do the same >> thing over and over. >> >> http://linuxcrazy.pastebin.com/m7689c088 > > What you can do is defi

Re: [Tutor] returning the entire line when regex matches

2009-05-04 Thread Martin Walsh
Nick Burgess wrote: > So far the script works fine, it avoids printing the lines i want and > I can add new domain names as needed. It looks like this: > > #!/usr/bin/python > import re > > outFile = open('outFile.dat', 'w') > log = file("log.dat", 'r').read().split('Source') # Set the line delim

Re: [Tutor] Python popen command using cat > textfile .... how to terminate

2009-05-14 Thread Martin Walsh
MK wrote: > Hi there, > > i am using this code to send an "cat > ThisIsMyUrl" with popen. > Of cos cat now waits for the CTRL+D command. > How can i send this command ? > > def console_command(cmd): > print cmd > console = os.popen(cmd,"r") > output = console.read() > con

Re: [Tutor] finding difference in time

2009-05-15 Thread Martin Walsh
Kent Johnson wrote: > On Fri, May 15, 2009 at 12:46 AM, R K wrote: >> Gurus, >> >> I'm trying to write a fairly simple script that finds the number of hours / >> minutes / seconds between now and the next Friday at 1:30AM. >> >> I have a few little chunks of code but I can't seem to get everything

Re: [Tutor] sqlite3 format data from tables

2009-05-23 Thread Martin Walsh
David wrote: > David wrote: >> I have a budget program I am using to learn from. >> http://linuxcrazy.pastebin.com/f3b301daf >> >> I can not figure out how to get the transaction details to return so >> that it looks nice. It returns like this now. >> >> Your transaction History is: [(1, u'Food', -

Re: [Tutor] How o convert spaces into tabs??

2009-06-02 Thread Martin Walsh
vince spicer wrote: > > regex will do it > > > import re > > line = re.sub(r"\s+", "\t", line) > > print line The above replaces the newline, which reminds me that even seemingly trivial uses of 're' can become not-so-trivial in a hurry. In [1]: import re In [2]: line = '1 2 3 4 5\n' In

Re: [Tutor] recursive glob -- recursive dir walk

2009-06-10 Thread Martin Walsh
spir wrote: > Hello, > > A foolow-up ;-) from previous question about glob.glob(). > > I need to 'glob' files recursively from a top dir (parameter). Tried to use > os.walk, but the structure of its return value is really unhandy for such a > use (strange, because it seems to me this precise us

Re: [Tutor] Help..Concatenaton Error

2009-06-11 Thread Martin Walsh
ayyaz wrote: > Randy Trahan wrote: >> Attached is an error I cannot get to work, I was doing a print >> concatenation but it won't let me get past "+ "ibly impressive. " \ >> (then to next line) >> >> Also Programming Lanquage Question: >> I have studied and an fairly proficient at XHTML and CSS,

Re: [Tutor] How to change the working directory in IDLE

2009-06-16 Thread Martin Walsh
Elisha Rosensweig wrote: > Hi Tutors, > > I"m using Python 2.6.2 and the IDLE tool (also v. 2.6.2). However, when > I open the editor I cannot seem to change the directory so as to allow > for easy access to my modules. So, for example, the following occurs: > > os.chdir('/Users/elisha/Docum

Re: [Tutor] How to change the working directory in IDLE

2009-06-16 Thread Martin Walsh
Martin Walsh wrote: > Elisha Rosensweig wrote: >> Hi Tutors, >> >> I"m using Python 2.6.2 and the IDLE tool (also v. 2.6.2). However, when >> I open the editor I cannot seem to change the directory so as to allow >> for easy access to my modules.

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Martin Walsh
Allen Fowler wrote: > > > >>> What is the recommended way to configure my application find the various >> database and/or configuration files it needs? >> >> Recommemded by whom? A lot depends on the OS. Apple for example have one set >> of >> recommendations for MacOS, Windows has another an

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Martin Walsh
Allen Fowler wrote: > > > As a follow-up question, how do give my modules stored under ./lib access to > the data in my ConfigParser object? (For instance, database connection > string, storage path, etc.) > > I guess a global ConfigParser object would work, but that seems wrong. > And yet

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Martin Walsh
Allen Fowler wrote: > > > >> Something like this ... >> >> # lib/mypaths.py >> # -- >> >> import os >> >> def script_path(base): >> return os.path.realpath(os.path.abspath(base)) >> >> def script_dir(base): >> return os.path.dirname(script_path(base)) >> >> def join_relative(

Re: [Tutor] Configuaration files and paths?

2009-08-06 Thread Martin Walsh
Allen Fowler wrote: > > >> Martin Walsh >> > >> Allen Fowler wrote: >>> As a follow-up question, how do give my modules stored under ./lib access >>> to >> the data in my ConfigParser object? (For instance, database connection >

Re: [Tutor] Configuaration files and paths?

2009-08-09 Thread Martin Walsh
Allen Fowler wrote: >>> FWIW: >>> >>> When using relative paths I got extra ../../ terms, so I changed >> join_relative() to: >>> def join_relative(base, path): >>> return os.path.normpath(os.path.join(script_dir(base), path)) >>> >>> >>> Seems to work... >> >> Yeah, good catch ... looks grea

Re: [Tutor] Confusion with $PATH

2009-09-25 Thread Martin Walsh
Wayne wrote: > On Fri, Sep 25, 2009 at 11:32 AM, David Eric > wrote: > > ok this is really weird . . . > i tried running the helloworld again, and it doesnt work :/ > > DTm:~ davidteboul$ echo $PATH > PATH$/Library/Frameworks/ > > Python.framework/V

Re: [Tutor] Not workin!

2009-09-29 Thread Martin Walsh
Luke Paireepinart wrote: > In this case you are saying "is their input equal to this list with many > elements?" and the answer is always going to be No because a string > won't be equal to a list unless both are empty. I know you probably didn't mean this as it reads, or as I'm reading it, but an

Re: [Tutor] Iterable Understanding

2009-11-15 Thread Martin Walsh
Stephen Nelson-Smith wrote: > I think I'm having a major understanding failure. Perhaps this will help ... http://www.learningpython.com/2009/02/23/iterators-iterables-and-generators-oh-my/ > So in essence this: > > logs = [ LogFile( "/home/stephen/qa/ded1353/quick_log.gz", "04/Nov/2009" ), >

Re: [Tutor] Iterable Understanding

2009-11-15 Thread Martin Walsh
Stephen Nelson-Smith wrote: >> It's unclear from your previous posts (to me at least) -- are the >> individual log files already sorted, in chronological order? > > Sorry if I didn't make this clear. No they're not. They are *nearly* > sorted - ie they're out by a few seconds, every so often, bu

Re: [Tutor] Iterable Understanding

2009-11-16 Thread Martin Walsh
Stephen Nelson-Smith wrote: > Nope - but I can look it up. The problem I have is that the source > logs are rotated at 0400 hrs, so I need two days of logs in order to > extract 24 hrs from to 2359 (which is the requirement). At > present, I preprocess using sort, which works fine as long as

Re: [Tutor] Iterable Understanding

2009-11-23 Thread Martin Walsh
Stephen Nelson-Smith wrote: > Martin, > >>def __iter__(self): >>while True: >>for logline in self.logfile: >>heappush(self.heap, (timestamp(logline), logline)) >>if len(self.heap) >= self.jitter: >>break >>try:

Re: [Tutor] Example of use of (?P) and (?P=name) in Python regular expressions?

2009-11-28 Thread Martin Walsh
Michael Hannon wrote: > Greetings. While looking into the use of regular expressions in Python, I > saw that it's possible to name match groups using: > > (?P...) > > and then refer to them using: > > (?P=name) I'm not sure you've got that quite right. IIUC, the (?P=name) syntax is us

Re: [Tutor] Attaching an uploaded file to an email

2005-02-20 Thread Martin Walsh
Tim Wilson wrote: Hi everyone, Hi Tim, I'm a newb, first time posting, so please take any of the following advice at face value # Collect form information form = cgi.FieldStorage() requestername = form["requestername"].value fromaddr = form["email"].value itemname = form["itemname"].value

Re: [Tutor] Help debuging a small program

2005-02-22 Thread Martin Walsh
Mark Kels wrote: On Mon, 21 Feb 2005 13:21:35 -0500, Kent Johnson <[EMAIL PROTECTED]> wrote: How far does it get? How do you know? I would put some debug print statements in. Also you should call sk.close() in the else clause of scan(). Finally, I don't think you will see any output in the resul

Re: [Tutor] 3 questions for my port scanner project

2005-02-26 Thread Martin Walsh
Mark Kels wrote: Hi list. Hi Mark, 2. I got a while loop which does the port scan itself. How can I end it while its working ? previous message with code: *http://tinyurl.com/3lobo* **I'm not totally sure of this, but you might try adding another conditional to your while loop that can be to

Re: [Tutor] variable name based on variables (expansion?)

2005-02-28 Thread Martin Walsh
John Christian wrote: # But I want the assignment # to be based on variables LIST=1 POSITION=2 GameLogic.varList$LIST[$POSITION]=0 >>> help(getattr) Help on built-in function getattr: getattr(...) getattr(object, name[, default]) -> value Get a named attribute from an object; getattr(x, 'y

Re: [Tutor] python newbie..system call help

2005-07-14 Thread Martin Walsh
Mike Pindzola wrote: > I have figured many things out. system works, i just forgot to type > os.system(). I have been looking into the os module and am finding alot > of useful stuff. I still need to workout the best way to ask a user for > a root password, show when typed and then pass it

Re: [Tutor] Send attachment

2005-07-23 Thread Martin Walsh
Jorge Louis De Castro wrote: > Hello, > > Any ideas how I can use Python and the Windows API to open a PC's mail > client and send an attachment? > The idea is saving some data onto a file and then invoke the email > client (OE or Outlook or whatever is the default on the machine) with > the r

Re: [Tutor] Quickest way to find a folder on windows

2005-07-26 Thread Martin Walsh
x27;My Documents') 'H:\\My Documents' .>>> os.path.join(os.environ['USERPROFILE'], 'My Documents') 'C:\\Documents and Settings\\martin walsh\\My Documents' as you can see, because of my non-standard setup, I get 2 different results in this i

Re: [Tutor] Help with pysvn

2007-04-16 Thread Martin Walsh
Hi Nam, Pavar, Namratha wrote: > Hi, > > > > I am getting the error "pysvn._pysvn.ClientError: callback_get_login > required" when I try to do a simple exercise using pysvn. I have made > sure the subversion config file doesn't have the "store-auth-creds = no" > . > > I would appreciate any h

Re: [Tutor] IDE / development environment

2007-04-22 Thread Martin Walsh
Eike Welk wrote: > On Sunday 22 April 2007 10:51, Rohan Deshpande wrote: >> What does everyone use as their development environment for Python, >> particularly web dev? > > I use PyDev an extension for Eclipse: > http://pydev.sourceforge.net/ +1 for pydev. The additional plugins (wtp, aptana, and

Re: [Tutor] screen scraping without the request

2007-04-22 Thread Martin Walsh
Hi Rohan, You might also try the LiveHTTPHeaders firefox extension, it is also very good for this type of reverse engineering. http://livehttpheaders.mozdev.org/index.html HTH, Marty Luke Paireepinart wrote: > Kent Johnson wrote: >> Rohan Deshpande wrote: >> >>> Hi All, >>> >>> the previous

Re: [Tutor] + converted to 25 in http string

2007-04-24 Thread Martin Walsh
Hi, govind goyal wrote: > Hi, > > I am using http to automate my Access point(AP) configuration where I sent > following strings to AP server through script. > > params = urllib.urlencode > ({'WRegion':"USA",'ssid':"wifi",'ap':"ap",'ssid_enable':"ssid_enable",* > 'wire_mode':"b+only",* > 'w_chan

Re: [Tutor] Socket question.

2007-05-16 Thread Martin Walsh
Hey Dude :) Dude, WHOA! wrote: > kinda thing. The problem is that the client I wrote doesn't receive > data and display it, and it also only executes single word commands. > Server side: > #!/usr/bin/env python > try: > echo = Popen(command, stdout=PIPE).stdout.read() On a

Re: [Tutor] Continue Matching after First Match

2007-05-20 Thread Martin Walsh
Hi Tom, Tom Tucker wrote: > Why the cStringIO stuff? The input data shown below is collected from > os.popen. I was trying to find an easy way of matching my regex. Ah, ldap... > Matching with a string seemed easier than looping through the ouput > collected. Hmm. Come to think of it, I gu

Re: [Tutor] question re: executing exe files with arguments

2007-05-20 Thread Martin Walsh
Hey Janani, Janani Krishnaswamy wrote: > Hi! > I am having trouble executing an exe file with 3 arguments within a > python script. Right now I have something like this: > > os.system(r'"1/2/3/program 1/2/3/argument1 1/2/3/argument2"') Without an error message, or traceback, this is difficult t

Re: [Tutor] ActivePython and CPython

2007-05-20 Thread Martin Walsh
Alan Gauld wrote: > <[EMAIL PROTECTED]> wrote >> Answer: PyDev for Eclipse turns Eclipse into a pretty good IDE for >> Python. > > Agreed, I downloaded pydev over the weekend and have been > playing. The editor isn't exactly vim/emacs but its as good as > IDLE/Pythonwin > > However I think th

Re: [Tutor] MS SQL Connection

2007-05-21 Thread Martin Walsh
Kent Johnson wrote: > Leon Keylin wrote: >> Thanks Mike, unfortunately that's the mod I had problems with before. >> The one that >> can't do truncate. I've written about it before here and it was easier >> to look for >> another solution. > > You could try adodbapi > http://adodbapi.sourceforge

Re: [Tutor] example of spawn

2007-06-05 Thread Martin Walsh
Jason Coggins wrote: > In the example listed below, reproduced from the web page you recommended, > what does `cp`, `cp` and `/dev/null` do? I am assuming `index.html` is the > name of the program that will be launched. > > example:-- > os.spawnlp(os.

Re: [Tutor] CGI error

2007-07-14 Thread Martin Walsh
Hi Darren, Darren Williams wrote: > Hi all Smile > > I have a Windows hosting account with lunarpages.com and am having a bit > of trouble with CGI. I have enabled both CGI and Python in the control > panel and made sure the permissions for all my CGI scripts are set to > both readable and execu

Re: [Tutor] Getting Date/Time from a file and using it in calculations

2007-08-15 Thread Martin Walsh
[EMAIL PROTECTED] wrote: > Hello there > > Messing around with certain time and datetime objects, I have managed to > subtract a date/time from the present time thusly: > > from time import * > import datetime > > one = datetime.datetime.now() > two = datetime.datetime(2007, 8, 29, 11, 15, 00)

Re: [Tutor] CGI File Woes

2007-09-30 Thread Martin Walsh
wormwood_3 wrote: >>> I've never used cgitb (and until now didn't know it existed!) >>> so can't comment. > > I had not heard of it until this week when I started working on CGI stuff, > but I have found it super handy! All you have to do it "import cgitb; > cgitb.enable()" and all tracebacks wi

Re: [Tutor] CGI File Woes

2007-09-30 Thread Martin Walsh
iew the server logs. And the person helping me knew nothing > about Python (he kept slipping and calling it PHP actually, to my dismay and > chagrin:-) ). > > Thanks for all the help, Alan and Martin. > > -Sam > > _ > - Original Message > From:

Re: [Tutor] Really basic web templating

2007-10-01 Thread Martin Walsh
wormwood_3 wrote: > Well yes and no:-) This sort of application would fall under the > sprawling category of CGI, yes, and I can use Python scripts on my web > server, so it is supported. But nearly every tutorial I have seen > regarding Python and CGI only have to do with form submissions, doing >

[Tutor] OT: webhosting

2007-10-01 Thread Martin Walsh
wormwood_3 wrote: > There was another host that I wanted to mention along these lines (for Python > sites) that I think is even better: VPSLink (http://www.vpslink.com). They > allow root SSH access, and can install your choice of OS (lots of linux > flavors, ubuntu, SUSE, CentOS, etc) from a co

Re: [Tutor] "standard output: Broken pipe"

2007-10-20 Thread Martin Walsh
James wrote: > Hi, > > I have a snippet of code in a Python script I'm whipping up that's > causing a not-so-pretty output. Here's the code: > > subprocess.call( "yes '' | make oldconfig" , shell=True ) > > When I run this code, Python loyally executes the command, and then I > see the foll

Re: [Tutor] "standard output: Broken pipe"

2007-10-21 Thread Martin Walsh
James wrote: > Given this explanation, it's probably not a great idea to use > signal.signal() then. ;) In this case, it seems to me that setting the SIG_DFL action for SIGPIPE is precisely what one would want to do. This is pure speculation, but if you were to re-implement some of the subproc

Re: [Tutor] "standard output: Broken pipe"

2007-10-21 Thread Martin Walsh
Michael Langford wrote: > > This signal is not something you care about. All SIGPIPE means is that > the source of the signal found itself writing to a pipe with no sender. > Your line "signal.signal(signal.SIGPIPE, signal.SIG_DFL)" means use the > default signal handler for SIGPIPE. While this w

Re: [Tutor] Looping + Variables

2007-10-21 Thread Martin Walsh
James wrote: > Hi. :) > > I'm trying to write a loop to simplify my life (and code :)). The > loop is going to iterate over a list of values that I have to change > in a file. I think my problem is better described with some code. :) Use a dictionary instead of a tuple ... # variables editVal

Re: [Tutor] "standard output: Broken pipe"

2007-10-22 Thread Martin Walsh
Eric Brunson wrote: > I'm coming in late to the discussion and thought that someone would > explain it succinctly, but there have been so many correct statements > which I feel fail to nail down the problem that I thought I'd chime in. > Hi Eric, Thank you for your considerate response. Your a

Re: [Tutor] "standard output: Broken pipe"

2007-10-22 Thread Martin Walsh
Eric Brunson wrote: > Martin Walsh wrote: >> Michael Langford wrote: >> I don't think this is quite right, but please correct me if I'm >> misinformed, or just plain wrong. :) >> >> Using "signal.signal(signal.SIGPIPE, signal.SIG_IGN)" (kernel

Re: [Tutor] Wrong version of Python being executed

2007-11-10 Thread Martin Walsh
Tony Cappellini wrote: >>> What do you get if you print sys.path from >> the interpreter? > > I've printed out sys.path from inside the script as well, > and all references to Python25 are replaced with Python23 > > > FWIW- This isn't a problem unique to this script. > I've just printed out sys.

Re: [Tutor] Wrong version of Python being executed

2007-11-11 Thread Martin Walsh
Tony Cappellini wrote: > Martin Walsh mwalsh at groktech.org > Sun Nov 11 06:13:10 CET 2007 > >>> That is odd. > >>> Try using the full path to python, just to be sure: c:\python25\python >>> script.py -- do you get the same behavior? > This works jus

Re: [Tutor] Wrong version of Python being executed

2007-11-12 Thread Martin Walsh
Alan Gauld wrote: > "Tony Cappellini" <[EMAIL PROTECTED]> wrote > >> I have to switch between 2.3 and 2.5, so to make it easy, I use an >> environment variable called CURRENT_PYTHON. >> (someone on this list or the wxPython list told me I should NOT use >> PYTHONPATH and modify it the way I am usi

Re: [Tutor] subprocess help, nohup

2007-11-18 Thread Martin Walsh
John wrote: > Hello, Hi John, I didn't see a response to your question, so I'll make an attempt ... > > I've written a script which conducts several subprocess calls and then > ultimately calls a shell script which runs even more programs... my > script is using subprocess to execute a few sed

Re: [Tutor] Python on T-Mobile Wing???

2007-11-21 Thread Martin Walsh
Trey Keown wrote: > Hey all, > I just got a brand new T-Mobile Wing, and, as you might guess, I want to > install python on it. Well, I tried both the pythonce main build (with the > .exe), and the build for the smartphone (also used .exe), but once I > downloaded them, when I tried to run them, a

Re: [Tutor] Selecting a browser

2007-12-01 Thread Martin Walsh
Ricardo Aráoz wrote: > Hi, I've checked webbrowser module and so far I find no way of selecting > a browser other than the default one. Say I want certain places opened > with IE and others with Mozilla, and I don't want to mess with the > user's setting of the default browser. Any tips? > TIA I t

Re: [Tutor] Selecting a browser

2007-12-03 Thread Martin Walsh
Ricardo Aráoz wrote: > Martin Walsh wrote: > Hi Marty, thanks for your help. > I've tried your suggestions but they don't seem to work for me. In W's > system window I can do : > C:/> S:\FirefoxPortable\FirefoxPortable.exe http://www.google.com > and it will op

Re: [Tutor] Output of list

2007-12-22 Thread Martin Walsh
Ricardo Aráoz wrote: > Emil wrote: >> hey >> >> I want to be capable of converting a string into a list where all the items, >> in the list, have a fixed length not equal to 1 e.g i have k = 'abcdefgh' >> and I want the fixed length for all the the items to be 2 then the list >> would look like

Re: [Tutor] Output of list

2007-12-23 Thread Martin Walsh
János Juhász wrote: > It is nice place to use a generator: > > def pairs(sliceit): > streamlist = list(sliceit) > streamlist.reverse() > while streamlist: > pair = streamlist.pop() > try:pair += streamlist.pop() > except: pass > yield pair > > ##

Re: [Tutor] Output of list

2007-12-23 Thread Martin Walsh
János Juhász wrote: > Dear Marty, Hi Janos, >> ... Or, by extending Alan's solution ... >> >> def splitStringByN(s, n): >>for m in range(0, len(s), n): >>yield s[m:m+n] >> >> k = 'abcdefghi' >> list(splitStringByN(k, 2)) > > It seems to be the most readable solution for me. For comp

Re: [Tutor] Processing unix style timestamp

2008-03-07 Thread Martin Walsh
Ravi Kondamuru wrote: > Hi, > > I have a log file that prints the date and time in the following format: > Mon Feb 11 01:34:52 CST 2008 > I am expecting multiple timezone entries (eg: PST, PDT and GMT) on the > system running in America/Los Angeles time zone. > I am looking for a way to internally

Re: [Tutor] SSH commands in Python on Linux

2005-08-10 Thread Martin Walsh
Bernard Lebel wrote: > Hello, Hi Bernard, > I'm trying to make a script to send a SSH command from a Linux > computer to another Linux compter. > > The Python syntax I'm using... > > > import os > os.system( 'ssh [EMAIL PROTECTED] "ls"' ) > > > Now the problem is that I'm always asked for th

Re: [Tutor] how to get response from os.system()

2008-03-17 Thread Martin Walsh
Hi Nathan, Nathan McBride wrote: > Yup I use the pexpect module for a lot however couldn't get 'pexpect.run' to > work with mysqldump piping to gzip > Just to hazard a guess -- when you want to pipe commands with pexpect you have to spawn ('run', it seems, would work the same way) the shell c

Re: [Tutor] PyMOTW: difflib

2008-04-06 Thread Martin Walsh
Dick Moores wrote: > See < http://blog.doughellmann.com/2007/10/pymotw-difflib.html> > > And my try with the Differ example, < > http://py77.python.pastebin.com/f41ec1ae8>, which also shows the error, > > "E:\Python25\pythonw.exe" -u "E:\PythonWork\demo_pymotw-difflib.py" > Traceback (most recent

Re: [Tutor] urllib2.urlopen(url)

2008-04-20 Thread Martin Walsh
Monika Jisswel wrote: > Hi, > > can i stop urllib2.urlopen() from following redirects automatically ? It doesn't answer your question directly, but if you care more about the initial request/response than the content at the other end of a redirect -- you can use httplib. It might look something

Re: [Tutor] seeking help to a problem w/ sockets

2008-04-27 Thread Martin Walsh
James Duffy wrote: > I have a problem w/ a file transfer receiver. They way it works is it > binds a port for incoming transfer , when the file transfer is complete. > It closes the connection and the socket, then loops back and restarts > the bind and listen. I have it set so that the socket is re

Re: [Tutor] free loop device

2008-05-06 Thread Martin Walsh
Nathan McBride wrote: > Yup, I got some help in IRC. What I ended up doing was using regex to > pull out each "/dev/loopX". Then > took the X and fed it to max which in turn gave me the highest numbered > loop device in use. After which I > then just added 1 to X and added it to the end of "/dev

Re: [Tutor] Logging module

2008-05-10 Thread Martin Walsh
Dick Moores wrote: > But how to use the logging module to log the report of the screw up? > Right now I don't care about the various levels. I just want to get > something into a log file. > > Hellmann suggest this: > > import logging > LOG_FILENAME = '/tmp/logging_example.out' > logging.basicCon

Re: [Tutor] How to get a string from a DOM Text node ?

2008-05-25 Thread Martin Walsh
Zameer Manji wrote: > I'm trying to extract some information from the following xml file: > http://pastebin.ca/1029125 > > file = "Music.xml" > dict = plist.childNodes[1] #dict contains App version and stuff, as well You really should try to avoid rebinding built-in names, like dict and file, t

Re: [Tutor] Modifying files in a directory.

2008-05-29 Thread Martin Walsh
[EMAIL PROTECTED] wrote: >.>> soup = BeautifulSoup(html) >.>> ord_tbl_price = soup.find('td', {'class': 'order_tbl_price'}) >.>> ord_tbl_price > $32.66 > > So now, how do I reduce the price by 15% and write it back to the > document? Not sure if this is the right way, but it seems to work for m

  1   2   >