diff --git a/t2kdm/__init__.py b/t2kdm/__init__.py index 2daeb2f..1527fd1 100644 --- a/t2kdm/__init__.py +++ b/t2kdm/__init__.py @@ -3,7 +3,7 @@ Helpful tools to manage the T2K data on the grid. """ -__version__ = '1.7.1-dev' +__version__ = '1.7.1' import configuration from configuration import _branding diff --git a/t2kdm/commands.py b/t2kdm/commands.py index f25046c..e8c520e 100644 --- a/t2kdm/commands.py +++ b/t2kdm/commands.py @@ -99,19 +99,19 @@ def run_from_cli(self, argstring, _return=False, **kwargs): Then it returns the actual return value. """ + ret = 1 # Arbitrary error code + try: args = shlex.split(argstring) except ValueError as e: # Catch errors from bad bash syntax print_(e) - return False + if _return: + return ret + else: + return False - ret = False try: # We do *not* want to exit after printing a help message or erroring, so we have to catch that. ret = self.run_from_arglist(args, **kwargs) - except dm.backends.BackendException as e: - print_(e) - except interactive.InteractiveException as e: - print_(e) except Exception as e: print_(e) except SystemExit: diff --git a/t2kdm/maid.py b/t2kdm/maid.py index 0d667a4..9aabafc 100644 --- a/t2kdm/maid.py +++ b/t2kdm/maid.py @@ -210,6 +210,7 @@ def __init__(self, **kwargs): super(CommandTask, self).__init__(**kwargs) def _do(self): + # Check interactive command for success return code return self.command.run_from_cli(self.argstr, _return=True) == 0 def __str__(self): diff --git a/t2kdm/tests.py b/t2kdm/tests.py index b296729..22b70a3 100644 --- a/t2kdm/tests.py +++ b/t2kdm/tests.py @@ -157,10 +157,10 @@ def run_read_only_tests(): print_("Testing Commands...") with no_output(True): assert(cmd.ls.run_from_cli('-l /') == False) - assert(cmd.ls.run_from_cli('.') == False) + assert(cmd.ls.run_from_cli('/', _return=True) == 0) - cmd.ls.run_from_cli('abc') # This should not work, but not throw exception - cmd.ls.run_from_cli('"abc') # This should not work, but not throw exception + assert(cmd.ls.run_from_cli('abc') == False) # This should not work, but not throw exception + assert(cmd.ls.run_from_cli('"abc', _return=True) != 0) # This should not work, but not throw exception with fake_argv(['%s-ls'%(dm._branding,), '/']): assert(cmd.ls.run_from_console() == 0) # This should work with fake_argv(['%s-cli'%(dm._branding), '/']):