Best Way to Handle All Exceptions

2009-07-13 Thread seldan24
Hello, I'm fairly new at Python so hopefully this question won't be too awful. I am writing some code that will FTP to a host, and want to catch any exception that may occur, take that and print it out (eventually put it into a log file and perform some alerting action). I've figured out two diff

Re: Best Way to Handle All Exceptions

2009-07-13 Thread seldan24
On Jul 13, 10:33 am, MRAB wrote: > seldan24 wrote: > > Hello, > > > I'm fairly new at Python so hopefully this question won't be too > > awful.  I am writing some code that will FTP to a host, and want to > > catch any exception that may occur, take that

Python Equivalent for dd & fold

2009-07-15 Thread seldan24
Hello, I have a shell script, that I'm attempting to convert to Python. It FTP's files down from an AS/400 machine. That part is working fine. Once the files arrive, the script converts them from EBCDIC to ASCII and then formats their line width based on a pre-determined size. For example, if I

Re: Python Equivalent for dd & fold

2009-07-15 Thread seldan24
On Jul 15, 12:47 pm, Michiel Overtoom wrote: > seldan24 wrote: > > what can I use as the equivalent for the Unix 'fold' command? > > def fold(s,len): >      while s: >          print s[:len] >          s=s[len:] > > s="A very long string indeed. Reall

Re: Python Equivalent for dd & fold

2009-07-16 Thread seldan24
On Jul 15, 1:48 pm, Emile van Sebille wrote: > On 7/15/2009 10:23 AM MRAB said... > > >> On Jul 15, 12:47 pm, Michiel Overtoom wrote: > >>> seldan24 wrote: > >>>> what can I use as the equivalent for the Unix 'fold' command? > >>>

Using a Callback Function - ftplib

2009-08-17 Thread seldan24
Hello, I'm utterly confused by something which is most likely trivial. I'm attempting to connect to an FTP server, retrieve a list of files, and store than in an array. I.e.: import ftplib ftp = ftplib.FTP(server) ftp.login(user, pass) ftp.cwd(conf['testdir']) ftp.retrlines('NLST ' + "testfile

Re: Using a Callback Function - ftplib

2009-08-17 Thread seldan24
On Aug 17, 1:51 pm, David <71da...@libero.it> wrote: > Il Mon, 17 Aug 2009 10:43:33 -0700 (PDT), seldan24 ha scritto: > > > Hello, > > > I'm utterly confused by something which is most likely trivial.  I'm > > attempting to connect to an FTP server, retr

Re: Using a Callback Function - ftplib

2009-08-19 Thread seldan24
On Aug 18, 6:02 am, Nitebirdz wrote: > On Mon, Aug 17, 2009 at 11:10:25AM -0700, seldan24 wrote: > > > I didn't even notice the higher level methods.  I changed the > > retrieval line to: > > > ftp.nlst("testfile*.txt") > > > This works great.