Mercurial > treepkg
view publishstaticweb.py @ 69:b52779523392
remove date/author line from README
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Thu, 12 Apr 2007 21:00:10 +0200 |
parents | 57a0b747ea3e |
children | 43e6bdba84e2 |
line wrap: on
line source
#! /usr/bin/python2.4 # Copyright (C) 2007 by Intevation GmbH # Authors: # Bernhard Herzog <bh@intevation.de> # # This program is free software under the GPL (>=v2) # Read the file COPYING coming with the software for details. """Publishes a static web-site with a status report""" import os from optparse import OptionParser from ConfigParser import SafeConfigParser from treepkg.readconfig import read_config_section from treepkg.run import call from treepkg.cmdexpand import cmdexpand def remove_trailing_slashes(s): return s.rstrip("/") staticweb_desc = ["build_user", "build_host", "build_create", ("build_dir", remove_trailing_slashes), "publish_user", "publish_host", ("publish_dir", remove_trailing_slashes), ("cachedir", remove_trailing_slashes)] def read_config(filename): parser = SafeConfigParser() parser.read([filename]) return read_config_section(parser, "staticweb", staticweb_desc) def parse_commandline(): parser = OptionParser() dirname = os.path.dirname(__file__) parser.set_defaults(config_file=os.path.join(dirname, "staticweb.cfg")) parser.add_option("--config-file", help=("The tree packager config file." " Default staticweb.cfg")) return parser.parse_args() def publish_static_site(treepkg_config): config = read_config(treepkg_config) # create web-page on build host call(cmdexpand("ssh $build_user$@$build_host $build_create $build_dir", **config)) # rsync the new web-pages to the local cache call(cmdexpand("rsync -rL --delete $build_user$@$build_host:$build_dir/" " $cachedir", **config)) # rsync the web pages from the local cache to the publishing host call(cmdexpand("rsync -rL --delete $cachedir/" " $publish_user$@$publish_host:$publish_dir", **config)) def main(): options, args = parse_commandline() publish_static_site(options.config_file) main()