[cura-tools] master: fix namespace selection in _LmiInstance::associators() (a106363)
by phatina@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit a1063632be4d5fa01a2ce04ce759a82df1780b38
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Nov 26 12:17:35 2012 +0100
fix namespace selection in _LmiInstance::associators()
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_shell.py | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index 2df6f7e..bf626cd 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -397,11 +397,11 @@ class _LmiInstance(BaseObject):
result = []
associators_list = self.m_client.getAssociators(self.m_inst)
for i in associators_list:
- (klass, errorstr) = self.m_client.getClass(i.classname, self.namespace)
- if not klass:
+ (cim_class, errorstr) = self.m_client.getClass(i.classname, i.path.namespace)
+ if not cim_class:
return []
- lmi_namespace = self.m_klass.m_namespace
- lmi_class = _LmiClass(self.m_client, lmi_namespace, klass)
+ lmi_namespace = _LmiNamespace(self.m_client, i.path.namespace)
+ lmi_class = _LmiClass(self.m_client, lmi_namespace, cim_class)
lmi_assoc_inst = _LmiInstance(self.m_client, lmi_class, i)
result.append(lmi_assoc_inst)
return result
11 years, 5 months
[cura-tools] master: fix _LmiInstance::properties(), ::printProperties() (f4f634d)
by phatina@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit f4f634deb40fd7039231083788616bc1c897bfba
Author: Peter Hatina <phatina(a)redhat.com>
Date: Thu Nov 22 14:29:40 2012 +0100
fix _LmiInstance::properties(), ::printProperties()
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_shell.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index 0ee41fd..2df6f7e 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -407,10 +407,11 @@ class _LmiInstance(BaseObject):
return result
def properties(self):
- return self.m_klass.properties()
+ return self.m_inst.properties.keys()
def printProperties(self):
- self.m_klass.printProperties()
+ for (name, prop) in self.m_inst.properties.iteritems():
+ sys.stdout.write("%s\n" % name)
def methods(self):
return self.m_klass.methods()
11 years, 5 months
[cura-tools] master: fix ok/fail message in interactive mode for LMI_PowerManagementService (52d8e13)
by phatina@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 52d8e134cfe2c98e845c419a8b2423861f3e34de
Author: Peter Hatina <phatina(a)redhat.com>
Date: Thu Nov 22 13:41:17 2012 +0100
fix ok/fail message in interactive mode for LMI_PowerManagementService
>---------------------------------------------------------------
cli-tools/lmi-shell.py | 6 +++++-
cli-tools/lmi/lmi_client_base.py | 8 ++++++++
cli-tools/lmi/lmi_client_shell.py | 3 ++-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/cli-tools/lmi-shell.py b/cli-tools/lmi-shell.py
index f0d9963..0da55a1 100755
--- a/cli-tools/lmi-shell.py
+++ b/cli-tools/lmi-shell.py
@@ -31,7 +31,11 @@ def _lmi_displayhook(o):
return
__builtin__._ = None
if isinstance(o, LmiReturnValue):
- sys.stdout.write("%s: %s (%d)" % (o.hostname, "ok" if o.rval == 0 else "fail", o.rval))
+ if o.rval == 0 or (o.rval == 4096 and o.instanceClassname == "LMI_PowerManagementService"):
+ result_str = "ok"
+ else:
+ result_str = "fail"
+ sys.stdout.write("%s: %s (%d)" % (o.hostname, result_str, o.rval))
if o.errorstr:
sys.stdout.write(": %s" % o.errorstr)
sys.stdout.write("\n")
diff --git a/cli-tools/lmi/lmi_client_base.py b/cli-tools/lmi/lmi_client_base.py
index 30ebafb..6acd7ad 100644
--- a/cli-tools/lmi/lmi_client_base.py
+++ b/cli-tools/lmi/lmi_client_base.py
@@ -20,6 +20,10 @@ _RValue = collections.namedtuple('RValue', ["rval", "rparams", "errorstr"])
class LmiReturnValue(_RValue):
@property
+ def instanceClassname(self):
+ return self.m_instance.classname if self.m_instance else ""
+
+ @property
def hostname(self):
return self.m_hostname
@@ -29,9 +33,13 @@ class LmiReturnValue(_RValue):
def __new__(self, **kwargs):
self.m_hostname = "none"
+ self.m_instance = None
if "hostname" in kwargs:
self.m_hostname = kwargs["hostname"]
kwargs.pop("hostname")
+ if "instance" in kwargs:
+ self.m_instance = kwargs["instance"]
+ kwargs.pop("instance")
return _RValue.__new__(self, **kwargs)
class LmiBaseClient(object):
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index 60a9a8c..0ee41fd 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -443,7 +443,8 @@ class _LmiShellClient(LmiBaseClient):
def callMethodRaw(self, instance, method, **params):
(rv, rp, err) = self._callMethodRaw(instance, method, **params)
- return LmiReturnValue(hostname = self.m_hostname, rval = rv, rparams = rp, errorstr = err)
+ return LmiReturnValue(hostname = self.m_hostname, instance = instance,
+ rval = rv, rparams = rp, errorstr = err)
@property
def interactive(self):
11 years, 5 months
[cura-tools] master: update _LmiInstance after a method call (ce03e77)
by phatina@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit ce03e774aa266d8779f2ce965c1dfaeb4de7f336
Author: Peter Hatina <phatina(a)redhat.com>
Date: Thu Nov 22 13:40:00 2012 +0100
update _LmiInstance after a method call
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_base.py | 6 ++++++
cli-tools/lmi/lmi_client_shell.py | 11 ++++++++++-
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_base.py b/cli-tools/lmi/lmi_client_base.py
index 30e04af..30ebafb 100644
--- a/cli-tools/lmi/lmi_client_base.py
+++ b/cli-tools/lmi/lmi_client_base.py
@@ -51,6 +51,12 @@ class LmiBaseClient(object):
return (None, e.args[0])
return (inst_name_list, "")
+ def _getInstance(self, path, **kwargs):
+ inst = self.m_cliconn.GetInstance(path, LocalOnly = False, **kwargs)
+ if not inst:
+ return (None, "No such class instance")
+ return (inst, "")
+
def _getInstances(self, klass, filter_key = "", **kwargs):
(inst_name_list, errorstr) = self._getInstanceNames(klass, **kwargs)
if not inst_name_list:
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index 6b65d50..60a9a8c 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -334,8 +334,14 @@ class _LmiInstance(BaseObject):
if t in cast:
cast_func = cast[t]
kwargs[param] = cast_func(value)
- return self.m_client.callMethodRaw(
+ rval = self.m_client.callMethodRaw(
self.m_instance, self.m_method.name, **kwargs)
+ (new_inst, errorstr) = self.m_client.getInstance(self.m_instance.path)
+ # NOTE: this is wrong! What should be the corrent way?
+ if not new_inst:
+ return rval
+ self.m_instance.m_inst = new_inst
+ return rval
def __init__(self, client, klass, inst):
super(self.__class__, self).__init__()
@@ -420,6 +426,9 @@ class _LmiShellClient(LmiBaseClient):
def getClassNames(self, namespace = None):
return self._getClassNames(namespace, DeepInheritance = True)
+ def getInstance(self, path):
+ return self._getInstance(path)
+
def getInstances(self, class_name, filter_key = "", **kwargs):
(instance_list, _) = self._getInstances(class_name, filter_key, **kwargs)
if not instance_list:
11 years, 5 months
[cura-tools] master: remove wsbios subdir dependency (3d84f21)
by phatina@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 3d84f211d79197cd52ac2dbd448df471b33b68c4
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Nov 19 14:48:41 2012 +0100
remove wsbios subdir dependency
>---------------------------------------------------------------
cli-tools/makefile.am | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cli-tools/makefile.am b/cli-tools/makefile.am
index 3d3b7a1..2c2f7e4 100644
--- a/cli-tools/makefile.am
+++ b/cli-tools/makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = lmi wsbios
+SUBDIRS = lmi
bin_SCRIPTS = \
lmi-ip.py \
11 years, 5 months
[cura-tools] master: bump release version to v0.2 (cb4a9b8)
by phatina@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit cb4a9b84725322431d84a2e8b9a677c471ea7d93
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Nov 19 14:47:18 2012 +0100
bump release version to v0.2
>---------------------------------------------------------------
configure.ac | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/configure.ac b/configure.ac
index d33db4d..056ba5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
AC_PREREQ([2.60])
-AC_INIT([OpenLMI-tools], [0.2pre], [phatina(a)redhat.com])
+AC_INIT([OpenLMI-tools], [0.2], [phatina(a)redhat.com])
AC_CONFIG_MACRO_DIR([m4])
m4_include([m4/python_module.m4])
11 years, 5 months
[cura-tools] master: add completion of properties in lmi-shell.py (e94f253)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit e94f2533ae2553d1b0cf3e098e6851787082881a
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Nov 19 10:01:50 2012 +0100
add completion of properties in lmi-shell.py
>---------------------------------------------------------------
cli-tools/lmi-shell.py | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/cli-tools/lmi-shell.py b/cli-tools/lmi-shell.py
index 1c08616..f0d9963 100755
--- a/cli-tools/lmi-shell.py
+++ b/cli-tools/lmi-shell.py
@@ -98,6 +98,13 @@ class _LmiCompleter(rlcompleter.Completer):
and m.lower().startswith(text.lower()), dir(obj))
return result
+ def __completeObjectProperties(self, obj, text):
+ result = filter(lambda m: not m.startswith("_") \
+ and not m.startswith("m_") \
+ and not callable(getattr(obj, m)) \
+ and m.lower().startswith(text.lower()), dir(obj))
+ return result
+
def _callable_postfix(self, val, word):
if hasattr(val, '__call__') \
and not isinstance(val, (_LmiNamespace, _LmiClass, _LmiInstance)):
@@ -127,10 +134,14 @@ class _LmiCompleter(rlcompleter.Completer):
self.m_last_complete.append(cmd + "." + c)
methods = self.__completeObjectMethods(expr, to_complete)
self.m_last_complete.extend(cmd + "." + m + "(" for m in methods)
+ properties = self.__completeObjectProperties(expr, to_complete)
+ self.m_last_complete.extend(cmd + "." + p for p in properties)
return self.m_last_complete[state]
elif isinstance(expr, _LmiClass):
methods = self.__completeObjectMethods(expr, to_complete)
self.m_last_complete= [cmd + "." + m + "(" for m in methods]
+ properties = self.__completeObjectProperties(expr, to_complete)
+ self.m_last_complete.extend(cmd + "." + p for p in properties)
return self.m_last_complete[state]
elif isinstance(expr, _LmiInstance):
for m in expr.methods():
@@ -141,6 +152,8 @@ class _LmiCompleter(rlcompleter.Completer):
self.m_last_complete.append(cmd + "." + p)
methods = self.__completeObjectMethods(expr, to_complete)
self.m_last_complete.extend(cmd + "." + m + "(" for m in methods)
+ properties = self.__completeObjectProperties(expr, to_complete)
+ self.m_last_complete.extend(cmd + "." + p for p in properties)
return self.m_last_complete[state]
return rlcompleter.Completer.complete(self, text, state)
11 years, 5 months
[cura-tools] master: introduce _LmiInstance::associators() (c7a6cdb)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit c7a6cdb0ac9ede1faea3821d9ca087170747be6b
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Nov 19 09:19:01 2012 +0100
introduce _LmiInstance::associators()
>---------------------------------------------------------------
cli-tools/lmi/lmi_client_base.py | 3 +++
cli-tools/lmi/lmi_client_shell.py | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/cli-tools/lmi/lmi_client_base.py b/cli-tools/lmi/lmi_client_base.py
index 1dacb4d..30e04af 100644
--- a/cli-tools/lmi/lmi_client_base.py
+++ b/cli-tools/lmi/lmi_client_base.py
@@ -110,3 +110,6 @@ class LmiBaseClient(object):
def _callMethod(self, instance, method, **params):
(rval, rparams, errorstr) = self._callMethodRaw(instance, method, **params)
return (rval == 0, rparams, errorstr)
+
+ def _getAssociators(self, instance, **params):
+ return self.m_cliconn.Associators(instance.path, **params)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index ba18c2f..6b65d50 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -387,6 +387,19 @@ class _LmiInstance(BaseObject):
def doc(self):
_LmiXmlFormatter(self.m_inst.tocimxml()).fancyFormat(self.m_client.interactive)
+ def associators(self):
+ result = []
+ associators_list = self.m_client.getAssociators(self.m_inst)
+ for i in associators_list:
+ (klass, errorstr) = self.m_client.getClass(i.classname, self.namespace)
+ if not klass:
+ return []
+ lmi_namespace = self.m_klass.m_namespace
+ lmi_class = _LmiClass(self.m_client, lmi_namespace, klass)
+ lmi_assoc_inst = _LmiInstance(self.m_client, lmi_class, i)
+ result.append(lmi_assoc_inst)
+ return result
+
def properties(self):
return self.m_klass.properties()
@@ -416,6 +429,9 @@ class _LmiShellClient(LmiBaseClient):
def getClass(self, class_name, namespace = None):
return self._getClass(class_name, namespace)
+ def getAssociators(self, instance):
+ return self._getAssociators(instance)
+
def callMethodRaw(self, instance, method, **params):
(rv, rp, err) = self._callMethodRaw(instance, method, **params)
return LmiReturnValue(hostname = self.m_hostname, rval = rv, rparams = rp, errorstr = err)
11 years, 5 months
[cura-tools] master: introduce display sugar for _LmiInstance::methodcall() (c642ee0)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit c642ee004009b8ed8aa50051ed07c37ad7dc009a
Author: Peter Hatina <phatina(a)redhat.com>
Date: Thu Nov 15 14:54:29 2012 +0100
introduce display sugar for _LmiInstance::methodcall()
>---------------------------------------------------------------
cli-tools/lmi-shell.py | 21 +++++++++++++++++++++
cli-tools/lmi/lmi_client_base.py | 19 +++++++++++++++++++
cli-tools/lmi/lmi_client_shell.py | 4 +++-
3 files changed, 43 insertions(+), 1 deletions(-)
diff --git a/cli-tools/lmi-shell.py b/cli-tools/lmi-shell.py
index 409ddda..1c08616 100755
--- a/cli-tools/lmi-shell.py
+++ b/cli-tools/lmi-shell.py
@@ -19,11 +19,28 @@ import sys
import code
import readline
import rlcompleter
+import __builtin__
+from lmi.lmi_client_base import LmiReturnValue
from lmi.lmi_client_shell import LmiConnection
from lmi.lmi_client_shell import _LmiNamespace
from lmi.lmi_client_shell import _LmiClass
from lmi.lmi_client_shell import _LmiInstance
+def _lmi_displayhook(o):
+ if o == None:
+ return
+ __builtin__._ = None
+ if isinstance(o, LmiReturnValue):
+ sys.stdout.write("%s: %s (%d)" % (o.hostname, "ok" if o.rval == 0 else "fail", o.rval))
+ if o.errorstr:
+ sys.stdout.write(": %s" % o.errorstr)
+ sys.stdout.write("\n")
+ else:
+ print o
+ __builtin__._ = o
+
+sys.displayhook = _lmi_displayhook
+
class _LmiShellOptions(object):
def __init__(self, argv):
self.m_argv = argv
@@ -136,6 +153,7 @@ class LmiInteractiveShell(code.InteractiveConsole):
locals["LmiConnection"] = LmiConnection
locals["connect"] = _connect_interactive
locals["clear_history"] = self.clearHistory
+ locals["use_display_sugar"] = _use_display_sugar
code.InteractiveConsole.__init__(self, locals)
self.m_completer = _LmiCompleter(self.locals)
self.m_history_path = os.path.expanduser("~/.lmi_shell_history")
@@ -226,6 +244,9 @@ def _connect(hostname, username = "", password = "", interactive = False):
readline.remove_history_item(readline.get_current_history_length() - 1)
return LmiConnection(hostname, username, password, interactive)
+def _use_display_sugar(use = True):
+ sys.displayhook = _lmi_displayhook if use else sys.__displayhook__
+
if __name__ == "__main__":
options = _LmiShellOptions(sys.argv)
if options.help:
diff --git a/cli-tools/lmi/lmi_client_base.py b/cli-tools/lmi/lmi_client_base.py
index 0a26972..1dacb4d 100644
--- a/cli-tools/lmi/lmi_client_base.py
+++ b/cli-tools/lmi/lmi_client_base.py
@@ -14,6 +14,25 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
import pywbem
+import collections
+
+_RValue = collections.namedtuple('RValue', ["rval", "rparams", "errorstr"])
+
+class LmiReturnValue(_RValue):
+ @property
+ def hostname(self):
+ return self.m_hostname
+
+ @hostname.setter
+ def hostname(self, hostname):
+ self.m_hostname = hostname
+
+ def __new__(self, **kwargs):
+ self.m_hostname = "none"
+ if "hostname" in kwargs:
+ self.m_hostname = kwargs["hostname"]
+ kwargs.pop("hostname")
+ return _RValue.__new__(self, **kwargs)
class LmiBaseClient(object):
def __init__(self, hostname, username = "", password = ""):
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index 09fd49c..ba18c2f 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -22,6 +22,7 @@ import tempfile
import subprocess
from xml.dom.minicompat import NodeList
from lmi_client_base import LmiBaseClient
+from lmi_client_base import LmiReturnValue
class _LmiErrorHandler(object):
def __init__(self, errormsg):
@@ -416,7 +417,8 @@ class _LmiShellClient(LmiBaseClient):
return self._getClass(class_name, namespace)
def callMethodRaw(self, instance, method, **params):
- return self._callMethodRaw(instance, method, **params)
+ (rv, rp, err) = self._callMethodRaw(instance, method, **params)
+ return LmiReturnValue(hostname = self.m_hostname, rval = rv, rparams = rp, errorstr = err)
@property
def interactive(self):
11 years, 5 months
[cura-tools] master: do not use pager when running in noninteractive mode, lmi-shell.py (520b602)
by phatina@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 520b6026c8b34a4b9e7644a9fbe118394fcbb857
Author: Peter Hatina <phatina(a)redhat.com>
Date: Thu Nov 15 13:07:37 2012 +0100
do not use pager when running in noninteractive mode, lmi-shell.py
>---------------------------------------------------------------
cli-tools/lmi-shell.py | 14 ++++++++++----
cli-tools/lmi/lmi_client_shell.py | 30 +++++++++++++++++++-----------
2 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/cli-tools/lmi-shell.py b/cli-tools/lmi-shell.py
index 46353aa..409ddda 100755
--- a/cli-tools/lmi-shell.py
+++ b/cli-tools/lmi-shell.py
@@ -134,7 +134,7 @@ class LmiInteractiveShell(code.InteractiveConsole):
if locals == None:
locals = {}
locals["LmiConnection"] = LmiConnection
- locals["connect"] = _connect
+ locals["connect"] = _connect_interactive
locals["clear_history"] = self.clearHistory
code.InteractiveConsole.__init__(self, locals)
self.m_completer = _LmiCompleter(self.locals)
@@ -191,7 +191,13 @@ def _lmi_interact(prompt = "> ", more_prompt = "... "):
console = LmiInteractiveShell(prompt, more_prompt)
console.interact()
-def _connect(hostname, username = "", password = ""):
+def _connect_interactive(hostname, username = "", password = ""):
+ return _connect(hostname, username, password, True)
+
+def _connect_noninteractive(hostname, username = "", password = ""):
+ return _connect(hostname, username, password, False)
+
+def _connect(hostname, username = "", password = "", interactive = False):
if not username:
while True:
try:
@@ -218,7 +224,7 @@ def _connect(hostname, username = "", password = ""):
return None
sys.stdout.write("\n")
readline.remove_history_item(readline.get_current_history_length() - 1)
- return LmiConnection(hostname, username, password)
+ return LmiConnection(hostname, username, password, interactive)
if __name__ == "__main__":
options = _LmiShellOptions(sys.argv)
@@ -231,7 +237,7 @@ if __name__ == "__main__":
else:
locals = {
"LmiConnection" : LmiConnection,
- "connect" : _connect
+ "connect" : _connect_noninteractive
}
sys.argv = options.scriptArgs
execfile(options.scriptName, locals)
diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py
index e785802..09fd49c 100644
--- a/cli-tools/lmi/lmi_client_shell.py
+++ b/cli-tools/lmi/lmi_client_shell.py
@@ -203,12 +203,15 @@ class _LmiXmlFormatter(object):
elif isinstance(self.m_xml, pywbem.cim_xml.VALUE_NAMEDINSTANCE):
self.__formatInstance(self.m_xml, indent, sub_indent, width, fd)
- def fancyFormat(self):
- tmpfile = tempfile.mkstemp()
- self.format(0, 0, self.m_width, tmpfile[0])
- os.close(tmpfile[0])
- subprocess.call([self.__getPager(), tmpfile[1]])
- os.remove(tmpfile[1])
+ def fancyFormat(self, interactive):
+ if interactive:
+ tmpfile = tempfile.mkstemp()
+ self.format(0, 0, self.m_width, tmpfile[0])
+ os.close(tmpfile[0])
+ subprocess.call([self.__getPager(), tmpfile[1]])
+ os.remove(tmpfile[1])
+ else:
+ self.format(0, 0, self.m_width)
# Base class for classes, that are used for tab-completion.
# Used due to deprecated methods since python 2.2.
@@ -266,7 +269,7 @@ class _LmiClass(BaseObject):
self.m_klass = klass
def doc(self):
- _LmiXmlFormatter(self.m_klass.tocimxml()).fancyFormat()
+ _LmiXmlFormatter(self.m_klass.tocimxml()).fancyFormat(self.m_client.interactive)
def instances(self, filter_key = "", **kwargs):
instance_list = self.m_client.getInstances(self.m_klass.classname, filter_key, **kwargs)
@@ -381,7 +384,7 @@ class _LmiInstance(BaseObject):
return self.m_inst.path
def doc(self):
- _LmiXmlFormatter(self.m_inst.tocimxml()).fancyFormat()
+ _LmiXmlFormatter(self.m_inst.tocimxml()).fancyFormat(self.m_client.interactive)
def properties(self):
return self.m_klass.properties()
@@ -396,8 +399,9 @@ class _LmiInstance(BaseObject):
self.m_klass.printMethods()
class _LmiShellClient(LmiBaseClient):
- def __init__(self, hostname, username = "", password = ""):
+ def __init__(self, hostname, username = "", password = "", interactive = False):
super(self.__class__, self).__init__(hostname, username, password)
+ self.m_interactive = interactive
def getClassNames(self, namespace = None):
return self._getClassNames(namespace, DeepInheritance = True)
@@ -414,9 +418,13 @@ class _LmiShellClient(LmiBaseClient):
def callMethodRaw(self, instance, method, **params):
return self._callMethodRaw(instance, method, **params)
+ @property
+ def interactive(self):
+ return self.m_interactive
+
class LmiConnection(object):
- def __init__(self, hostname, username = "", password = ""):
- self.m_shell_client = _LmiShellClient(hostname, username, password)
+ def __init__(self, hostname, username = "", password = "", interactive = False):
+ self.m_shell_client = _LmiShellClient(hostname, username, password, interactive)
def namespaces(self):
return ["root", "cimv2", "interop"]
11 years, 5 months