Re: users of pycurl here?

2005-10-10 Thread Michele Simionato
The Effbot wrote:
 here's a robust parser for various LIST output formats:

http://cr.yp.to/ftpparse.html

 (google for ftpparse to find python bindings for that module)

Well, I have downloaded the one from your site (ftpparse-1.1-20021124)
and I have given a python setup.py install. Now I have a _ftpparse.so
which exposes a single function 'parse'. However both the module and
the function do not have any docstring,  the underscore makes me
believe that there should be a ftpparse.py file which is missing,
and the README says for a usage example, see the sanity.py test
script but there is not such a script in the distribution :-(

   Michele Simionato

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: users of pycurl here?

2005-10-10 Thread Fredrik Lundh
Michele Simionato wrote:

 the README says for a usage example, see the sanity.py test
 script but there is not such a script in the distribution :-(

looks like a distutils glitch...  try this one:

# $Id$
# minimal sanity check

import string

TESTS = [
# examples taken from ftpparse.c,
+i8388621.29609,m824255902,/,\tdev,
+i8388621.44468,m839956783,r,s10376,\tRFCEPLF,
-rw-r--r--   1 root other531 Jan 29 03:26 README,
dr-xr-xr-x   2 root other512 Apr  8  1994 etc,
dr-xr-xr-x   2 root 512 Apr  8  1994 etc,
lrwxrwxrwx   1 root other  7 Jan 25 00:17 bin - usr/bin,
04-27-00  09:09PM   DIR  licensed,
07-18-00  10:16AM   DIR  pub,
04-14-00  03:47PM  589 readme.htm,
]

import _ftpparse

# parse sample strings
for line in TESTS:
print repr(line), -
try:
item = _ftpparse.parse(line)
except ValueError:
print ***, cannot parse this line
else:
print, (item.name, item.size, item.mtime, item.id, item.trycwd)

# check behaviour for unknown attributes
try:
item.unknown
except AttributeError:
pass

# end

on my machine, this prints:

'# examples taken from ftpparse.c' -
*** cannot parse this line
'+i8388621.29609,m824255902,/,\tdev' -
('dev', None, 824255902, '8388621.29609', True)
'+i8388621.44468,m839956783,r,s10376,\tRFCEPLF' -
('RFCEPLF', 10376, 839956783, '8388621.44468', False)
'-rw-r--r--   1 root other531 Jan 29 03:26 README' -
('README', 531, 1106969160, None, False)
'dr-xr-xr-x   2 root other512 Apr  8  1994 etc' -
('etc', 512, 765763200, None, True)
'dr-xr-xr-x   2 root 512 Apr  8  1994 etc' -
('etc', 512, 765763200, None, True)
'lrwxrwxrwx   1 root other  7 Jan 25 00:17 bin - usr/bin' -
('bin', 7, 1106612220, None, True)
'04-27-00  09:09PM   DIR  licensed' -
('licensed', None, 956869740, None, True)
'07-18-00  10:16AM   DIR  pub' -
('pub', None, 963915360, None, True)
'04-14-00  03:47PM  589 readme.htm' -
('readme.htm', 589, 955727220, None, False)

/F



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: users of pycurl here?

2005-10-10 Thread Michele Simionato
Yes, it works fine, thanks (still I am a bit surprised there is not
ftpparse.py but only
an _ftpparse.so).

  Michele Simionato

-- 
http://mail.python.org/mailman/listinfo/python-list


users of pycurl here?

2005-10-07 Thread Michele Simionato
I am having a hard time in finding out how to retrieve information
about
the *size* of files I want to download from an FTP site. Should I
send a QUOTE SIZE command to the ftp server or is there an easier way?
TIA,

  Michele Simionato

-- 
http://mail.python.org/mailman/listinfo/python-list


RE: users of pycurl here?

2005-10-07 Thread Michael . Coll-Barth

How about doing an 'ls -la' once you have connected to the server?  That
returns a listing of the files with the size in bytes.

-Original Message-
From: Michele Simionato

I am having a hard time in finding out how to retrieve information about the
*size* of files I want to download from an FTP site. Should I send a QUOTE
SIZE command to the ftp server or is there an easier way?
___
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure.  If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof.  Thank you.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: users of pycurl here?

2005-10-07 Thread Fredrik Lundh
Michele Simionato wrote:

 I am having a hard time in finding out how to retrieve information
 about the *size* of files I want to download from an FTP site. Should I
 send a QUOTE SIZE command to the ftp server or is there an easier way?

SIZE isn't a standard FTP command, so that only works for some servers.

if you want your code to work for a wider range of servers, you need to
parse the output from the LIST command:

http://cr.yp.to/ftp/list.html

here's a robust parser for various LIST output formats:

http://cr.yp.to/ftpparse.html

(google for ftpparse to find python bindings for that module)

/F



-- 
http://mail.python.org/mailman/listinfo/python-list