5 from wizard import deploy
8 options, args = parse_args(argv)
9 d = deploy.Deployment.fromDir(args[0])
10 d.getLog() # force the log to be loaded, to pre-empt errors
15 usage = """usage: %prog info [ARGS] DIR
17 Prints information about an autoinstalled directory,
18 including its history and current version."""
19 parser = optparse.OptionParser(usage)
20 parser.add_option("--reverse", dest="reverse", action="store_true",
21 default=False, help="Print entries in chronological order (default is reverse)")
22 options, args = parser.parse_args(argv)
24 parser.error("too many arguments")
26 parser.error("must specify directory")
29 def print_log(d, options):
31 log = reversed(d.getLog())
35 print "%s %s" % (entry.version.application.name, entry.version.version)
36 print "User: %s" % entry.user
37 print "Date: %s" % entry.datetime.strftime("%a %b %0d %H:%M:%S %Y %z")
40 if isinstance(entry.source, deploy.TarballInstall):
41 info = "Installed with tarball at:\n%s" % \
42 prettify(entry.source.location)
46 class PipeToLess(object):
48 self.proc = subprocess.Popen("less", stdin=subprocess.PIPE)
49 self.old_stdout = sys.stdout
50 sys.stdout = self.proc.stdin
51 def __exit__(self, *args):
53 self.proc.stdin.close()
55 sys.stdout = self.old_stdout
58 return loc.replace("/afs/athena.mit.edu/contrib/scripts", "~scripts")
60 def indent(text, indent):
61 # There should be a built-in
62 return "\n".join([" " * indent + x for x in text.split("\n")])