Last active 1748863654

nithir's Avatar nithir revised this gist 1748863654. Go to revision

No changes

nithir's Avatar nithir revised this gist 1728457499. Go to revision

1 file changed, 28 insertions

ftp.py(file created)

@@ -0,0 +1,28 @@
1 + #!/usr/bin/python3
2 + # -*- coding: utf-8 -*-
3 +
4 + import ftplib
5 +
6 + host = 'ftp.redhat.com'
7 + username = 'anonymous'
8 + password = 'xxx@gmail.com'
9 +
10 + with ftplib.FTP(host, username, password) as ftp :
11 + print('Entrée à la racine du ftp')
12 + ftp.dir()
13 + DIR='./redhat/linux/beta/SAM/SRPMS'
14 + print('Déplacement dans le répertoire "%s"'%DIR)
15 + ftp.cwd(DIR)
16 + ftp.dir()
17 + FILE='thumbslug-deps-0.0.8-1.el6.src.rpm'
18 + print('Téléchargement du fichier %s'%FILE)
19 + print("%s : "%FILE, end="")
20 + def ecrire(data):
21 + print(".", end="")
22 + fp.write(data)
23 + with open(FILE, 'wb') as fp:
24 + ftp.retrbinary('RETR %s'%FILE, ecrire)
25 + #ftp.retrbinary('RETR %s'%FILE, fp.write)
26 + print()
27 + # fin de session | pas necessaire grace au with
28 + #ftp.quit()
Newer Older