]> scripts.mit.edu Git - wizard.git/commitdiff
Change to production directory before running certain commands.
authorEdward Z. Yang <ezyang@mit.edu>
Sun, 14 Nov 2010 16:13:04 +0000 (16:13 +0000)
committerEdward Z. Yang <ezyang@mit.edu>
Sun, 14 Nov 2010 16:13:04 +0000 (16:13 +0000)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
TODO
doc/module/wizard.util.rst
wizard/command/backup.py
wizard/command/blacklist.py
wizard/command/restore.py
wizard/command/upgrade.py
wizard/util.py

diff --git a/TODO b/TODO
index 74eab2d02c097ae7d12024c0246f8502fb00d985..3a1eea9a17a41646ea48cc4f10922a31cd0c11c1 100644 (file)
--- a/TODO
+++ b/TODO
@@ -16,7 +16,6 @@
   (or maybe this interacts /really/ poorly with restore, in which case
   restore should ensure all files are present before actually doing the
   restore)
-- Should be able to run restore from /tmp directory
 - Show progress or something when upgrading
 - Allow 'sticky notes' for future upgraders to notice
 - Blacklist should allow an easy way for a user to override it,
index ae9485f96aa6e5b9508ec0213d98d59da4681d88..46bd1720da7d26d3ef5adec1596f1ad79ccc4dc0 100644 (file)
@@ -15,6 +15,7 @@ Classes
 
 Functions
 ---------
+.. autofunction:: chdir_to_production
 .. autofunction:: dictmap
 .. autofunction:: dictkmap
 .. autofunction:: chdir
index a1699e828bd2226be8df28e343e0c476e2fc6a75..38ed50ac46bfa2dec374ee366fabb289a083897b 100644 (file)
@@ -7,6 +7,7 @@ def main(argv, baton):
     dir = os.path.abspath(args[0]) if args else os.getcwd()
     shell.drop_priviledges(dir, options.log_file)
     util.chdir(dir)
+    util.chdir_to_production()
     d = deploy.ProductionCopy(".")
     d.verify()
     d.verifyConfigured()
index 0d16be24ea067773be56149c61979f8d6e0dc9e1..e90fa36e15e7002a34477b6499664abcb100c8f4 100644 (file)
@@ -8,9 +8,7 @@ def main(argv, baton):
     # Directory information not transferred via command line, so this
     # will not error due to the changed directory.
     shell.drop_priviledges(".", options.log_file)
-    # XXX: this should be abstracted away!
-    if os.path.exists(".git/WIZARD_REPO"):
-        util.chdir(shell.eval('git', 'config', 'remote.origin.url'))
+    util.chdir_to_production()
     production = deploy.ProductionCopy(".")
     production.verify()
     open(production.blacklisted_file, 'w').write(reason + "\n")
index 3d4fc2e081501991e26d18e70fb9975730a97e27..5bc13b8394cec030e8761836dae4b42882f2cb9a 100644 (file)
@@ -2,10 +2,11 @@ import logging
 import os
 import sys
 
-from wizard import command, deploy, shell
+from wizard import command, deploy, shell, util
 
 def main(argv, baton):
     options, args = parse_args(argv, baton)
+    util.chdir_to_production()
     d = deploy.ProductionCopy(".")
     d.verify()
     backups = d.backup_dir
index f397c08f527559ff325d6a539a36139807ac87fb..e31e7b935b9402ef51c01a673cc0b39171154b12 100644 (file)
@@ -115,11 +115,7 @@ class Upgrade(object):
         If we called ``--continue`` inside a production copy,  check if
         :file:`.wizard/pending` exists and change to that directory if so.
         """
-        # XXX: Can't use deploy; maybe should stringify constants?
-        if os.path.exists(".wizard/pending"):
-            newdir = open(".wizard/pending").read().strip()
-            logging.warning("Detected production copy; changing directory to %s", newdir)
-            os.chdir(newdir)
+        util.chdir_to_production()
     def resumeState(self):
         self.temp_wc_dir = os.getcwd()
         self.wc = deploy.WorkingCopy(".")
index 8f1d1ba4bff20ab9eb0ca7121febce9e4b51072f..7237ae656826537dec251d662d205074364fa19f 100644 (file)
@@ -44,6 +44,14 @@ def boolish(val):
             return False
         return bool(val)
 
+def chdir_to_production():
+    # XXX: Can't use deploy; maybe should stringify constant
+    # .wizard/pending?
+    if os.path.exists(".wizard/pending"):
+        newdir = open(".wizard/pending").read().strip()
+        logging.warning("Detected production copy; changing directory to %s", newdir)
+        os.chdir(newdir)
+
 class ChangeDirectory(object):
     """
     Context for temporarily changing the working directory.