| 1 |
ftputil 1.1 is released. You can find it at |
|---|
| 2 |
http://www.ndh.net/home/sschwarzer/python/python_software.html . |
|---|
| 3 |
|
|---|
| 4 |
ftputil provides a higher-level interface for FTP sessions than the |
|---|
| 5 |
ftplib module. FTP servers can be accessed via an interface similar to |
|---|
| 6 |
os and os.path. Remote files are accessible as file-like objects. |
|---|
| 7 |
|
|---|
| 8 |
New since version 1.0: |
|---|
| 9 |
|
|---|
| 10 |
- ftputil now runs under Python 2.1+ (not only 2.2+). |
|---|
| 11 |
- documentation |
|---|
| 12 |
- conditional upload/download (depending on local and remote file |
|---|
| 13 |
timestamps) |
|---|
| 14 |
- FTPHost.stat follows links |
|---|
| 15 |
- a session factory other than the default, ftplib.FTP, can be given |
|---|
| 16 |
in the FTPHost constructor; this allows to use classes derived from |
|---|
| 17 |
ftplib.FTP (like ftpslib.FTP_TLS from the M2Crypto package) |
|---|
| 18 |
- several bugfixes (mostly regarding byte count in text mode |
|---|
| 19 |
transfers) |
|---|
| 20 |
- unit test |
|---|
| 21 |
|
|---|
| 22 |
Stefan |
|---|
| 23 |
---------------------------------------------------------------------- |
|---|
| 24 |
Hello Pythoneers :) |
|---|
| 25 |
|
|---|
| 26 |
I would like to announce ftputil.py, a module which provides a |
|---|
| 27 |
more friendly interface for FTP sessions than the ftplib module. |
|---|
| 28 |
|
|---|
| 29 |
The FTPHost objects generated from it allow many operations similar |
|---|
| 30 |
to those of os and os.path. Examples: |
|---|
| 31 |
|
|---|
| 32 |
# download some files from the login directory |
|---|
| 33 |
import ftputil |
|---|
| 34 |
host = ftputil.FTPHost('ftp.domain.com', 'user', 'secret') |
|---|
| 35 |
names = host.listdir(host.curdir) |
|---|
| 36 |
for name in names: |
|---|
| 37 |
if host.path.isreg(name): |
|---|
| 38 |
host.download(name, name, 'b') # remote, local, binary mode |
|---|
| 39 |
|
|---|
| 40 |
# make a new directory and copy a remote file into it |
|---|
| 41 |
host.mkdir('newdir') |
|---|
| 42 |
source = host.file('index.html', 'r') # file-like object |
|---|
| 43 |
target = host.file('newdir/index.html', 'w') # file-like object |
|---|
| 44 |
host.copyfileobj(source, target) # mimics shutil.copyfileobj |
|---|
| 45 |
source.close() |
|---|
| 46 |
target.close() |
|---|
| 47 |
|
|---|
| 48 |
Even host.path.walk works. :-) But slow. ;-) |
|---|
| 49 |
|
|---|
| 50 |
ftputil.py can be downloaded from |
|---|
| 51 |
http://www.ndh.net/home/sschwarzer/download/ftputil.py |
|---|
| 52 |
|
|---|
| 53 |
I would like to get your suggestions and comments. :-) |
|---|
| 54 |
|
|---|
| 55 |
Stefan |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
P.S.: Thanks to Pedro Rodriguez for his helpful answer to my question |
|---|
| 59 |
in comp.lang.python :-) |
|---|
| 60 |
---------------------------------------------------------------------- |
|---|