]> scripts.mit.edu Git - wizard.git/commitdiff
Rename/remove commands and modules.
authorEdward Z. Yang <ezyang@mit.edu>
Tue, 18 Aug 2009 18:40:25 +0000 (14:40 -0400)
committerEdward Z. Yang <ezyang@mit.edu>
Tue, 18 Aug 2009 18:43:36 +0000 (14:43 -0400)
- Renamed 'wizard massmigrate' to 'wizard mass-migrate'
- Removed 'wizard info'
- Renamed wizard.log to wizard.old_log
- Fix bug in wizard.shell._async

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
TODO
bin/wizard
wizard/command/info.py [deleted file]
wizard/command/mass_migrate.py [moved from wizard/command/massmigrate.py with 97% similarity]
wizard/deploy.py
wizard/old_log.py [moved from wizard/log.py with 100% similarity]
wizard/shell.py
wizard/util.py

diff --git a/TODO b/TODO
index 53e33c42c2b21fea6855086940afe4151d49dfc1..42aa9bfef3afb06160f68530f341ad42c9efa877 100644 (file)
--- a/TODO
+++ b/TODO
@@ -6,7 +6,6 @@ TODO NOW:
   installs
 - Push su code to migrate, not mass-migrate (only do it
   as root, this serves as a safe guard)
-- Rename massmigrate to mass-migrate
 - Move migration code into Wizard, since we already deal
   with installation there anyway (this TODO has been updated
   accordingly)
@@ -14,7 +13,9 @@ TODO NOW:
 - Make parallel-find.pl use `sudo -u username git describe --tags`
   to determine version
 - Remove .scripts/version generation in install script
-- Make the installer use 'wizard install'
+- Make the installer use 'wizard install' /or/ do a migration
+  after doing a normal install (the latter makes it easier
+  for mass-rollbacks).
 
 - Better error message if daemon/scripts-security-upd
   is not on scripts-security-upd list
@@ -25,8 +26,6 @@ TODO NOW:
       this runs the risk of filling up the tubes.  Maybe just
       create a log directory and give each process different
       files.
-- Remove log functionality; we don't care about it besides
-  for parsing old style installs
 
 - The great initial deploy:
     - Turn on mediawiki new autoinstaller
index 09381a311bee534015172762438edc5a3c5ebf9a..01e7c339c8971d86529ed6ce48b8611cae372684 100755 (executable)
@@ -17,10 +17,9 @@ Wizard is a Git-based autoinstall management system for scripts.
 Its commands are:
     configure       Configures an autoinstall (database, etc) to work
     errors          Lists all broken autoinstall metadata
-    info            Reports information about an autoinstall
     install         Installs an application
     list            Lists autoinstalls, with optional filtering
-    massmigrate     Performs mass migration of autoinstalls of an application
+    mass-migrate    Performs mass migration of autoinstalls of an application
     migrate         Migrate autoinstalls from old format to Git-based format
     prepare-config  Prepares configuration files for versioning
     summary         Generate statistics (see help for subcommands)
diff --git a/wizard/command/info.py b/wizard/command/info.py
deleted file mode 100644 (file)
index 2fd47d2..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-import optparse
-import sys
-import subprocess
-
-from wizard import deploy, log
-
-def main(argv, baton):
-    options, args = parse_args(argv)
-    d = deploy.Deployment(args[0])
-    d.log # force the log to be loaded, to pre-empt errors
-    with PipeToLess():
-        print_log(d, options)
-
-def parse_args(argv):
-    usage = """usage: %prog info [ARGS] DIR
-
-Prints information about an autoinstalled directory,
-including its history and current version."""
-    parser = optparse.OptionParser(usage)
-    parser.add_option("--reverse", dest="reverse", action="store_true",
-            default=False, help="Print entries in chronological order (default is reverse)")
-    options, args = parser.parse_args(argv)
-    if len(args) > 1:
-        parser.error("too many arguments")
-    elif not args:
-        parser.error("must specify directory")
-    return options, args
-
-def print_log(d, options):
-    if options.reverse:
-        dlog = reversed(d.log)
-    else:
-        dlog = d.log
-    for entry in dlog:
-        print "%s %s" % (entry.version.application.name, entry.version.version)
-        print "User: %s" % entry.user
-        print "Date: %s" % entry.datetime.strftime("%a %b %0d %H:%M:%S %Y %z")
-        print
-        info = "Unknown"
-        if isinstance(entry.source, log.TarballInstall):
-            info = "Installed with tarball at:\n%s" % \
-                prettify(entry.source.location)
-        print indent(info, 4)
-        print
-
-class PipeToLess(object):
-    def __enter__(self):
-        self.proc = subprocess.Popen("less", stdin=subprocess.PIPE)
-        self.old_stdout = sys.stdout
-        sys.stdout = self.proc.stdin
-    def __exit__(self, *args):
-        if self.proc:
-            self.proc.stdin.close()
-            self.proc.wait()
-            sys.stdout = self.old_stdout
-
-def prettify(loc):
-    return loc.replace("/afs/athena.mit.edu/contrib/scripts", "~scripts")
-
-def indent(text, indent):
-    # There should be a built-in
-    return "\n".join([" " * indent + x for x in text.split("\n")])
similarity index 97%
rename from wizard/command/massmigrate.py
rename to wizard/command/mass_migrate.py
index 01a178dd8980e06f1c19f39d4eb61c800659b823..cbacff7b11ba62ca453c5f94c3eb13ec9329367d 100644 (file)
@@ -58,7 +58,7 @@ def main(argv, baton):
         logging.warning("%s from %d installs" % (name, len(deploys)))
 
 def parse_args(argv, baton):
-    usage = """usage: %prog massmigrate [ARGS] APPLICATION
+    usage = """usage: %prog mass-migrate [ARGS] APPLICATION
 
 Mass migrates an application to the new repository format.
 Essentially equivalent to running '%prog migrate' on all
@@ -66,7 +66,7 @@ autoinstalls for a particular application found by parallel-find,
 but with advanced reporting.
 
 When doing an actual run, it is recommended to use --seen to
-be able to resume gracefully (without it, massmigrate must
+be able to resume gracefully (without it, mass-migrate must
 stat every install to find out if it migrated it yet).
 
 This command is intended to be run as root on a server with
index 8c694efe2bc941d8da80f7dd072eae7fd95baa37..7ea4ba247f716e62d1d149e13fde96dca3c02301 100644 (file)
@@ -12,7 +12,7 @@ import tempfile
 import logging
 
 import wizard
-from wizard import git, log, util
+from wizard import git, old_log, util
 
 ## -- Global Functions --
 
@@ -74,7 +74,7 @@ class Deployment(object):
         self._app_version = version
         # some cache variables
         self._read_cache = {}
-        self._log = None
+        self._old_log = None
     def read(self, file, force = False):
         """
         Reads a file's contents, possibly from cache unless ``force``
@@ -160,11 +160,14 @@ class Deployment(object):
         """The :class:`Application` of this deployment."""
         return self.app_version.application
     @property
-    def log(self):
-        """The :class:`wizard.deploy.Log` of this deployment."""
-        if not self._log:
-            self._log = log.DeployLog.load(self)
-        return self._log
+    def old_log(self):
+        """
+        The :class:`wizard.old_log.Log` of this deployment.  This
+        is only applicable to un-migrated autoinstalls.
+        """
+        if not self._old_log:
+            self._old_log = old_log.DeployLog.load(self)
+        return self._old_log
     @property
     def version(self):
         """
@@ -181,7 +184,7 @@ class Deployment(object):
                     appname, _, version = git.describe().partition('-')
                 self._app_version = ApplicationVersion.make(appname, version)
             else:
-                self._app_version = self.log[-1].version
+                self._app_version = self.old_log[-1].version
         return self._app_version
     @staticmethod
     def parse(line):
similarity index 100%
rename from wizard/log.py
rename to wizard/old_log.py
index e5cc5062182dcabd276d535c2ac277a8bc8827af..39cd102b153226957c8d74d69373dc73beacccde 100644 (file)
@@ -216,7 +216,7 @@ class ParallelShell(Shell):
         super(ParallelShell, self).__init__(dry=dry)
         self.running = {}
         self.max = max # maximum of commands to run in parallel
-    def _async(self, proc, args, python, on_success, on_error):
+    def _async(self, proc, args, python, on_success, on_error, **kwargs):
         """
         Gets handed a :class:`subprocess.Proc` object from our deferred
         execution.  See :meth:`Shell.call` source code for details.
index 071737ad700d9f179464f74caf7fb23d8ca1c247..61eeed79803591e0e1b954b5e2a2876acd59cded 100644 (file)
@@ -53,6 +53,21 @@ class Counter(object):
     def __iter__(self):
         return self.dict.__iter__()
 
+class PipeToLess(object):
+    """
+    Context for printing output to a pager.  Use this if output
+    is expected to be long.
+    """
+    def __enter__(self):
+        self.proc = subprocess.Popen("less", stdin=subprocess.PIPE)
+        self.old_stdout = sys.stdout
+        sys.stdout = self.proc.stdin
+    def __exit__(self, *args):
+        if self.proc:
+            self.proc.stdin.close()
+            self.proc.wait()
+            sys.stdout = self.old_stdout
+
 def dictmap(f, d):
     """
     A map function for dictionaries.  Only changes values.