[cura-tools] master: fixed installation to user directory (251f2ae)
by miminar@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 251f2aec6ce9773499080f624c6d7fc0de8cb977
Author: Michal Minar <miminar(a)redhat.com>
Date: Tue Aug 6 17:15:13 2013 +0200
fixed installation to user directory
Missing 'lmi' namespace package in packages list renders shell
unimportable, when installed to user directory.
>---------------------------------------------------------------
cli/setup.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli/setup.py b/cli/setup.py
index e20b085..9753557 100644
--- a/cli/setup.py
+++ b/cli/setup.py
@@ -25,7 +25,7 @@ setup(
author="Peter Hatina",
author_email="phatina(a)redhat.com",
namespace_packages=['lmi'],
- packages=["lmi.shell"],
+ packages=["lmi", "lmi.shell"],
install_requires=["lmi"],
scripts=["lmishell"]
)
10 years, 9 months
[cura-tools] master: man page generator, autogenerate date and LMIShell version (8f934b4)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 8f934b4fde159c65c7ce04775efb2e0a79dbaa12
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Aug 6 13:46:15 2013 +0200
man page generator, autogenerate date and LMIShell version
>---------------------------------------------------------------
util/man-page-generator/generate-man-page | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/util/man-page-generator/generate-man-page b/util/man-page-generator/generate-man-page
index 3a32b00..0d98dcd 100755
--- a/util/man-page-generator/generate-man-page
+++ b/util/man-page-generator/generate-man-page
@@ -25,12 +25,23 @@ the provided file as a first command line argument will be used.
import re
import sys
import urllib
+import datetime
try:
import html2text
except ImportError, e:
sys.exit(e.message)
sys.exit(1)
+# Try to import LMIShell from relative path
+sys.path.append("../../cli")
+try:
+ from lmi.shell import __version__ as lmishell_version
+except ImportError:
+ # LMIShell can not be imported, we need to adjust the version by hand later...
+ lmishell_version = "Unknown"
+ sys.stderr.write("Error: Can not import lmi.shell from relative path ../../cli\n")
+ sys.stderr.write(" Version used: Unknown\n")
+
# Tuple of urls, where the documentation of LMIShell lives.
wiki_pages = (
"https://fedorahosted.org/openlmi/wiki/shell/startup",
@@ -53,7 +64,7 @@ page_end_line = 17
# The man page static header with LMIShell Synopsis, Description
# and command line options.
man_page_header = \
-""".TH lmishell "1" "July 2013" "openlmi-tools version 0.5" "User Commands"
+""".TH lmishell "1" "%s" "openlmi-tools v%s" "User Commands"
.SH NAME
lmishell \\- (non)interactive WBEM client and interpreter.
.SH SYNOPSIS
@@ -90,7 +101,7 @@ Do not print any log messages to stderr.
.P
By default, LMIShell prints out log messages with Error severity. Options
\\fB\\-v\\fR, \\fB\\-m\\fR and \\fB\\-q\\fR are mutually exclusive and
-can not be used together."""
+can not be used together.""" % (datetime.datetime.now().strftime("%B %Y"), lmishell_version)
# The man page static footer containing Authors section.
man_page_footer = \
""".SH "AUTHORS"
10 years, 9 months
[cura-tools] master: man page generator, remove link to LMIShell schema (2508009)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 25080091f0cecdd805bf0c50d29e3cdf053cb89b
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Aug 6 13:45:45 2013 +0200
man page generator, remove link to LMIShell schema
>---------------------------------------------------------------
util/man-page-generator/generate-man-page | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/util/man-page-generator/generate-man-page b/util/man-page-generator/generate-man-page
index 96f300c..3a32b00 100755
--- a/util/man-page-generator/generate-man-page
+++ b/util/man-page-generator/generate-man-page
@@ -64,11 +64,10 @@ lmishell provides a (non)interactive or interactive way how to access CIM
objects provided by OpenPegasus or sblim-sfcb CIMOM.
OpenLMI Shell is based on a python interpreter and added logic, therefore what
-you can do in pure python, it is possible in LMIShell. There are classes added
-to manipulate with CIM classes, instance names, instances, etc. Additional
-classes are added to fulfill wrapper pattern and expose only those methods,
-which are necessary for the purpose of a shell. Following scheme depicts a
-structure of the OpenLMI Shell.
+is possible to do in pure python, it is possible in LMIShell. There are classes
+added to manipulate with CIM classes, instance names, instances, etc.
+Additional classes are added to fulfill wrapper pattern and expose only those
+methods, which are necessary for the purpose of a shell.
.SH OPTIONS
The options may be given in any order before the first positional argument,
which stands for the script name.
10 years, 9 months
[cura-tools] master: code cleanup, update doc strings for LMIInstance methods (7340573)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 7340573b21fe92e11fedbeba818e327650b595ea
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Aug 6 11:19:45 2013 +0200
code cleanup, update doc strings for LMIInstance methods
>---------------------------------------------------------------
cli/lmi/shell/LMIInstance.py | 152 +++++++++++++++++++++++++++++++++++-------
1 files changed, 127 insertions(+), 25 deletions(-)
diff --git a/cli/lmi/shell/LMIInstance.py b/cli/lmi/shell/LMIInstance.py
index e52d0b4..af83f64 100644
--- a/cli/lmi/shell/LMIInstance.py
+++ b/cli/lmi/shell/LMIInstance.py
@@ -59,7 +59,11 @@ class LMIInstance(LMIBaseObject):
property.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Arguments:
name -- string containing the class member, the method name, or the property
@@ -86,7 +90,11 @@ class LMIInstance(LMIBaseObject):
Modifies a CIMInstance property.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Arguments:
name -- string containing a name of the CIMInstance's member
@@ -104,7 +112,11 @@ class LMIInstance(LMIBaseObject):
Returns a pretty string for the object.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty string. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return "%s(classname='%s', ...)" % (self.__class__.__name__, self.classname)
@@ -115,7 +127,11 @@ class LMIInstance(LMIBaseObject):
Property returning a string of a class name.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty string. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return self._lmi_class.classname
@@ -126,7 +142,11 @@ class LMIInstance(LMIBaseObject):
Property retuning a string of a namespace name.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty string. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return self._lmi_class.namespace
@@ -137,7 +157,11 @@ class LMIInstance(LMIBaseObject):
Property returning a string of a CIMInstance path.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return self._cim_instance.path
@@ -151,7 +175,11 @@ class LMIInstance(LMIBaseObject):
as a fallback.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
LMIXmlFormatter(self._cim_instance.tocimxml()).fancy_format(self._client.interactive)
@@ -165,7 +193,11 @@ class LMIInstance(LMIBaseObject):
as a fallback.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
LMIMofFormatter(self._cim_instance.tomof()).fancy_format(self._client.interactive)
@@ -176,7 +208,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of associated LMIInstanceName with this object.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
AssocClass -- valid CIM association class name. It acts as a filter on the
@@ -209,7 +245,11 @@ class LMIInstance(LMIBaseObject):
Returns the first associated LMIInstanceName with this object.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
AssocClass -- valid CIM association class name. It acts as a filter on the
@@ -245,7 +285,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of associated LMIInstance with this object.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
AssocClass -- valid CIM association class name. It acts as a filter on the
@@ -291,7 +335,11 @@ class LMIInstance(LMIBaseObject):
Returns the first associated LMIInstance with this object.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
AssocClass -- valid CIM association class name. It acts as a filter on the
@@ -339,7 +387,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of association LMIInstanceName objects with this object.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
ResultClass -- valid CIM class name. It acts as a filter on the returned set
@@ -360,7 +412,11 @@ class LMIInstance(LMIBaseObject):
Returns the first association LMIInstanceName with this object.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keywords Arguments:
ResultClass -- valid CIM class name. It acts as a filter on the returned set
@@ -384,7 +440,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of association LMIInstance objects with this object.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
ResultClass -- valid CIM class name. It acts as a filter on the returned set
@@ -417,7 +477,11 @@ class LMIInstance(LMIBaseObject):
Returns the first association LMIInstance with this object.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Keyword Arguments:
ResultClass -- valid CIM class name. It acts as a filter on the returned set
@@ -452,7 +516,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of CIMInstance properties.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return self._cim_instance.properties.keys()
@@ -463,7 +531,11 @@ class LMIInstance(LMIBaseObject):
Prints out the list of CIMInstance properties.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
for (name, prop) in self._cim_instance.properties.iteritems():
sys.stdout.write("%s\n" % name)
@@ -476,7 +548,11 @@ class LMIInstance(LMIBaseObject):
This method may consume significant memory amount when called.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty dictionary. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return dict(zip(self._cim_instance.properties.keys(),
map(lambda x: x.value, self._cim_instance.properties.values())))
@@ -487,7 +563,11 @@ class LMIInstance(LMIBaseObject):
Returns a CIMInstance property value.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
Arguments:
prop_name -- string containing the CIMInstance property name
@@ -500,7 +580,11 @@ class LMIInstance(LMIBaseObject):
Returns a list of CIMInstance methods' names.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return an empty list. If the shell uses exceptions,
+ LMIDeletedObjectError will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
return self._lmi_class.methods()
@@ -510,7 +594,11 @@ class LMIInstance(LMIBaseObject):
Prints out the list of CIMInstance methods' names.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
self._lmi_class.print_methods()
@@ -528,7 +616,12 @@ class LMIInstance(LMIBaseObject):
was refreshed; otherwise rval is set to False.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return LMIReturnValue containing False as a return value with
+ proper error string set. If the shell uses exceptions, LMIDeletedObjectError will
+ be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
(new_cim_instance, _, errorstr) = self._client._get_instance(self.path, LocalOnly=False)
if not new_cim_instance:
@@ -550,7 +643,12 @@ class LMIInstance(LMIBaseObject):
is set to -1.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return LMIReturnValue containing False as a return value with
+ proper error string set. If the shell uses exceptions, LMIDeletedObjectError will
+ be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
(rval, rparams, errorstr) = self._client._modify_instance(self._cim_instance)
return LMIReturnValue(rval=rval, rparams=rparams, errorstr=errorstr)
@@ -562,7 +660,11 @@ class LMIInstance(LMIBaseObject):
Deletes this instance from the CIMOM.
Note: If the method LMIInstance.delete() was called, this method will not execute
- its code and will return LMIReturnValue containing None as a return value.
+ its code and will return None. If the shell uses exceptions, LMIDeletedObjectError
+ will be raised.
+
+ Raised exceptions:
+ LMIDeletedObjectError
"""
rval = self._client._delete_instance(self.path)
self._deleted = rval.rval == 0
10 years, 9 months
[cura-tools] master: code cleanup, drop unused import in LMIClass (c52b40f)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit c52b40f5b8669b1d9d40ae9b665d29bc3ab4cfa7
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Aug 6 10:54:33 2013 +0200
code cleanup, drop unused import in LMIClass
>---------------------------------------------------------------
cli/lmi/shell/LMIClass.py | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/cli/lmi/shell/LMIClass.py b/cli/lmi/shell/LMIClass.py
index a82d2fb..5e8db27 100644
--- a/cli/lmi/shell/LMIClass.py
+++ b/cli/lmi/shell/LMIClass.py
@@ -19,7 +19,6 @@ import pywbem
from LMIBaseObject import LMIBaseObject
from LMIBaseClient import LMIBaseClient
from LMIFormatter import LMIXmlFormatter
-from LMIReturnValue import LMIReturnValue
from LMIConstantValues import LMIConstantValuesParamProp
from LMIExceptions import LMIUnknownPropertyError
10 years, 9 months
[cura-tools] master: drop LMIReturnValue properties (19a9ead)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 19a9eadc6e1f0e0062442488e35b25540b30684f
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Aug 6 10:25:11 2013 +0200
drop LMIReturnValue properties
>---------------------------------------------------------------
cli/lmi/shell/LMIExceptions.py | 5 ---
cli/lmi/shell/LMIReturnValue.py | 53 ++++++++------------------------------
2 files changed, 11 insertions(+), 47 deletions(-)
diff --git a/cli/lmi/shell/LMIExceptions.py b/cli/lmi/shell/LMIExceptions.py
index 2bd4bda..e281207 100644
--- a/cli/lmi/shell/LMIExceptions.py
+++ b/cli/lmi/shell/LMIExceptions.py
@@ -64,11 +64,6 @@ class LMIHandlerNamePatternError(Exception):
replacable characters.
"""
-class LMIReturnValueError(Exception):
- """
- Raised, when there is a mandatory argument missing
- """
-
class LMIFilterError(Exception):
"""
Raised, when there is a filter error present
diff --git a/cli/lmi/shell/LMIReturnValue.py b/cli/lmi/shell/LMIReturnValue.py
index 9b69e3b..9203040 100644
--- a/cli/lmi/shell/LMIReturnValue.py
+++ b/cli/lmi/shell/LMIReturnValue.py
@@ -15,8 +15,6 @@
import collections
-from LMIExceptions import LMIReturnValueError
-
_RValue = collections.namedtuple('RValue', ["rval", "rparams", "errorstr"])
class LMIReturnValue(_RValue):
@@ -26,50 +24,21 @@ class LMIReturnValue(_RValue):
rparams -- returned parameters of eg. method call
errorstr -- error string
"""
- def __getattr__(self, name):
- """
- Returns a property value, if found.
-
- Arguments:
- name -- string of property name
+ def __repr__(self):
"""
- if not name in self._properties:
- raise AttributeError(name)
- return self._properties[name]
-
- def properties(self):
- """
- Returns a list of strings of all available properties.
+ Returns a pretty string for the object.
"""
- return self._properties.keys()
+ return "LMIReturnValue(rval=%r, rparams=%r, errorstr=%r)" % self
- def __new__(self, **kwargs):
+ def __new__(self, rval, rparams=None, errorstr=None):
"""
- Creates a new instance of LMIReturnValue. At least rval keyword argument must be
- provided to properly construct a LMIReturnValue object; otherwise
- LMIReturnValueError exception will be raised.
+ Creates a new instance of LMIReturnValue.
- Keyword arguments:
+ Arguments:
rval -- return value
- rparams -- return parameters
- errorstr -- error string
-
- Any other keyword argument will be also stored and is accessible via getattr.
+ rparams -- optional return parameters
+ errorstr -- optional error string
"""
- if not "rval" in kwargs:
- raise LMIReturnValueError("rval argument missing while instancing LMIReturnValue object")
- properties = {}
- keys_to_pop = []
- for (key, value) in kwargs.iteritems():
- if key in ("rval", "rparams", "errorstr"):
- continue
- properties[key] = value
- keys_to_pop.append(key)
- for key in keys_to_pop:
- kwargs.pop(key)
- rval = _RValue.__new__(self,
- rval = kwargs["rval"],
- rparams = kwargs["rparams"] if "rparams" in kwargs else {},
- errorstr = kwargs["errorstr"] if "errorstr" in kwargs else "")
- rval._properties = properties
- return rval
+ rparams = rparams if rparams else {}
+ errorstr = errorstr if errorstr else ""
+ return _RValue.__new__(self, rval=rval, rparams=rparams, errorstr=errorstr)
10 years, 9 months
[cura-tools] master: code cleanup, drop _return_value in LMIConnection::subscribe_indication() (aad139f)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit aad139f3bb44177eb4f6cc78e9c90b48d674a54f
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Aug 6 10:40:34 2013 +0200
code cleanup, drop _return_value in LMIConnection::subscribe_indication()
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index dec3f6c..c1ecaea 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -231,7 +231,6 @@ class LMIConnection(object):
Destination -- string representing destination uri, where the indications should
be delivered
"""
- _return_value = lambda rval, errorstr="": LMIReturnValue(rval=rval, errorstr=errorstr)
try:
cim_filter_provided = "Filter" in kwargs
if cim_filter_provided:
@@ -244,7 +243,7 @@ class LMIConnection(object):
else:
errorstr = "Filter argument accepts instances of CIMInstance or LMIInstance"
lmi_raise_or_dump_exception(LMIIndicationError(errorstr))
- return _return_value(False, errorstr)
+ return LMIReturnValue(rval=False, errorstr=errorstr)
else:
cim_filter_props = {
"CreationClassName" : kwargs["FilterCreationClassName"],
@@ -260,7 +259,7 @@ class LMIConnection(object):
cim_filter_props)
if not cim_filter:
lmi_raise_or_dump_exception(LMIIndicationError(errorstr))
- return _return_value(False, errorstr)
+ return LMIReturnValue(rval=False, errorstr=errorstr)
cim_handler_provided = "Handler" in kwargs
if cim_handler_provided:
cim_handler = kwargs["Handler"]._cim_instance
@@ -279,7 +278,7 @@ class LMIConnection(object):
if not "Filter" in kwargs:
self._client._delete_instance(cim_filter.path)
lmi_raise_or_dump_exception(LMIIndicationError(errorstr))
- return _return_value(False, errorstr)
+ return LMIReturnValue(rval=False, errorstr=errorstr)
cim_subscription_props = {
"Filter" : cim_filter.path,
"Handler" : cim_handler.path
@@ -293,7 +292,7 @@ class LMIConnection(object):
if not "Handler" in kwargs:
self._client._delete_instance(cim_handler.path)
lmi_raise_or_dump_exception(LMIIndicationError(errorstr))
- return _return_value(False, errorstr)
+ return LMIReturnValue(rval=False, errorstr=errorstr)
# XXX: Should we auto-delete all the indications?
permanent = lmi_get_item_or_default(kwargs, "Permanent", True)
self._indications[kwargs["Name"]] = LMISubscription(
@@ -305,8 +304,8 @@ class LMIConnection(object):
except KeyError, e:
errorstr = "Not all necessary parameters provided, missing: %s" % e
lmi_raise_or_dump_exception(LMIIndicationError(errorstr))
- return _return_value(False, errorstr)
- return _return_value(True)
+ return LMIReturnValue(rval=False, errorstr=errorstr)
+ return LMIReturnValue(rval=True)
def unsubscribe_indication(self, name):
"""
10 years, 9 months
[cura-tools] master: code cleanup in LMIBaseClient (f18c930)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit f18c93082f325bf951be6e4b7fe5253fd766c5d8
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Aug 6 09:23:54 2013 +0200
code cleanup in LMIBaseClient
>---------------------------------------------------------------
cli/lmi/shell/LMIBaseClient.py | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/cli/lmi/shell/LMIBaseClient.py b/cli/lmi/shell/LMIBaseClient.py
index 7d26b10..a8ecbcb 100644
--- a/cli/lmi/shell/LMIBaseClient.py
+++ b/cli/lmi/shell/LMIBaseClient.py
@@ -113,14 +113,14 @@ class LMIBaseClient(object):
except KeyError, e:
errorstr = "Can not filter by '%s'" % filter_key
lmi_raise_or_dump_exception(LMIFilterError(errorstr))
- return LMIReturnValue(rval = None, errorstr = errorstr)
+ return LMIReturnValue(rval=None, errorstr=errorstr)
except pywbem.cim_operations.CIMError, e:
lmi_raise_or_dump_exception(e)
- return LMIReturnValue(rval = None, errorstr = e.args[1])
+ return LMIReturnValue(rval=None, errorstr=e.args[1])
except pywbem.cim_http.AuthError, e:
lmi_raise_or_dump_exception(e)
- return LMIReturnValue(rval = None, errorstr = e.args[0])
- return LMIReturnValue(rval = inst_name_list)
+ return LMIReturnValue(rval=None, errorstr=e.args[0])
+ return LMIReturnValue(rval=inst_name_list)
def _get_instance(self, path, **kwargs):
"""
@@ -160,7 +160,7 @@ class LMIBaseClient(object):
except pywbem.cim_http.AuthError, e:
lmi_raise_or_dump_exception(e)
return LMIReturnValue(rval=None, errorstr=e.args[0])
- return LMIReturnValue(rval = inst)
+ return LMIReturnValue(rval=inst)
# NOTE: usage with Key=something, Value=something is deprecated
# NOTE: inst_filter is either None or dict
10 years, 9 months
[cura-tools] master: drop display hook (796b949)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 796b949e8ef39b7e5605f6436c97178866030fdd
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Aug 6 10:07:29 2013 +0200
drop display hook
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 20 ++-----------
cli/lmi/shell/LMIConsole.py | 34 ----------------------
cli/lmi/shell/LMIInstance.py | 59 ++++++++-------------------------------
cli/lmi/shell/LMIMethod.py | 53 +++++-----------------------------
cli/lmi/shell/LMIReturnValue.py | 30 +-------------------
cli/lmi/shell/LMIShellClient.py | 12 ++------
6 files changed, 27 insertions(+), 181 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 43666d0..dec3f6c 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -231,12 +231,7 @@ class LMIConnection(object):
Destination -- string representing destination uri, where the indications should
be delivered
"""
- _return_value = lambda rval, errorstr="": LMIReturnValue(
- rval=rval,
- errorstr=errorstr,
- use_display_hook=True,
- hostname=self._client.hostname
- )
+ _return_value = lambda rval, errorstr="": LMIReturnValue(rval=rval, errorstr=errorstr)
try:
cim_filter_provided = "Filter" in kwargs
if cim_filter_provided:
@@ -324,19 +319,10 @@ class LMIConnection(object):
if not name in self._indications:
errorstr = "No such indication"
lmi_raise_or_dump_exception(LMIIndicationError(errorstr))
- return LMIReturnValue(
- rval=False,
- errorstr=errorstr,
- use_display_hook=True,
- hostname=self._client.hostname
- )
+ return LMIReturnValue(rval=False, errorstr=errorstr)
indication = self._indications.pop(name)
indication.delete()
- return LMIReturnValue(
- rval=True,
- use_display_hook=True,
- hostname=self._client.hostname
- )
+ return LMIReturnValue(rval=True)
def __unsubscribe_all_indications(self):
"""
diff --git a/cli/lmi/shell/LMIConsole.py b/cli/lmi/shell/LMIConsole.py
index 37058da..f81099f 100644
--- a/cli/lmi/shell/LMIConsole.py
+++ b/cli/lmi/shell/LMIConsole.py
@@ -38,39 +38,6 @@ from LMIConnection import connect as connect_internal
from LMIUtil import lmi_set_use_exceptions
from LMIUtil import lmi_get_use_exceptions
-def _lmi_displayhook(o):
- """
- LMIShell display hook, which is used, when run in the interactive mode. Prints out a
- pretty message, when a LMIReturnValue is returned from a function, method call, etc.
- It is important, that the LMIReturnValue object needs to have a property
- "use_display_hook" set.
- """
- if o is None:
- return
- __builtin__._ = None
- if isinstance(o, LMIReturnValue) and o.use_display_hook:
- o.use_display_hook = False
- if (isinstance(o.rval, int) and o.rval in (0, 4096)) or (isinstance(o.rval, bool) and o.rval == True):
- result_str = "ok"
- else:
- result_str = "fail"
- sys.stdout.write("%s: %s (%s)" % (o.hostname, result_str, str(o.rval)))
- if o.errorstr:
- sys.stdout.write(": %s" % o.errorstr)
- sys.stdout.write("\n")
- else:
- print o
- __builtin__._ = o
-
-sys.displayhook = _lmi_displayhook
-
-def _use_display_sugar(use=True):
- """
- Helper function, which controls, if to use display "sugar". That means, if to use LMI
- display hook for LMIReturnValue.
- """
- sys.displayhook = _lmi_displayhook if use else sys.__displayhook__
-
class LMIConsole(code.InteractiveConsole):
"""
Class representing an interactive console.
@@ -152,7 +119,6 @@ class LMIConsole(code.InteractiveConsole):
if isinstance(v, LMIConnection):
locals[k]._client.interactive = True
locals["clear_history"] = self.clear_history
- locals["use_display_sugar"] = _use_display_sugar
locals["connect"] = connect
self.locals = dict(self.locals.items() + locals.items())
self.setup_completer()
diff --git a/cli/lmi/shell/LMIInstance.py b/cli/lmi/shell/LMIInstance.py
index 364f129..e52d0b4 100644
--- a/cli/lmi/shell/LMIInstance.py
+++ b/cli/lmi/shell/LMIInstance.py
@@ -515,20 +515,11 @@ class LMIInstance(LMIBaseObject):
self._lmi_class.print_methods()
@lmi_possibly_deleted( \
- lambda obj: LMIReturnValue( \
- rval=False, \
- errorstr="This instance has been deleted from a CIM broker", \
- use_display_hook=True, \
- hostname=obj._client.hostname), \
- Self=True \
+ LMIReturnValue(rval=False, errorstr="This instance has been deleted from a CIM broker"), \
)
- @lmi_return_expr_if_fail(lambda obj: obj._cim_instance,
- lambda obj: LMIReturnValue( \
- rval=False, \
- errorstr="Can not refresh the instance", \
- use_display_hook=True, \
- hostname=obj._client.hostname), \
- Self=True \
+ @lmi_return_val_if_fail( \
+ lambda obj: obj._cim_instance,
+ LMIReturnValue(rval=False, errorstr="Can not refresh the instance"), \
)
def refresh(self):
"""
@@ -541,36 +532,16 @@ class LMIInstance(LMIBaseObject):
"""
(new_cim_instance, _, errorstr) = self._client._get_instance(self.path, LocalOnly=False)
if not new_cim_instance:
- return LMIReturnValue(
- rval=False,
- errorstr=errorstr,
- use_display_hook=True,
- hostname=self._client.hostname
- )
+ return LMIReturnValue(rval=False, errorstr=errorstr)
self._cim_instance = new_cim_instance
- return LMIReturnValue(
- rval=True,
- use_display_hook=True,
- hostname=self._client.hostname
- )
+ return LMIReturnValue(rval=True)
@lmi_possibly_deleted( \
- lambda obj: LMIReturnValue( \
- rval=False, \
- errorstr="This instance has been deleted from a CIM broker",
- use_display_hook=True, \
- hostname=obj._client.hostname
- ), \
- Self=True \
- )
- @lmi_return_expr_if_fail(lambda obj: obj._cim_instance.path, \
- lambda obj: LMIReturnValue( \
- rval=False, \
- errorstr="Can't push this instance", \
- use_display_hook=True, \
- hostname=obj._client.hostname \
- ), \
- Self=True \
+ LMIReturnValue(rval=False, errorstr="This instance has been deleted from a CIM broker") \
+ )
+ @lmi_return_val_if_fail( \
+ lambda obj: obj._cim_instance.path, \
+ LMIReturnValue(rval=False, errorstr="Can't push this instance"), \
)
def push(self):
"""
@@ -582,13 +553,7 @@ class LMIInstance(LMIBaseObject):
its code and will return LMIReturnValue containing None as a return value.
"""
(rval, rparams, errorstr) = self._client._modify_instance(self._cim_instance)
- return LMIReturnValue(
- rval=rval,
- rparams=rparams,
- errorstr=errorstr,
- use_display_hook=True,
- hostname=self._client.hostname
- )
+ return LMIReturnValue(rval=rval, rparams=rparams, errorstr=errorstr)
@lmi_possibly_deleted(None)
@lmi_return_if_fail(lambda obj: obj._cim_instance.path)
diff --git a/cli/lmi/shell/LMIMethod.py b/cli/lmi/shell/LMIMethod.py
index 7760706..3a05740 100644
--- a/cli/lmi/shell/LMIMethod.py
+++ b/cli/lmi/shell/LMIMethod.py
@@ -132,11 +132,7 @@ class LMIMethod(LMIBaseObject):
if not error_inst:
raise LMISynchroMethodCallError("Could not get Job error message")
errorstr = error_inst.Message
- return LMIReturnValue(
- rval=rval,
- rparams=rparams,
- errorstr=errorstr
- )
+ return LMIReturnValue(rval=rval, rparams=rparams, errorstr=errorstr)
def __handle_synchro_method_call_indication(self, job_inst):
"""
@@ -362,12 +358,7 @@ class LMIMethod(LMIBaseObject):
# NOTE: maybe we could check for pywbem type and not to exit prematurely
errorstr = "Unknown parameter '%s' supplied for method '%s'" % (param, self._method.name)
lmi_raise_or_dump_exception(LMIUnknownParameterError(errorstr))
- return LMIReturnValue(
- rval=-1,
- errorstr=errorstr,
- hostname=self._client.hostname,
- use_display_hook=True
- )
+ return LMIReturnValue(rval=-1, errorstr=errorstr)
(rval, call_rparams, call_errorstr) = self._client._call_method_raw(self._lmi_instance,
self._method.name, **kwargs)
rval = lmi_transform_to_lmi(self._client, rval)
@@ -377,12 +368,7 @@ class LMIMethod(LMIBaseObject):
# NOTE: this is wrong! What should we do?
errorstr = "Could not perform CIM -> LMI object transformation"
lmi_raise_or_dump_exception(LMIMethodCallError(errorstr))
- return LMIReturnValue(
- rval=rval,
- errorstr=errorstr,
- hostname=self._client.hostname,
- use_display_hook=True
- )
+ return LMIReturnValue(rval=rval, errorstr=errorstr)
# Check if we can perform synchronous method call
job = call_rparams["job"] if "job" in call_rparams else None
can_perform_sync_call = job.classname in LMIMethod._INDICATION_JOB_CLASSNAMES if job else False
@@ -397,20 +383,10 @@ class LMIMethod(LMIBaseObject):
handled_by_indication = True
except pywbem.CIMError, e:
lmi_raise_or_dump_exception(e)
- return LMIReturnValue(
- rval=-1,
- errorstr=e.args[1],
- use_display_hook=True,
- hostname=self._client.hostname
- )
+ return LMIReturnValue(rval=-1, errorstr=e.args[1])
except LMISynchroMethodCallError, e:
lmi_raise_or_dump_exception(e)
- return LMIReturnValue(
- rval=-1,
- errorstr=e.message,
- use_display_hook=True,
- hostname=self._client.hostname
- )
+ return LMIReturnValue(rval=-1, errorstr=e.message)
# Fall through, try to handle the synchro call by polling
except LMIHandlerNamePatternError, e:
handled_by_indication = False
@@ -424,27 +400,14 @@ class LMIMethod(LMIBaseObject):
(rval, call_rparams, call_errorstr) = self.__handle_synchro_method_call_polling(job_inst)
except LMISynchroMethodCallError, e:
lmi_raise_or_dump_exception(e)
- return LMIReturnValue(
- rval=-1,
- errorstr=e.message,
- hostname=self._client.hostname,
- use_display_hook=True
- )
+ return LMIReturnValue(rval=-1, errorstr=e.message)
call_rparams = lmi_transform_to_lmi(self._client, call_rparams)
if not self._lmi_instance.refresh():
# NOTE: this is wrong! What should we do?
errorstr = "Could not update an LMI object after a method call"
lmi_raise_or_dump_exception(LMIMethodCallError(errorstr))
- return LMIReturnValue(
- rval=rval,
- errorstr=errorstr
- )
- return LMIReturnValue(
- hostname=self._client.hostname,
- use_display_hook=True,
- rval=rval,
- rparams=call_rparams,
- errorstr=call_errorstr)
+ return LMIReturnValue(rval=rval, errorstr=errorstr)
+ return LMIReturnValue(rval=rval, rparams=call_rparams, errorstr=call_errorstr)
def __getattr__(self, name):
"""
diff --git a/cli/lmi/shell/LMIReturnValue.py b/cli/lmi/shell/LMIReturnValue.py
index 5ca650c..9b69e3b 100644
--- a/cli/lmi/shell/LMIReturnValue.py
+++ b/cli/lmi/shell/LMIReturnValue.py
@@ -43,29 +43,6 @@ class LMIReturnValue(_RValue):
"""
return self._properties.keys()
- @property
- def use_display_hook(self):
- """
- Property returning a bool flag, if the LMIReturnValue can be used in the
- interactive mode's output hook.
- """
- return self._properties["use_display_hook"]
-
- @use_display_hook.setter
- def use_display_hook(self, value):
- """
- Property setter for display hook.
- """
- self._properties["use_display_hook"] = value
-
- @property
- def hostname(self):
- """
- Property returning a string of the hostname. Used in the interactive mode's output
- hook.
- """
- return self._properties["hostname"]
-
def __new__(self, **kwargs):
"""
Creates a new instance of LMIReturnValue. At least rval keyword argument must be
@@ -76,17 +53,12 @@ class LMIReturnValue(_RValue):
rval -- return value
rparams -- return parameters
errorstr -- error string
- hostname -- ; default value is "This machine"
- use_display_hook -- ; default value is False
Any other keyword argument will be also stored and is accessible via getattr.
"""
if not "rval" in kwargs:
raise LMIReturnValueError("rval argument missing while instancing LMIReturnValue object")
- properties = {
- "hostname" : "This Machine",
- "use_display_hook" : False
- }
+ properties = {}
keys_to_pop = []
for (key, value) in kwargs.iteritems():
if key in ("rval", "rparams", "errorstr"):
diff --git a/cli/lmi/shell/LMIShellClient.py b/cli/lmi/shell/LMIShellClient.py
index 6ef012f..ca9a927 100644
--- a/cli/lmi/shell/LMIShellClient.py
+++ b/cli/lmi/shell/LMIShellClient.py
@@ -77,12 +77,9 @@ class LMIShellClient(LMIBaseClient):
if class_list is None:
(class_list, _, errorstr) = LMIBaseClient._get_class_names(self, namespace, **kwargs)
if not class_list:
- return LMIReturnValue(
- rval=class_list,
- errorstr=errorstr
- )
+ return LMIReturnValue(rval=class_list, errorstr=errorstr)
self._cache.set_classes(class_list)
- return LMIReturnValue(rval = class_list)
+ return LMIReturnValue(rval=class_list)
return LMIBaseClient._get_class_names(self, namespace, **kwargs)
def _get_class(self, class_name, namespace=None, **kwargs):
@@ -121,10 +118,7 @@ class LMIShellClient(LMIBaseClient):
if klass is None:
(klass, _, errorstr) = LMIBaseClient._get_class(self, class_name, namespace, **kwargs)
if not klass:
- return LMIReturnValue(
- rval=klass,
- errorstr=errorstr
- )
+ return LMIReturnValue(rval=klass, errorstr=errorstr)
self._cache.add_class(klass)
return LMIReturnValue(rval=klass)
return LMIBaseClient._get_class(self, class_name, namespace, **kwargs)
10 years, 9 months
[cura-tools] master: switch shebang to /usr/bin/python (f194617)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit f19461714e4fec45e444350694c9762c314e9cff
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Aug 6 09:22:54 2013 +0200
switch shebang to /usr/bin/python
>---------------------------------------------------------------
cli/lmishell | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli/lmishell b/cli/lmishell
index f49a208..a49a2fa 100755
--- a/cli/lmishell
+++ b/cli/lmishell
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python
# Copyright (C) 2012-2013 Peter Hatina <phatina(a)redhat.com>
#
# This program is free software; you can redistribute it and/or
10 years, 9 months