File: upload.py

package info (click to toggle)
zope-devguide 20011206-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 456 kB
  • ctags: 45
  • sloc: python: 152; makefile: 124; sh: 54
file content (60 lines) | stat: -rw-r--r-- 1,131 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python
import sys
import os
from ftplib import FTP
from glob import glob
from getpass import getpass

if not sys.argv[1:]:
    print """
Usage: upload.py <username>

Uploads the Developer's Guide in DTML format to Zope.org given a
username and password.

Make sure you first build the DTML files with the dtml.py script.
"""
    sys.exit(1)
    
username=sys.argv[1]
password=getpass()

print "Connecting"
ftp=FTP('ftp.zope.org', username, password)
ftp.set_pasv(1)

ftp.cwd('/Documentation/ZDG')
for file in glob('*.dtml'):
    print "Uploading %s" % file
    f=open(file, 'rb')
    ftp.storbinary('STOR %s' % file, f, 1024)
    f.close()
    
ftp.cwd('/Documentation/ZDG/Figures')
os.chdir('Figures')
for file in glob('*.png'):
    print "Uploading %s" % file
    f=open(file, 'rb')
    ftp.storbinary('STOR %s' % file, f, 1024)
    f.close()

ftp.cwd('/Documentation/ZDG/examples')
os.chdir('../examples')
for file in glob('*.py') + glob('*.tgz'):
    print "Uploading %s" % file
    f=open(file, 'rb')
    ftp.storbinary('STOR %s' % file, f, 1024)
    f.close()

print "Closing"    
ftp.quit()