import time
import itertools
import sys
+import shutil
import wizard
from wizard import deploy, util, scripts, shell, sset, command
command.create_logdir(options.log_dir)
seen = sset.make(options.seen)
is_root = not os.getuid()
- report = command.open_reports(options.log_dir, ('lookup', 'warnings', 'errors'), options.redo, ('merge', 'verify'))
+ report = command.open_reports(options.log_dir, ('lookup', 'warnings', 'errors'),
+ options.redo, ('merge', 'verify', 'backup_failure', 'blacklisted'))
# loop stuff
errors = {}
i = 0
- fails = {
- "merge": 0,
- "verify": 0,
- }
deploys = deploy.parse_install_lines(app, options.versions_path, user=options.user)
requested_deploys = itertools.islice(deploys, options.limit)
+ # clean up /dev/shm/wizard
+ if os.path.exists("/dev/shm/wizard"):
+ shutil.rmtree("/dev/shm/wizard")
+ os.mkdir("/dev/shm/wizard")
+ os.chmod("/dev/shm/wizard", 0o777)
try:
for i, d in enumerate(requested_deploys, 1):
report.lookup.write("%04d %s\n" % (i, d.location))
+ report.flush()
# check if we want to punt due to --limit
if d.location in seen:
continue
report.lookup.write("[%04d] %s\n" % (i, d.location))
logging.warning("[%04d] Warnings at [%s]:\n%s" % (i, d.location, stderr))
seen.add(d.location)
+ report.flush()
def on_error(e):
if e.name == "AlreadyUpgraded":
seen.add(d.location)
conflicts, _, tmpdir = e.stdout.rstrip().partition(" ")
logging.warning("[%04d] Conflicts in %d files: resolve at [%s], source at [%s]" % (i, int(conflicts), tmpdir, d.location))
report.merge.write("[%04d] %s %d %s\n" % (i, tmpdir, int(conflicts), d.location))
- fails['merge'] += 1
+ report.fails['merge'] += 1
+ elif e.name == "BlacklistedError":
+ _, _, reason = e.stdout.rstrip().partition(" ")
+ reason = reason.replace("\n", " ")
+ shortmsg = "[%04d] %s %s\n" % (i, d.location, reason)
+ report.blacklisted.write(shortmsg)
+ report.fails['blacklisted'] += 1
+ logging.warning("[%04d] Blacklisted because of '%s' at %s" % (i, reason, d.location))
else:
name = e.name
if name == "WebVerificationError":
# it's a really common error
logging.info("[%04d] Could not verify application at %s" % (i, url))
report.verify.write("[%04d] %s\n" % (i, url))
- fails['verify'] += 1
+ report.fails['verify'] += 1
else:
if name not in errors: errors[name] = []
errors[name].append(d)
msg = "[%04d] %s in %s" % (i, name, d.location)
logging.error(msg)
report.errors.write(msg + "\n")
+ shortmsg = "[%04d] %s\n" % (i, d.location)
+ if name == "BackupFailure":
+ report.backup_failure.write(shortmsg)
+ report.fails['backup_failure'] += 1
+ report.flush()
return (on_success, on_error)
on_success, on_error = make_on_pair(d, i)
sh.call("wizard", "upgrade", d.location, *child_args,
logging.warning("%s from %d installs" % (name, len(deploys)))
def printPercent(description, number, total):
logging.warning("%d out of %d installs (%.1f%%) had %s" % (number, total, float(number)/total*100, description))
- if fails['merge']:
- printPercent("merge conflicts", fails['merge'], i)
- if fails['verify']:
- printPercent("web verification failure", fails['verify'], i)
+ if report.fails['merge']:
+ printPercent("merge conflicts", report.fails['merge'], i)
+ if report.fails['verify']:
+ printPercent("web verification failure", report.fails['verify'], i)
def parse_args(argv, baton):
usage = """usage: %prog mass-upgrade [ARGS] APPLICATION