]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/__init__.py
Refactor, increase error coverage, more sanity checks.
[wizard.git] / wizard / command / __init__.py
index 505142009796322c387d3f4640b9f6e65b335ef5..eeb5336a236dcaffa999bf3f8867b2a08cfab99b 100644 (file)
@@ -9,33 +9,6 @@ import wizard
 
 logging_setup = False
 
-class Error(wizard.Error):
-    """Base error class for all command errors"""
-    pass
-
-class PermissionsError(Error):
-    def __init__(self, dir):
-        self.dir = dir
-    def __str__(self):
-        return """
-
-ERROR: You don't have permissions to access this directory.
-Do you have tokens for AFS with your root instance, and
-is your root instance on scripts-security-upd?
-
-You can check by running the commands 'klist' and
-'blanche scripts-security-upd'.
-"""
-
-class NoSuchDirectoryError(Error):
-    def __init__(self, dir):
-        self.dir = dir
-    def __str__(self):
-        return """
-
-ERROR: No such directory... check your typing
-"""
-
 def boolish(val):
     """
     Parse the contents of an environment variable as a boolean.
@@ -55,16 +28,6 @@ def boolish(val):
             return False
         return bool(val)
 
-def chdir(dir):
-    try:
-        os.chdir(dir)
-    except OSError as e:
-        if e.errno == errno.EACCES:
-            raise PermissionsError(dir)
-        elif e.errno == errno.ENOENT:
-            raise NoSuchDirectoryError(dir)
-        else: raise e
-
 def makeLogger(options, numeric_args):
     global logging_setup
     if logging_setup: return logging.getLogger()
@@ -151,3 +114,7 @@ class OptionBaton(object):
         """Hands off parameters to option parser"""
         for key in args:
             option_parser.add_option(self.store[key])
+
+class Error(wizard.Error):
+    """Base error class for all command errors"""
+    pass