From 03c6b34d4878e828dda99514941fb586ed886a3a Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sat, 10 Oct 2009 14:37:26 -0400 Subject: [PATCH] Implement quick logging changes. Signed-off-by: Edward Z. Yang --- TODO | 11 +---------- wizard/command/__init__.py | 2 +- wizard/command/upgrade.py | 9 ++++++++- wizard/deploy.py | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index 68aee94..fdf6918 100644 --- a/TODO +++ b/TODO @@ -18,7 +18,7 @@ TODO NOW: doing a size comparison of the tars: `git pull` MUST NOT fail, otherwise things are left conflicted, and not easy to fix. - Prune -7 call errors and automatically reprocess them (with a - strike out counter of 3) + strike out counter of 3)--this requires better error parsing - Snap-in conflict resolution teaching: 1. View the merge conflicts after doing a short run 2. Identify common merge conflicts @@ -33,8 +33,6 @@ TODO NOW: - Distinguish from logging and reporting (so we can easily send mail to users) - - Remove "already migrated" cruft that will accumulate if we do small - --limit and then increase. - Logs aren't actually useful, /because/ most operations are idempotent. Thus, scratch logfile and make our report files more useful: error.log needs error information; we don't care too much about machinability. @@ -43,8 +41,6 @@ TODO NOW: that if we add soft ignores, you /do/ lose information, so there needs to be some way to also have the soft ignore report a "cached error" - Report the identifier number at the beginning of all of the stdout logs - - Log files that already exist should be initialized with some sort - of separator THAT CONTAINS THE LOCATION OF THE INSTALL - Don't really care about having the name in the logfile name, but have a lookup txt file - Figure out a way of collecting blacklist data from .scripts/blacklisted @@ -52,13 +48,8 @@ TODO NOW: - Failed migrations should be wired to have wizard commands in them automatically log to the relevant file. In addition, the seen file should get updated when one of them gets fixed. - - Log files need to have dates, since it looks like upgrades will be - multi-day affairs - Failed migration should report how many unmerged files there are (so we can auto-punt if it's over a threshold) - - Verification failures should be written to a report file, possibly - with short HTML fingerprints so we can inspect them easily and - numbers to look at the log files - Let users use Wizard when ssh'ed into Scripts - Make single user mass-migrate work when not logged in as root diff --git a/wizard/command/__init__.py b/wizard/command/__init__.py index bc1b718..0ba071c 100644 --- a/wizard/command/__init__.py +++ b/wizard/command/__init__.py @@ -42,7 +42,7 @@ def makeLogger(options, numeric_args): else: logger.addHandler(NullLogHandler()) # prevent default if options.log_file: file = logging.FileHandler(options.log_file) - logformatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s", "%H:%M:%S") + logformatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s", "%Y-%m-%d %H:%M") file.setFormatter(logformatter) logger.addHandler(file) if options.debug: diff --git a/wizard/command/upgrade.py b/wizard/command/upgrade.py index da15d56..7cc1412 100644 --- a/wizard/command/upgrade.py +++ b/wizard/command/upgrade.py @@ -47,7 +47,12 @@ def main(argv, baton): repo = d.application.repository(options.srv_path) version = calculate_newest_version(sh, repo) if version == d.app_version.scripts_tag and not options.force: - raise AlreadyUpgraded + # don't log this error + # XXX: maybe we should build this in as a flag to add + # to exceptions w/ our exception handler + sys.stderr.write("Traceback:\n (n/a)\nAlreadyUpgraded\n") + sys.exit(1) + logging.info("Upgrading %s" % os.getcwd()) if not options.dry_run: perform_pre_commit(sh) # If /dev/shm exists, it's a tmpfs and we can use it @@ -88,6 +93,8 @@ def main(argv, baton): except shell.CallError: sh.call("git", "checkout", "-q", "master", "--") sh.call("git", "reset", "-q", "--hard", final_commit) + # This is a quick sanity check to make sure we didn't completely + # mess up the merge d.verifyVersion() # Till now, all of our operations were in a tmp sandbox. if options.dry_run: diff --git a/wizard/deploy.py b/wizard/deploy.py index bdea87e..6197a9a 100644 --- a/wizard/deploy.py +++ b/wizard/deploy.py @@ -228,7 +228,7 @@ class Deployment(object): """ try: host, basepath = scripts.get_web_host_and_path(self.location) - except ValueError: + except (ValueError, TypeError): raise UnknownWebPath return util.fetch(host, basepath, path, post) -- 2.45.0