Wizard is a Git-based autoinstall management system for scripts.
Its commands are:
+ errors Lists all broken autoinstall metadata
info Reports information about an autoinstall
+ list Lists autoinstalls, with optional filtering
massmigrate Performs mass migration of autoinstalls of an application
migrate Migrate autoinstalls from old format to Git-based format
summary Generate statistics (see help for subcommands)
import logging
from wizard import deploy, command
-from wizard.command import summary
def main(argv, baton):
options, show = parse_args(argv, baton)
- for e in summary.parse_install_lines(show, options, True):
+ for e in deploy.parse_install_lines(show, options, True):
if not isinstance(e, deploy.Error):
if isinstance(e, Exception):
raise e
print e.location
def parse_args(argv, baton):
- usage = """usage: %prog summary list-errors [ARGS]
+ usage = """usage: %prog errors [ARGS]
Lists all errors that occurred while parsing the versions
directory."""
--- /dev/null
+import logging
+import traceback
+import os.path
+
+from wizard import command, deploy
+
+def main(argv, baton):
+ options, show = parse_args(argv, baton)
+ errors = 0
+ for d in deploy.parse_install_lines(show, options, True):
+ if isinstance(d, Exception):
+ errors += 1
+ if options.exists and not os.path.exists(os.path.join(d.location, options.exists)):
+ continue
+ print d.location
+ if errors:
+ logging.warning("%d errors, see wizard errors for details" % errors)
+
+def parse_args(argv, baton):
+ usage = """usage: %prog list [ARGS] [APP[-VERSION]]
+
+Lists the locations of all autoinstalls, optionally
+filtered on parameters such as application name and version.
+
+Examples:
+ %prog list
+ List all autoinstalls
+ %prog list --exists php.ini
+ List all autoinstalls with php.ini
+ %prog list mediawiki
+ List only MediaWiki autoinstalls
+ %prog list mediawiki-1.11.0
+ List only Mediawiki 1.11.0 autoinstalls"""
+ parser = command.WizardOptionParser(usage)
+ parser.add_option("-e", "--exists", dest="exists",
+ help="only print deployment if FILE exists", metavar="FILE")
+ baton.push(parser, "versions_path")
+ options, args = parser.parse_all(argv)
+ if len(args) > 1:
+ parser.error("too many arguments")
+ return options, args
+
calculates interesting information about them.
Its subcommands are:
- count-exists Counts how many autoinstalls contain a file
- list Prints the locations of all autoinstalls
- list-errors Prints all errors that occurred during parsing
version Breakdown of autoinstalls by version (default)
Use %prog summary SUBCOMMAND --help for more information."""
parser.error("invalid action")
command_module.main(rest_argv, baton)
-## -- some generic helper stuff --
-
-def parse_install_lines(show, options, yield_errors = False):
- if not show: show = deploy.applications()
- show = frozenset(show)
- for line in deploy.getInstallLines(options.versions_path):
- # construction
- try:
- d = deploy.Deployment.parse(line)
- name = d.application.name
- except deploy.NoSuchApplication as e:
- if yield_errors:
- yield e
- continue
- except deploy.Error:
- # we consider this a worse error
- logging.warning("Error with '%s'" % line.rstrip())
- continue
- # filter
- if name + "-" + str(d.version) in show or name in show:
- pass
- else:
- continue
- # yield
- yield d
-
-class Counter(object):
- def __init__(self):
- self.dict = {}
- def count(self, value):
- self.dict.setdefault(value, 0)
- self.dict[value] += 1
- def __getitem__(self, key):
- return self.dict[key]
- def __iter__(self):
- return self.dict.__iter__()
-
+++ /dev/null
-import os
-
-from wizard import command
-from wizard.command import summary
-
-def main(argv, baton):
- options, args = parse_args(argv, baton)
- value = args[0]
- show = args[1:]
- for d in summary.parse_install_lines(show, options):
- if os.path.exists(d.location + "/" + value):
- print d.location
-
-def parse_args(argv, baton):
- usage = """usage: %prog summary count-exists [ARGS] FILE [APP[-VERSION]]
-
-Lists all autoinstalls that contain FILE in their
-working copy.
-
-Examples:
- %prog summary count-exists php.ini
- Finds all autoinstalls that contain php.ini files"""
- parser = command.WizardOptionParser(usage)
- baton.push(parser, "versions_path")
- options, args = parser.parse_all(argv)
- if len(args) > 1:
- parser.error("too many arguments")
- if not args:
- parser.error("need to specify FILE")
- return options, args
-
+++ /dev/null
-import logging
-import traceback
-
-from wizard import command
-from wizard.command import summary
-
-def main(argv, baton):
- options, show = parse_args(argv, baton)
- errors = 0
- for d in summary.parse_install_lines(show, options, True):
- if isinstance(d, Exception):
- errors += 1
- print d.location
- if errors:
- logging.warning("%d errors, see wizard summary list-errors for details" % errors)
-
-def parse_args(argv, baton):
- usage = """usage: %prog summary list [ARGS] [APP[-VERSION]]
-
-Lists the locations of all autoinstalls, optionally
-filtered on application name and version.
-
-Examples:
- %prog summary list
- List all autoinstalls
- %prog summary list mediawiki
- List only MediaWiki autoinstalls
- %prog summary list mediawiki-1.11.0
- List only Mediawiki 1.11.0 autoinstalls"""
- parser = command.WizardOptionParser(usage)
- baton.push(parser, "versions_path")
- options, args = parser.parse_all(argv)
- if len(args) > 1:
- parser.error("too many arguments")
- return options, args
-
import math
-from wizard import command
-from wizard.command import summary
+from wizard import command, deploy, util
def main(argv, baton):
options, show = parse_args(argv, baton)
HISTOGRAM_WIDTH = 30
show = set()
- c_version = summary.Counter()
- c_application = summary.Counter()
- for d in summary.parse_install_lines(show, options):
+ c_version = util.Counter()
+ c_application = util.Counter()
+ for d in deploy.parse_install_lines(show, options):
version = d.app_version
c_version.count(version)
c_application.count(version.application)
return fileinput.input([vs])
return fileinput.input([vs + "/" + f for f in os.listdir(vs)])
+def parse_install_lines(show, options, yield_errors = False):
+ if not show: show = applications()
+ show = frozenset(show)
+ for line in getInstallLines(options.versions_path):
+ # construction
+ try:
+ d = Deployment.parse(line)
+ name = d.application.name
+ except deploy.NoSuchApplication as e:
+ if yield_errors:
+ yield e
+ continue
+ except deploy.Error:
+ # we consider this a worse error
+ logging.warning("Error with '%s'" % line.rstrip())
+ continue
+ # filter
+ if name + "-" + str(d.version) in show or name in show:
+ pass
+ else:
+ continue
+ # yield
+ yield d
+
## -- Model Objects --
class Deployment(object):
def __exit__(self, *args):
os.chdir(self.olddir)
+class Counter(object):
+ def __init__(self):
+ self.dict = {}
+ def count(self, value):
+ self.dict.setdefault(value, 0)
+ self.dict[value] += 1
+ def __getitem__(self, key):
+ return self.dict[key]
+ def __iter__(self):
+ return self.dict.__iter__()
+
def dictmap(f, d):
"""A map function for dictionaries. Does not allow changing keys, only
values"""