#!/usr/bin/env python2 # usage="""usage: %prog [options] url Get the documentation package out of the repository and install it on a web page. """ import os import re import sys import optparse import commands def System(command, forcerun=False): """Run a command if this isn't a dry run. The dryrun argument """ if options.trace: print "Trace: " + command if not options.DryRun or forcerun: os.system(command) def CommandOutput(command, forcerun=False): """Run a command if this isn't a dry run.""" if options.trace: print "Trace: " + command if not options.DryRun or forcerun: return commands.getoutput(command) def CMTGetVersion(package,output): """Return the available version of a package. The most recent is first""" version = None if output == None: try: versions = os.listdir("./" + package) versions.sort() version = versions.pop(0) except: version = None else: print output match = re.search(r"^# ==* .* version ([\w]*)",output) version=match.group(1) return version def CMTCheckout(package,version=None): if version == '': version = None if version == None: output = CommandOutput("cmt checkout %s" % (package) ) else: output = CommandOutput("cmt checkout -r %s %s" %(version,package)) version = CMTGetVersion(package,output) if version == None: print "**** Package %s not found" % (package) else: print "Using package %s version %s" %(package,version) return version def CMTGetRequirements(package,version): """Return a list of the requirements for a package. This only returns the explicit requirements.""" try: filename = "/".join((".",package,version,"cmt/requirements")) input = file(filename).read() except: input = "" requirements = re.findall(r"(?m)^ *use *([\w]*) *([\w]*).*$",input) return requirements ############################################################# # START THE REAL SCRIPT # Parse the options for this installation. parser = optparse.OptionParser(usage=usage) parser.add_option("-d","--dry-run", dest="DryRun", action = "store_true", default=False, help="do a dry run without running the actual commands") parser.add_option("--trace",action="store_true", dest="trace", default=True, help="print commands before executing them") parser.add_option("-t", "--no-trace",action="store_false", dest="trace", help="don't print commands before executing them") parser.add_option("-V", "--version", dest="version", default=None, help="specify the version of the documentation") (options, args) = parser.parse_args() if 0 COMET Software Documentation This is a redirection to the main documentation page. If this doesn't update automatically, you can jump directly to the main page. """ % (IcedustDocVersion,IcedustDocVersion)) index.close()