]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/__init__.py
Use CLI installer for MediaWiki 1.17.0 and later.
[wizard.git] / wizard / command / __init__.py
index 5d77be38427ebce61fe24883f367fef24b240fb0..8d5e14c3c434b922db807dffc7214c4ceb4aab0c 100644 (file)
@@ -9,30 +9,17 @@ import shutil
 import cStringIO
 
 import wizard
-from wizard import util
+from wizard import util, shell
+
+def chdir_to_production():
+    if os.path.exists(".git/WIZARD_UPGRADE_VERSION"): # XXX do something more robust
+        util.chdir(shell.eval("git", "config", "remote.origin.url"))
+        return True
+    return False
 
 logging_setup = False
 debug = True # This will get overwritten with the real value early on
 
-def boolish(val):
-    """
-    Parse the contents of an environment variable as a boolean.
-    This recognizes more values as ``False`` than :func:`bool` would.
-
-        >>> boolish("0")
-        False
-        >>> boolish("no")
-        False
-        >>> boolish("1")
-        True
-    """
-    try:
-        return bool(int(val))
-    except (ValueError, TypeError):
-        if val == "No" or val == "no" or val == "false" or val == "False":
-            return False
-        return bool(val)
-
 def setup_logger(options, numeric_args):
     global logging_setup
     if logging_setup: return logging.getLogger()
@@ -89,6 +76,8 @@ def security_check_homedir(location):
     This protects against malicious mountpoints, and is roughly equivalent
     to the suexec checks.
     """
+    # XXX: this is a smidge unfriendly to systems who haven't setup
+    # nswitch.
     try:
         uid = util.get_dir_uid(location)
         real = os.path.realpath(location)
@@ -149,13 +138,15 @@ class WizardOptionParser(optparse.OptionParser):
             self.add_option("-h", "--help", action="help", help=optparse.SUPPRESS_HELP)
         group = optparse.OptionGroup(self, "Common Options")
         group.add_option("-v", "--verbose", dest="verbose", action="store_true",
-                default=boolish(os.getenv("WIZARD_VERBOSE")), help="Turns on verbose output.  Envvar is WIZARD_VERBOSE")
+                default=util.boolish(os.getenv("WIZARD_VERBOSE")), help="Turns on verbose output.  Envvar is WIZARD_VERBOSE")
         group.add_option("--debug", dest="debug", action="store_true",
-                default=boolish(os.getenv("WIZARD_DEBUG")), help="Turns on debugging output.  Envvar is WIZARD_DEBUG")
+                default=util.boolish(os.getenv("WIZARD_DEBUG")), help="Turns on debugging output.  Envvar is WIZARD_DEBUG")
         group.add_option("-q", "--quiet", dest="quiet", action="store_true",
-                default=boolish(os.getenv("WIZARD_QUIET")), help="Turns off output to stdout. Envvar is WIZARD_QUIET")
+                default=util.boolish(os.getenv("WIZARD_QUIET")), help="Turns off output to stdout. Envvar is WIZARD_QUIET")
         group.add_option("--log-file", dest="log_file", metavar="FILE",
-                default=None, help="Logs verbose output to file")
+                default=os.getenv("WIZARD_LOGFILE"), help="Logs verbose output to file")
+        group.add_option("--directory", dest="directory", metavar="PATH",
+                default=os.getenv("WIZARD_DIRECTORY", ".wizard"), help="Initialize this folder to store metadata.")
         self.add_option_group(group)
         options, numeric_args = self.parse_args(*args, **kwargs)
         setup_logger(options, numeric_args)