Allow kamaki-shell to ignore unrecognized commands
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Mon, 2 Dec 2013 16:25:33 +0000 (18:25 +0200)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Mon, 2 Dec 2013 16:25:33 +0000 (18:25 +0200)
kamaki/cli/__init__.py
kamaki/cli/argument/__init__.py
kamaki/cli/config/__init__.py

index 2f8ee80..4b59858 100644 (file)
@@ -512,12 +512,11 @@ def main(foo):
             filelog = logger.add_file_logger(__name__.split('.')[0])
             filelog.info('* Initial Call *\n%s\n- - -' % ' '.join(argv))
 
-            cloud = _init_session(parser.arguments, is_non_API(parser))
             from kamaki.cli.utils import suggest_missing
             global _colors
             exclude = ['ansicolors'] if not _colors == 'on' else []
             suggest_missing(exclude=exclude)
-            foo(exe, parser, cloud)
+            foo(exe, parser)
         except CLIError as err:
             print_error_message(err)
             if _debug:
@@ -535,7 +534,9 @@ def main(foo):
 
 
 @main
-def run_shell(exe, parser, cloud):
+def run_shell(exe, parser):
+    parser.arguments['help'].value = False
+    cloud = _init_session(parser.arguments)
     from command_shell import _init_shell
     global kloger
     _cnf = parser.arguments['config']
@@ -551,7 +552,8 @@ def run_shell(exe, parser, cloud):
 
 
 @main
-def run_one_cmd(exe, parser, cloud):
+def run_one_cmd(exe, parser):
+    cloud = _init_session(parser.arguments, is_non_API(parser))
     if parser.unparsed:
         global _history
         try:
index 9c66b11..7b434ed 100644 (file)
@@ -103,7 +103,7 @@ class ConfigArgument(Argument):
 
     @property
     def value(self):
-        return super(ConfigArgument, self).value
+        return getattr(self, '_value', None)
 
     @value.setter
     def value(self, config_file):
index b0f69c8..55e652a 100644 (file)
@@ -291,7 +291,7 @@ class Config(RawConfigParser):
 
         :raises KeyError: if cloud or cloud's option does not exist
         """
-        r = self.get(CLOUD_PREFIX, cloud)
+        r = self.get(CLOUD_PREFIX, cloud) if cloud else None
         if not r:
             raise KeyError('Cloud "%s" does not exist' % cloud)
         return r[option]