push_html(): New function; handles the mechanics of actually pushing the
generated HTML to SourceForge. main(): Adjust to use push_html(), and simplify the logic so it only gets called from one place.
This commit is contained in:
parent
5177e3db51
commit
181d3e68ea
30
pep2html.py
30
pep2html.py
|
@ -166,6 +166,23 @@ def make_html(file, verbose=0):
|
||||||
fixfile(file, newfile)
|
fixfile(file, newfile)
|
||||||
return newfile
|
return newfile
|
||||||
|
|
||||||
|
def push_html(files, username, verbose):
|
||||||
|
if verbose:
|
||||||
|
quiet = ""
|
||||||
|
else:
|
||||||
|
quiet = "-q"
|
||||||
|
if username:
|
||||||
|
username = username + "@"
|
||||||
|
target = username + HOST + ":" + HDIR
|
||||||
|
files.append("style.css")
|
||||||
|
filelist = " ".join(files)
|
||||||
|
rc = os.system("scp %s %s %s" % (quiet, filelist, target))
|
||||||
|
if rc:
|
||||||
|
sys.exit(rc)
|
||||||
|
rc = os.system("ssh %s%s chmod 664 %s/*" % (username, HOST, HDIR))
|
||||||
|
if rc:
|
||||||
|
sys.exit(rc)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# defaults
|
# defaults
|
||||||
|
@ -185,7 +202,7 @@ def main():
|
||||||
elif opt in ('-i', '--install'):
|
elif opt in ('-i', '--install'):
|
||||||
update = 1
|
update = 1
|
||||||
elif opt in ('-u', '--user'):
|
elif opt in ('-u', '--user'):
|
||||||
username = arg + "@"
|
username = arg
|
||||||
elif opt in ('-q', '--quiet'):
|
elif opt in ('-q', '--quiet'):
|
||||||
verbose = 0
|
verbose = 0
|
||||||
|
|
||||||
|
@ -195,20 +212,13 @@ def main():
|
||||||
file = find_pep(pep)
|
file = find_pep(pep)
|
||||||
newfile = make_html(file, verbose=verbose)
|
newfile = make_html(file, verbose=verbose)
|
||||||
html.append(newfile)
|
html.append(newfile)
|
||||||
if update:
|
|
||||||
os.system("scp %s style.css " % " ".join(html) \
|
|
||||||
+ username + HOST + ":" + HDIR)
|
|
||||||
else:
|
else:
|
||||||
# do them all
|
# do them all
|
||||||
for file in glob.glob("pep-*.txt"):
|
for file in glob.glob("pep-*.txt"):
|
||||||
make_html(file, verbose=verbose)
|
make_html(file, verbose=verbose)
|
||||||
if update:
|
html = ["pep-*.html"]
|
||||||
os.system("scp pep-*.html style.css " + \
|
|
||||||
username + HOST + ":" + HDIR)
|
|
||||||
|
|
||||||
if update:
|
if update:
|
||||||
os.system("ssh " + username + HOST + " chmod 664 " + HDIR + "/*")
|
push_html(html, username, verbose)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue