17.12.2012 Views

Programmation PYTHON - Zenk - Security - Repository

Programmation PYTHON - Zenk - Security - Repository

Programmation PYTHON - Zenk - Security - Repository

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

md(dirname) -> résultat<br />

Supprime le répertoire dirname.<br />

storbinary(commande, file[, blocksize])<br />

Principaux modules<br />

CHAPITRE 8<br />

Envoie un fichier pointé par un objet file ouvert en lecture. commande est de la<br />

forme « STOR nom fichier », blocksize détermine la taille du tampon de lecture<br />

(8192 par défaut). Le fichier est envoyé en mode binaire.<br />

storlines(commande, file)<br />

Équivalente à storbinary, pour les fichiers texte. Envoie le contenu du fichier ligne<br />

à ligne.<br />

Session FTP<br />

>>> import ftplib<br />

>>> ftp = ftplib.FTP('localhost')<br />

>>> ftp.getwelcome()<br />

'220 ProFTPD 1.2.10 Server (ProFTPD Default Installation) [127.0.0.1]'<br />

>>> ftp.login('tziade', 'xxx')<br />

'230 User tziade logged in.'<br />

>>> ftp.dir()<br />

-rw-r--r-- 1 (?) tziade 4704 Jul 27 19:58 5505.tgz<br />

-rw-rw-r-- 1 (?) tziade 473 Feb 15 2005 backup.sh<br />

-rw-r--r-- 1 (?) tziade 292694 Mar 27 22:09<br />

enigmail-0.91.0-tb-linux.xpi<br />

-rw-rw-r-- 1 (?) tziade 10315 Jan 3 2005 install.py<br />

-rw-r--r-- 1 (?) tziade 9269 May 3 14:05 log.txt<br />

drwxr-xr-x 13 (?) tziade 4096 Jul 11 23:37 server<br />

drwxr-xr-x 2 (?) tziade 4096 Jul 11 23:37 www<br />

>>> ftp.quit()<br />

'221 Goodbye.'<br />

En un mot...<br />

Cette première série de modules constitue une bonne trousse à outils pour la programmation<br />

système. Le prochain chapitre aborde des modules plus orientés sur la<br />

programmation.<br />

263

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!