Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit d0a8482ba935c510e9e51e6e97bf82cfd04aaa91
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Feb 14 10:07:15 2014 +0100
make synchro-calls available to all methods, which return a job
>---------------------------------------------------------------
cli/lmi/shell/LMIClass.py | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/cli/lmi/shell/LMIClass.py b/cli/lmi/shell/LMIClass.py
index f156cf6..f8a0a69 100644
--- a/cli/lmi/shell/LMIClass.py
+++ b/cli/lmi/shell/LMIClass.py
@@ -315,9 +315,14 @@ class LMIClass(LMIWrapperBaseObject):
"""
(class_names, _, _) = self._conn._client._get_class_names(self.namespace)
methods_lst = self._cim_class.methods.keys()
- for method in self._cim_class.methods.keys():
- if "__MethodParameters_" + method in class_names:
- methods_lst.append("Sync" + method)
+ # Iterate through a list of all CIM methods and append any method which
+ # can be called in the synchronous way. One type of such method is the
+ # method, which has its "counterpart" class __MethodParameters_<Method>.
+ # The other one is the method, which defines a Job return paremeter.
+ for (name, method) in self._cim_class.methods.iteritems():
+ if "__MethodParameters_" + name in class_names or \
+ "Job" in method.parameters:
+ methods_lst.append("Sync" + name)
return methods_lst
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit f6da730d943300f616837a2272db0c780c977c5c
Author: Peter Hatina <phatina(a)redhat.com>
Date: Wed Feb 12 15:34:43 2014 +0100
update copyright years
>---------------------------------------------------------------
cli/completion/_lmishell | 2 +-
cli/completion/lmi.bash | 2 +-
cli/completion/lmishell.bash | 2 +-
cli/lmi/__init__.py | 2 +-
cli/lmi/shell/LMIBaseClient.py | 2 +-
cli/lmi/shell/LMIBaseObject.py | 2 +-
cli/lmi/shell/LMIClass.py | 2 +-
cli/lmi/shell/LMICompleter.py | 2 +-
cli/lmi/shell/LMIConnection.py | 2 +-
cli/lmi/shell/LMIConsole.py | 2 +-
cli/lmi/shell/LMIConstantValues.py | 2 +-
cli/lmi/shell/LMIDecorators.py | 2 +-
cli/lmi/shell/LMIExceptions.py | 2 +-
cli/lmi/shell/LMIFormatter.py | 2 +-
cli/lmi/shell/LMIHelper.py | 2 +-
cli/lmi/shell/LMIIndication.py | 2 +-
cli/lmi/shell/LMIIndicationListener.py | 2 +-
cli/lmi/shell/LMIInstance.py | 2 +-
cli/lmi/shell/LMIInstanceName.py | 2 +-
cli/lmi/shell/LMIJob.py | 2 +-
cli/lmi/shell/LMIMethod.py | 2 +-
cli/lmi/shell/LMINamespace.py | 2 +-
cli/lmi/shell/LMIObjectFactory.py | 2 +-
cli/lmi/shell/LMIReturnValue.py | 2 +-
cli/lmi/shell/LMIShellCache.py | 2 +-
cli/lmi/shell/LMIShellClient.py | 2 +-
cli/lmi/shell/LMIShellConfig.py | 2 +-
cli/lmi/shell/LMIShellOptions.py | 2 +-
cli/lmi/shell/LMIShellVersion.py | 3 +--
cli/lmi/shell/LMISubscription.py | 2 +-
cli/lmi/shell/LMIUtil.py | 2 +-
cli/lmi/shell/__init__.py | 2 +-
cli/lmishell | 2 +-
cli/setup.py | 2 +-
34 files changed, 34 insertions(+), 35 deletions(-)
diff --git a/cli/completion/_lmishell b/cli/completion/_lmishell
index d3843b3..28a51e4 100644
--- a/cli/completion/_lmishell
+++ b/cli/completion/_lmishell
@@ -1,6 +1,6 @@
#compdef lmishell
-# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
diff --git a/cli/completion/lmi.bash b/cli/completion/lmi.bash
index 0aa174b..c60ab9b 100644
--- a/cli/completion/lmi.bash
+++ b/cli/completion/lmi.bash
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
diff --git a/cli/completion/lmishell.bash b/cli/completion/lmishell.bash
index 07958f0..9d3ec2a 100644
--- a/cli/completion/lmishell.bash
+++ b/cli/completion/lmishell.bash
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
diff --git a/cli/lmi/__init__.py b/cli/lmi/__init__.py
index e554343..a02ea71 100644
--- a/cli/lmi/__init__.py
+++ b/cli/lmi/__init__.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIBaseClient.py b/cli/lmi/shell/LMIBaseClient.py
index a16f9f1..7ca9b5d 100644
--- a/cli/lmi/shell/LMIBaseClient.py
+++ b/cli/lmi/shell/LMIBaseClient.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIBaseObject.py b/cli/lmi/shell/LMIBaseObject.py
index 1e2df9e..565c89c 100644
--- a/cli/lmi/shell/LMIBaseObject.py
+++ b/cli/lmi/shell/LMIBaseObject.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIClass.py b/cli/lmi/shell/LMIClass.py
index aa250b1..f156cf6 100644
--- a/cli/lmi/shell/LMIClass.py
+++ b/cli/lmi/shell/LMIClass.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMICompleter.py b/cli/lmi/shell/LMICompleter.py
index 64e0a87..df57388 100644
--- a/cli/lmi/shell/LMICompleter.py
+++ b/cli/lmi/shell/LMICompleter.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 5d1040b..b708551 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIConsole.py b/cli/lmi/shell/LMIConsole.py
index f1c9c4f..cb287a2 100644
--- a/cli/lmi/shell/LMIConsole.py
+++ b/cli/lmi/shell/LMIConsole.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIConstantValues.py b/cli/lmi/shell/LMIConstantValues.py
index e9927ba..93fe796 100644
--- a/cli/lmi/shell/LMIConstantValues.py
+++ b/cli/lmi/shell/LMIConstantValues.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIDecorators.py b/cli/lmi/shell/LMIDecorators.py
index e3b2763..eafd387 100644
--- a/cli/lmi/shell/LMIDecorators.py
+++ b/cli/lmi/shell/LMIDecorators.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIExceptions.py b/cli/lmi/shell/LMIExceptions.py
index a93dc26..2dc0499 100644
--- a/cli/lmi/shell/LMIExceptions.py
+++ b/cli/lmi/shell/LMIExceptions.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIFormatter.py b/cli/lmi/shell/LMIFormatter.py
index 48babe3..1ed8650 100644
--- a/cli/lmi/shell/LMIFormatter.py
+++ b/cli/lmi/shell/LMIFormatter.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIHelper.py b/cli/lmi/shell/LMIHelper.py
index b33fffb..1747603 100644
--- a/cli/lmi/shell/LMIHelper.py
+++ b/cli/lmi/shell/LMIHelper.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIIndication.py b/cli/lmi/shell/LMIIndication.py
index 808d4e8..07da2c3 100644
--- a/cli/lmi/shell/LMIIndication.py
+++ b/cli/lmi/shell/LMIIndication.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIIndicationListener.py b/cli/lmi/shell/LMIIndicationListener.py
index 5b76f06..cb28c7c 100644
--- a/cli/lmi/shell/LMIIndicationListener.py
+++ b/cli/lmi/shell/LMIIndicationListener.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIInstance.py b/cli/lmi/shell/LMIInstance.py
index 28c6c36..9597447 100644
--- a/cli/lmi/shell/LMIInstance.py
+++ b/cli/lmi/shell/LMIInstance.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIInstanceName.py b/cli/lmi/shell/LMIInstanceName.py
index c70a5fd..cdc5cf3 100644
--- a/cli/lmi/shell/LMIInstanceName.py
+++ b/cli/lmi/shell/LMIInstanceName.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIJob.py b/cli/lmi/shell/LMIJob.py
index db172a1..ef70b17 100644
--- a/cli/lmi/shell/LMIJob.py
+++ b/cli/lmi/shell/LMIJob.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIMethod.py b/cli/lmi/shell/LMIMethod.py
index 1b8529d..7c32be9 100644
--- a/cli/lmi/shell/LMIMethod.py
+++ b/cli/lmi/shell/LMIMethod.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMINamespace.py b/cli/lmi/shell/LMINamespace.py
index 2f70055..0c53608 100644
--- a/cli/lmi/shell/LMINamespace.py
+++ b/cli/lmi/shell/LMINamespace.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIObjectFactory.py b/cli/lmi/shell/LMIObjectFactory.py
index e3d355d..d6151a9 100644
--- a/cli/lmi/shell/LMIObjectFactory.py
+++ b/cli/lmi/shell/LMIObjectFactory.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIReturnValue.py b/cli/lmi/shell/LMIReturnValue.py
index 80afad5..56f0bc7 100644
--- a/cli/lmi/shell/LMIReturnValue.py
+++ b/cli/lmi/shell/LMIReturnValue.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIShellCache.py b/cli/lmi/shell/LMIShellCache.py
index 68cec67..39da533 100644
--- a/cli/lmi/shell/LMIShellCache.py
+++ b/cli/lmi/shell/LMIShellCache.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIShellClient.py b/cli/lmi/shell/LMIShellClient.py
index 6c246f0..385e3ac 100644
--- a/cli/lmi/shell/LMIShellClient.py
+++ b/cli/lmi/shell/LMIShellClient.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIShellConfig.py b/cli/lmi/shell/LMIShellConfig.py
index 05b5638..e134747 100644
--- a/cli/lmi/shell/LMIShellConfig.py
+++ b/cli/lmi/shell/LMIShellConfig.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIShellOptions.py b/cli/lmi/shell/LMIShellOptions.py
index 8695fec..d7d8377 100644
--- a/cli/lmi/shell/LMIShellOptions.py
+++ b/cli/lmi/shell/LMIShellOptions.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIShellVersion.py b/cli/lmi/shell/LMIShellVersion.py
index 1c1cb6c..452176c 100644
--- a/cli/lmi/shell/LMIShellVersion.py
+++ b/cli/lmi/shell/LMIShellVersion.py
@@ -1,5 +1,4 @@
-
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMISubscription.py b/cli/lmi/shell/LMISubscription.py
index 6fb9e9c..a61dcc2 100644
--- a/cli/lmi/shell/LMISubscription.py
+++ b/cli/lmi/shell/LMISubscription.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/LMIUtil.py b/cli/lmi/shell/LMIUtil.py
index 15b7448..2eb5575 100644
--- a/cli/lmi/shell/LMIUtil.py
+++ b/cli/lmi/shell/LMIUtil.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmi/shell/__init__.py b/cli/lmi/shell/__init__.py
index 378cc24..cbf3479 100644
--- a/cli/lmi/shell/__init__.py
+++ b/cli/lmi/shell/__init__.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/lmishell b/cli/lmishell
index 433d413..7988d53 100755
--- a/cli/lmishell
+++ b/cli/lmishell
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
diff --git a/cli/setup.py b/cli/setup.py
index fd6ed8a..4fc2f71 100644
--- a/cli/setup.py
+++ b/cli/setup.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
+# Copyright (C) 2012-2014 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 71d21c92700df68c5900b230a62b601b9c367f85
Author: Michal Minar <miminar(a)redhat.com>
Date: Wed Feb 12 12:21:36 2014 +0100
logging: get the logger with name of a module
Allow to configure shell's logging facilities from dependent
applications. Using module's name as a name for a logger is a convetion
greatly simplifying logging's setup.
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index ef83a8a..5d1040b 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -71,7 +71,7 @@ def __lmi_raw_input(prompt, use_echo=True):
get_input = raw_input
stream = sys.stdout
if not sys.stderr.isatty() and not sys.stdout.isatty():
- logging.getLogger("").warn(
+ logging.getLogger(__name__).warn(
'Both stdout and stderr are detached from terminal, using stdout for prompt')
if not use_echo:
os.system("stty -echo")
@@ -140,7 +140,7 @@ def connect(uri, username="", password="", **kwargs):
if kwargs:
raise TypeError("connect() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
- logger = logging.getLogger("")
+ logger = logging.getLogger(__name__)
connection = None
# If we are running as root and the scheme has not been explicitly set,
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit fcf648f891c27eeb68ebe6bbaf2f600e51f20ae4
Author: Michal Minar <miminar(a)redhat.com>
Date: Sun Jan 19 15:13:32 2014 +0100
terminate with exit code of last command executed
Make sure that return code of triggered command gets propagated to the
application's entry point.
In interactive mode, meta-command shall exit with the return code of the
last command executed. Note that exit is also a command (returning 0 by
default).
Resolves ticket #174
Original commit digest in openlmi-scripts repo:
0580e779fee8bcd21dd00b2374c96902c1b49cf1
>---------------------------------------------------------------
cli/lmi/scripts/_metacommand/__init__.py | 5 ++++-
cli/lmi/scripts/common/command/base.py | 4 +++-
cli/lmi/scripts/common/command/session.py | 2 +-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/cli/lmi/scripts/_metacommand/__init__.py b/cli/lmi/scripts/_metacommand/__init__.py
index e26c1b7..598c0a7 100644
--- a/cli/lmi/scripts/_metacommand/__init__.py
+++ b/cli/lmi/scripts/_metacommand/__init__.py
@@ -204,7 +204,7 @@ class MetaCommand(object):
"""
cmd = TopLevelCommand(self)
try:
- return cmd.run(argv)
+ retval = cmd.run(argv)
except Exception as exc:
trace = True if self.config is None else self.config.trace
if isinstance(exc, errors.LmiError) or not trace:
@@ -212,6 +212,9 @@ class MetaCommand(object):
else:
LOG().exception("fatal")
return 1
+ if isinstance(retval, bool) or not isinstance(retval, (int, long)):
+ return 0 if bool(retval) or retval is None else 1
+ return retval
def main(argv=sys.argv[1:]):
"""
diff --git a/cli/lmi/scripts/common/command/base.py b/cli/lmi/scripts/common/command/base.py
index dcf40bf..62a1aec 100644
--- a/cli/lmi/scripts/common/command/base.py
+++ b/cli/lmi/scripts/common/command/base.py
@@ -219,7 +219,9 @@ class LmiBaseCommand(object):
:param list args: Arguments passed to the command line that were
not yet parsed. It's the contents of ``sys.argv`` (if in
non-interactive mode) from the current command on.
- :returns: Exit code of application.
+ :returns: Exit code of application. This maybe also be a boolean value
+ or ``None``. ``None`` and ``True`` are treated as a success causing
+ exit code to be 0.
:rtype: integer
"""
raise NotImplementedError("run method must be overriden in subclass")
diff --git a/cli/lmi/scripts/common/command/session.py b/cli/lmi/scripts/common/command/session.py
index 1be7fec..b65952a 100644
--- a/cli/lmi/scripts/common/command/session.py
+++ b/cli/lmi/scripts/common/command/session.py
@@ -187,5 +187,5 @@ class LmiSessionCommand(LmiEndPointCommand):
return self.execute(connection, *args, **kwargs)
def run_with_args(self, args, kwargs):
- self.process_session(self.app.session, args, kwargs)
+ return self.process_session(self.app.session, args, kwargs)
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 8c311014fddd2e5c7affb03a90f3b8a5f13ddd11
Author: Michal Minar <miminar(a)redhat.com>
Date: Sun Jan 19 15:14:54 2014 +0100
exit interactive mode only when LmiTerminate is raised
Do not take into account the return value of executed command when
deciding whether to stop the shell. Terminate only when LmiTerminate is
raised.
Original commit digest in openlmi-scripts repo:
97fc31be422e833232679cfb27fbcfd4ae3fde5b
>---------------------------------------------------------------
cli/lmi/scripts/_metacommand/interactive.py | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/cli/lmi/scripts/_metacommand/interactive.py b/cli/lmi/scripts/_metacommand/interactive.py
index bc31bf1..1170a94 100644
--- a/cli/lmi/scripts/_metacommand/interactive.py
+++ b/cli/lmi/scripts/_metacommand/interactive.py
@@ -42,6 +42,7 @@ class Interactive(cmd.Cmd):
cmd.Cmd.__init__(self,
stdin=parent_app.stdin, stdout=parent_app.stdout)
self.prompt = prompt
+ self._last_exit_code = 0
@property
def command_manager(self):
@@ -74,7 +75,11 @@ class Interactive(cmd.Cmd):
line_parts = shlex.split(line)
try:
# let's try to run registered subcommand
- return self.run_subcommand(line_parts)
+ retval = self.run_subcommand(line_parts)
+ if isinstance(retval, bool) or not isinstance(retval, (int, long)):
+ retval = 0 if bool(retval) or retval is None else 1
+ self._last_exit_code = retval
+ return retval
except errors.LmiCommandNotFound:
return cmd.Cmd.default(self, line)
except docopt.DocoptExit as err:
@@ -137,7 +142,7 @@ class Interactive(cmd.Cmd):
"""
Exit on End-Of-File.
"""
- return True
+ raise errors.LmiTerminate(self._last_exit_code)
def get_names(self):
"""
@@ -147,3 +152,15 @@ class Interactive(cmd.Cmd):
return [ n for n in cmd.Cmd.get_names(self)
if not n.startswith('do__')]
+ def postcmd(self, stop, _line):
+ """
+ This is called after the ``do_*`` command to postprocess its result and
+ decide whether to stop the shell. We want to stop only when
+ :py:class:`lmi.scripts.common.errors.LmiError` is raised. This
+ exception is catched upwards in call chain.
+
+ :returns: Whether to stop the shell.
+ :rtype: bool
+ """
+ return False
+