[Tutor] Capturing and parsing over telnet

2008-11-30 Thread Stephen Nelson-Smith
I want to write a program that connects to a TCP port using telnet, and issues commands, parsing the output the command provides, and then issuing another command. This might look like this: $ telnet water.fieldphone.net 7456 Welcome to water, enter your username >_ sheep Enter your password >_ s

Re: [Tutor] Capturing and parsing over telnet

2008-11-30 Thread David
Stephen Nelson-Smith wrote: > I want to write a program that connects to a TCP port using telnet, > and issues commands, parsing the output the command provides, and then > issuing another command. > > This might look like this: > > $ telnet water.fieldphone.net 7456 > Welcome to water, enter you

Re: [Tutor] Capturing and parsing over telnet

2008-11-30 Thread Stephen Nelson-Smith
Hi, > How about pexpect; > http://www.noah.org/wiki/Pexpect Ah yes - I've used that before to good effect. ATM I'm playing with telnetlib. Is there a way to read everything on the screen, even if I don't know what it will be? eg: c = telnetlib.Telnet("test.lan") c.read_until("name: ") c.write(

Re: [Tutor] Capturing and parsing over telnet

2008-11-30 Thread Stephen Nelson-Smith
Hi, > I effectively want something like c.read_everything() Looks like read_very_eager() does what I want. S. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] attribute of built-in type

2008-11-30 Thread Kent Johnson
On Sat, Nov 29, 2008 at 5:09 PM, spir <[EMAIL PROTECTED]> wrote: > Kent Johnson a écrit : >> On Fri, Nov 28, 2008 at 6:01 PM, spir <[EMAIL PROTECTED]> wrote: >>> Kent Johnson a écrit : >> OK, functions (and methods, which are also functions, both of which >> are instances of some builtin type), cla

Re: [Tutor] Text Scatter Plots?

2008-11-30 Thread Kent Johnson
On Mon, Sep 29, 2008 at 6:34 AM, Wayne Watson <[EMAIL PROTECTED]> wrote: > Is there a text graphics module that does say scatter plots or histograms? > I'm thinking of stuff prior to the graphics era of computing. I'm looking > for something really simple. Not simple but maybe helpful: http://www-

[Tutor] Reading gzip files

2008-11-30 Thread Dinesh B Vadhia
I'm reading gzip files and writing the content out to a text file line by line. The code is simply: import gzip list_zipfiles = dircache.listdir(zipfolder) writefile = "out_file.txt" fw = open(writefile, 'w') for ziparchive in list_zipfiles: zfile = gzip.GzipFile(zipfolder + ziparchive, "r

Re: [Tutor] Reading gzip files

2008-11-30 Thread Alan Gauld
"Dinesh B Vadhia" <[EMAIL PROTECTED]> wrote I'm reading gzip files and writing the content out to a text file line by line. File "C:\Python25\lib\gzip.py", line 275, in _read self._read_eof() File "C:\Python25\lib\gzip.py", line 311, in _read_eof raise IOError, "CRC check failed" IOErr

Re: [Tutor] Reading gzip files

2008-11-30 Thread David
Dinesh B Vadhia wrote: > I'm reading gzip files and writing the content out to a text file line > by line. The code is simply: > > import gzip > list_zipfiles = dircache.listdir(zipfolder) > writefile = "out_file.txt" > fw = open(writefile, 'w') > > for ziparchive in list_zipfiles: > zfil

Re: [Tutor] Reading gzip files

2008-11-30 Thread David
David wrote: > #!/usr/bin/python > import tarfile > tFile = tarfile.open("/home/david/zip_files/zip.tar.gz", "r") > for f in tFile.getnames(): > print f > tFile.close() > #fname = "out.txt" > #fobj = open(fname, 'w') > #for line in f: > #fobj.write(line + '/n') > #tFile.close() > #fobj

Re: [Tutor] Reading gzip files

2008-11-30 Thread Dinesh B Vadhia
Hi Alan A bunch of gzipped files are read with the majority working but a few don't. I don't know if these files were originally zipped with gzip but I'd guess that they were. Strangely, for the files that don't work I can read/print the file almost to the end and then it falls over with the