Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
List overview
Download
cura-tools-devel
March 2013
----- 2024 -----
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
cura-tools-devel@lists.fedorahosted.org
1 participants
17 discussions
Start a n
N
ew thread
[cura-tools] master: add nonexisting class check (fff8278)
by phatina@fedoraproject.org
13 Mar '13
13 Mar '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit fff82781663bfe383b774e4fc3864418257f0786 Author: Peter Hatina <phatina(a)redhat.com> Date: Wed Mar 13 14:34:07 2013 +0100 add nonexisting class check >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 986375e..1aa593e 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -398,7 +398,9 @@ class _LmiNamespace(BaseObject): self._name = name def __getattr__(self, name): - # TODO: check class existance, otherwise return None + (class_list, _, _) = self._client._get_class_names(self._name, DeepInheritance = True) + if not class_list or not name in class_list: + return None return _LmiClass(self._client, self, name) def __repr__(self):
1
0
0
0
[cura-tools] master: code cleanup in LmiBaseClient (8b90b25)
by phatina@fedoraproject.org
13 Mar '13
13 Mar '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 8b90b259c5a9bbe311ee00404c5d3e24679aa076 Author: Peter Hatina <phatina(a)redhat.com> Date: Wed Mar 13 11:55:34 2013 +0100 code cleanup in LmiBaseClient >--------------------------------------------------------------- cli-tools/lmi/lmi_client_base.py | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cli-tools/lmi/lmi_client_base.py b/cli-tools/lmi/lmi_client_base.py index cf96987..2b34823 100644 --- a/cli-tools/lmi/lmi_client_base.py +++ b/cli-tools/lmi/lmi_client_base.py @@ -114,7 +114,7 @@ class LmiBaseClient(object): return LmiReturnValue(rval = None, errorstr = e.args[0]) if filter_value: inst_name_list = filter(lambda n: not filter_key in n or n[filter_key] == filter_value, inst_name_list) - return LmiReturnValue(rval = inst_name_list, errorstr = "") + return LmiReturnValue(rval = inst_name_list) def _get_instance(self, path, **kwargs): try: @@ -125,7 +125,7 @@ class LmiBaseClient(object): except pywbem.cim_http.AuthError, e: raise_or_dump_exception(e) return LmiReturnValue(rval = None, errorstr = e.args[0]) - return LmiReturnValue(rval = inst, errorstr = "") + return LmiReturnValue(rval = inst) def _get_instances(self, class_name, namespace = None, **kwargs): filter_value = "" @@ -159,7 +159,7 @@ class LmiBaseClient(object): except pywbem.cim_http.AuthError, e: raise_or_dump_exception(e) return LmiReturnValue(rval = None, errorstr = e.args[0]) - return LmiReturnValue(rval = class_name_list, errorstr = "") + return LmiReturnValue(rval = class_name_list) def _get_classes(self, namespace = None, **kwargs): try: @@ -170,7 +170,7 @@ class LmiBaseClient(object): except pywbem.cim_http.AuthError, e: raise_or_dump_exception(e) return LmiReturnValue(rval = None, errorstr = e.args[0]) - return LmiReturnValue(rval = class_list, errorstr = "") + return LmiReturnValue(rval = class_list) def _get_class(self, class_name, namespace = None, **kwargs): try: @@ -181,7 +181,7 @@ class LmiBaseClient(object): except pywbem.cim_http.AuthError, e: raise_or_dump_exception(e) return LmiReturnValue(rval = None, errorstr = e.args[0]) - return LmiReturnValue(rval = klass, errorstr = "") + return LmiReturnValue(rval = klass) def _call_method_raw(self, instance, method, **params): try: @@ -192,7 +192,7 @@ class LmiBaseClient(object): except pywbem.cim_http.AuthError, e: raise_or_dump_exception(e) return LmiReturnValue(rval = -1, errorstr = e.args[0] + ": '" + method + "'") - return LmiReturnValue(rval = rval, rparams = rparams, errorstr = "") + return LmiReturnValue(rval = rval, rparams = rparams) def _call_method(self, instance, method, **params): (rval, rparams, errorstr) = self._call_method_raw(instance, method, **params) @@ -248,7 +248,7 @@ class LmiBaseClient(object): except pywbem.cim_http.AuthError, e: raise_or_dump_exception(e) return LmiReturnValue(rval = -1, errorstr = e.args[0]) - return LmiReturnValue(rval = 0, errorstr = "") + return LmiReturnValue(rval = 0) def _delete_instance(self, instance, **params): try: @@ -259,7 +259,7 @@ class LmiBaseClient(object): except pywbem.cim_http.AuthError, e: raise_or_dump_exception(e) return LmiReturnValue(rval = -1, errorstr = e.args[0]) - return LmiReturnValue(rval = 0, errorstr = "") + return LmiReturnValue(rval = 0) def _exec_query(self, query_lang, query, namespace = None): try: @@ -270,7 +270,7 @@ class LmiBaseClient(object): except pywbem.cim_http.AuthError, e: raise_or_dump_exception(e) return LmiReturnValue(rval = [], errorstr = e.args[0]) - return LmiReturnValue(rval = inst_list, errorstr = "") + return LmiReturnValue(rval = inst_list) @staticmethod def _set_use_exceptions(use = True):
1
0
0
0
[cura-tools] master: introduce class caching (28a0590)
by phatina@fedoraproject.org
13 Mar '13
13 Mar '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 28a05908f38ca6a5da1cef5039137870dfb0c039 Author: Peter Hatina <phatina(a)redhat.com> Date: Wed Mar 13 10:56:19 2013 +0100 introduce class caching >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 71 ++++++++++++++++++++++++++++++++- cli-tools/lmishell | 78 ++++++++++++++++++++++-------------- 2 files changed, 116 insertions(+), 33 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 2f5bda2..986375e 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -967,18 +967,77 @@ class _LmiInstance(BaseObject): rval = self._client._delete_instance(self.path) self._deleted = rval.rval == 0 +class _LmiShellCache(object): + def __init__(self, active = True, classname_list = None, classes = {}): + self._classname_list = classname_list + self._classes = classes + self._active = active + + def clear(self): + self._classname_list = None + self._classes = {} + + def get_classes(self): + return self._classname_list + + def set_classes(self, classname_list): + self._classname_list = classname_list + + def get_class(self, classname): + if not classname in self._classes: + return None + return self._classes[classname] + + def add_class(self, cim_class): + self._classes[cim_class.classname] = cim_class + + @property + def active(self): + return self._active + + @active.setter + def active(self, val): + self._active = val + class _LmiShellClient(LmiBaseClient): - def __init__(self, hostname, username = "", password = "", interactive = False): + def __init__(self, hostname, username = "", password = "", interactive = False, use_cache = True): super(self.__class__, self).__init__(hostname, username, password) self._interactive = interactive + self._cache = _LmiShellCache(use_cache) + + def _get_class_names(self, namespace = None, **kwargs): + if self._cache.active: + class_list = self._cache.get_classes() + 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) + self._cache.set_classes(class_list) + return LmiReturnValue(rval = class_list) + return LmiBaseClient._get_class_names(self, namespace, **kwargs) + + def _get_class(self, class_name, namespace = None, **kwargs): + if self._cache.active: + klass = self._cache.get_class(class_name) + if klass is None: + (klass, _, errorstr) = LmiBaseClient._get_class(self, class_name, namespace, **kwargs) + if not klass: + return LmiReturnValue(rval = klass, errorstr = errorstr) + self._cache.add_class(klass) + return LmiReturnValue(rval = klass) + return LmiBaseClient._get_class(self, class_name, namespace, **kwargs) @property def interactive(self): return self._interactive + @interactive.setter + def interactive(self, i): + self._interactive = bool(i) + class LmiConnection(object): - def __init__(self, hostname, username = "", password = "", interactive = False): - self._client = _LmiShellClient(hostname, username, password, interactive) + def __init__(self, hostname, username = "", password = "", interactive = False, use_cache = True): + self._client = _LmiShellClient(hostname, username, password, interactive, use_cache) @property def hostname(self): @@ -991,6 +1050,12 @@ class LmiConnection(object): def print_namespaces(self): sys.stdout.write("root\n") + def clear_cache(self): + self._client._cache.clear() + + def use_cache(self, active = True): + self._client._cache.active = active + @property def root(self): return _LmiNamespaceRoot(self._client) diff --git a/cli-tools/lmishell b/cli-tools/lmishell index 4bb3849..f50731b 100755 --- a/cli-tools/lmishell +++ b/cli-tools/lmishell @@ -179,10 +179,42 @@ class _LmiCompleter(rlcompleter.Completer): return self._last_complete[state] return rlcompleter.Completer.complete(self, text, state) -class LmiInteractiveShell(code.InteractiveConsole): +class LmiInteractiveShellConfig(object): DEFAULT_CONFIG_FILE = "~/.lmishellrc" DEFAULT_HISTORY_FILE = "~/.lmi_shell_history" DEFAULT_HISTORY_LENGTH = -1 + DEFAULT_USE_CACHE = True + + def __init__(self): + try: + conf = {} + execfile(os.path.expanduser(LmiInteractiveShellConfig.DEFAULT_CONFIG_FILE), conf) + self._history_file = os.path.expanduser(get_item_or_default(conf, "history_file", + LmiInteractiveShellConfig.DEFAULT_HISTORY_FILE)) + self._history_length = get_item_or_default(conf, "history_length", + LmiInteractiveShellConfig.DEFAULT_HISTORY_LENGTH) + self._use_cache = get_item_or_default(conf, "use_cache", + LmiInteractiveShellConfig.DEFAULT_USE_CACHE) + except (SyntaxError, IOError), e: + if isinstance(e, SyntaxError): + sys.stderr.write("Error: %s\n" % e) + self._history_file = os.path.expanduser(LmiInteractiveShellConfig.DEFAULT_HISTORY_FILE) + self._history_length = LmiInteractiveShellConfig.DEFAULT_HISTORY_LENGTH + self._use_cache = LmiInteractiveShellConfig.DEFAULT_USE_CACHE + + @property + def history_file(self): + return self._history_file + + @property + def history_length(self): + return self._history_length + + @property + def use_cache(self): + return self._use_cache + +class LmiInteractiveShell(code.InteractiveConsole): DEFAULT_LOCALS = { "LmiConnection" : LmiConnection, "use_exceptions" : LmiBaseClient._set_use_exceptions, @@ -195,18 +227,25 @@ class LmiInteractiveShell(code.InteractiveConsole): "indication_listeners" : _lmi_indication_listeners_list } - def __init__(self, prompt, more_prompt, locals = None, **kwargs): + def __init__(self, prompt, more_prompt, locals = None, use_cache = True): sys.ps1 = prompt sys.ps2 = more_prompt if locals is None: locals = {} + else: + for (k, v) in locals.iteritems(): + if isinstance(v, LmiConnection): + locals[k]._client.interactive = True locals = dict(locals.items() + LmiInteractiveShell.DEFAULT_LOCALS.items()) - locals["connect"] = _connect_interactive locals["clear_history"] = self.clear_history locals["use_display_sugar"] = _use_display_sugar code.InteractiveConsole.__init__(self, locals) self._completer = _LmiCompleter(self.locals) - self.load_config(get_item_or_default(kwargs, "config", LmiInteractiveShell.DEFAULT_CONFIG_FILE)) + config = LmiInteractiveShellConfig() + self._history_file = config.history_file + self._history_length = config.history_length + self._use_cache = config.use_cache + locals["connect"] = lambda h, u = "", p = "": _connect(h, u, p, True, self._use_cache) readline.set_completer(self._completer.complete) readline.parse_and_bind('tab: complete') @@ -244,20 +283,6 @@ class LmiInteractiveShell(code.InteractiveConsole): more = 0 self.save_history() - def load_config(self, config_file): - try: - conf = {} - execfile(os.path.expanduser(config_file), conf) - self._history_file = os.path.expanduser(get_item_or_default(conf, "history_file", - LmiInteractiveShell.DEFAULT_HISTORY_FILE)) - self._history_length = get_item_or_default(conf, "history_length", - LmiInteractiveShell.DEFAULT_HISTORY_LENGTH) - except (SyntaxError, IOError), e: - if isinstance(e, SyntaxError): - sys.stderr.write("Error: %s\n" % e) - self._history_file = os.path.expanduser(LmiInteractiveShell.DEFAULT_HISTORY_FILE) - self._history_length = LmiInteractiveShell.DEFAULT_HISTORY_LENGTH - def load_history(self): if self._history_length == 0 or not os.path.exists(self._history_file): return @@ -281,13 +306,7 @@ def _lmi_interact(locals = None): console = LmiInteractiveShell("> ", "... ", locals) console.interact() -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): +def _connect(hostname, username = "", password = "", interactive = False, use_cache = True): if not username: while True: try: @@ -315,7 +334,7 @@ def _connect(hostname, username = "", password = "", interactive = False): sys.stdout.write("\n") readline.remove_history_item(readline.get_current_history_length() - 1) # Try to get some non-existing class as a login check - connection = LmiConnection(hostname, username, password, interactive) + connection = LmiConnection(hostname, username, password, interactive, use_cache) use_exceptions = LmiBaseClient._get_use_exceptions() try: LmiBaseClient._set_use_exceptions(True) @@ -349,8 +368,10 @@ if __name__ == "__main__": if options.interactive: _lmi_interact() else: + config = LmiInteractiveShellConfig() + use_cache = config.use_cache locals = copy.deepcopy(LmiInteractiveShell.DEFAULT_LOCALS) - locals["connect"] = _connect_noninteractive + locals["connect"] = lambda h, u = "", p = "": _connect(h, u, p, False, use_cache) sys.argv = options.script_args try: execfile(options.script_name, locals) @@ -358,8 +379,5 @@ if __name__ == "__main__": if not options.inspect: sys.exit(e.code) if options.inspect: - for (k, v) in locals.iteritems(): - if isinstance(v, LmiConnection): - locals[k]._client._interactive = True _lmi_interact(locals) sys.exit(0)
1
0
0
0
[cura-tools] master: introduce lazy fetching of CIMClass (2ecab36)
by phatina@fedoraproject.org
13 Mar '13
13 Mar '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 2ecab36a8014fb0cc5a90845c3c947f531b2452e Author: Peter Hatina <phatina(a)redhat.com> Date: Tue Mar 12 14:47:44 2013 +0100 introduce lazy fetching of CIMClass >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 58 ++++++++++++++++++------------------- 1 files changed, 28 insertions(+), 30 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 232dfe5..2f5bda2 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -398,10 +398,8 @@ class _LmiNamespace(BaseObject): self._name = name def __getattr__(self, name): - (klass, _, errorstr) = self._client._get_class(name, self._name, LocalOnly = False) - if not klass: - return None - return _LmiClass(self._client, self, klass) + # TODO: check class existance, otherwise return None + return _LmiClass(self._client, self, name) def __repr__(self): return "%s(namespace='%s', ...)" % (self.__class__.__name__, self._name) @@ -544,12 +542,22 @@ class _LmiNamespaceRoot(_LmiNamespace): sys.stdout.write("PG_InterOp\n") sys.stdout.write("PG_Internal\n") +def lmi_class_fetch_lazy(fn): + def wrapped(self, *args, **kwargs): + if not self._cim_class: + # FIXME: this is wrong, throw an exception? + (self._cim_class, _, _) = self._client._get_class( + self._cim_classname, self._namespace.name, LocalOnly = False) + return fn(self, *args, **kwargs) + return wrapped + class _LmiClass(BaseObject): - def __init__(self, client, namespace, klass): + def __init__(self, client, namespace, classname): super(self.__class__, self).__init__() - self._client = client - self._namespace = namespace - self._cim_class = klass + self.__dict__["_client"] = client + self.__dict__["_namespace"] = namespace + self.__dict__["_cim_class"] = None + self.__dict__["_cim_classname"] = classname def __repr__(self): return "%s(classname='%s', ...)" % (self.__class__.__name__, self.classname) @@ -569,12 +577,13 @@ class _LmiClass(BaseObject): return None return _LmiInstance(self._client, self, cim_instance) + @lmi_class_fetch_lazy def doc(self): _LmiXmlFormatter(self._cim_class.tocimxml()).fancy_format(self._client.interactive) def instance_names(self, **kwargs): (inst_name_list, _, errorstr) = self._client._get_instance_names( - self._cim_class.classname, namespace = self._namespace.name, **kwargs) + self._cim_classname, namespace = self._namespace.name, **kwargs) if not inst_name_list: return [] result = [] @@ -590,7 +599,7 @@ class _LmiClass(BaseObject): def instances(self, **kwargs): (instance_list, _, errorstr) = self._client._get_instances( - self._cim_class.classname, self._namespace.name, **kwargs) + self._cim_classname, self._namespace.name, **kwargs) if not instance_list: return [] return map(lambda inst: _LmiInstance(self._client, self, inst), instance_list) @@ -603,23 +612,27 @@ class _LmiClass(BaseObject): return None return inst_name.to_instance() + @lmi_class_fetch_lazy def properties(self): return self._cim_class.properties.keys() + @lmi_class_fetch_lazy def print_properties(self): for prop in self._cim_class.properties.keys(): sys.stdout.write("%s\n" % prop) + @lmi_class_fetch_lazy def methods(self): return self._cim_class.methods.keys() + @lmi_class_fetch_lazy def print_methods(self): for method in self._cim_class.methods.keys(): sys.stdout.write("%s\n" % method) @property def classname(self): - return self._cim_class.classname + return self._cim_classname @property def namespace(self): @@ -639,15 +652,8 @@ class _LmiInstanceName(BaseObject): if not cim_instance: return None lmi_namespace = _LmiNamespace(self._client, self._cim_instance_name.namespace) - (cim_class, _, errorstr) = self._client._get_class( - self._cim_instance_name.classname, - self._cim_instance_name.namespace, - LocalOnly = False) - if not cim_class: - return None - lmi_class = _LmiClass(self._client, lmi_namespace, cim_class) - if not lmi_class: - return None + cim_classname = self._cim_instance_name.classname + lmi_class = _LmiClass(self._client, lmi_namespace, cim_classname) return _LmiInstance(self._client, lmi_class, cim_instance) @property @@ -867,12 +873,8 @@ class _LmiInstance(BaseObject): assoc_args["Props"] = Props associators_list = self._client._get_associators(self._cim_instance, **assoc_args) for i in associators_list: - (cim_class, _, errorstr) = self._client._get_class(i.classname, i.path.namespace, - LocalOnly = False) - if not cim_class: - return [] lmi_namespace = _LmiNamespace(self._client, i.path.namespace) - lmi_class = _LmiClass(self._client, lmi_namespace, cim_class) + lmi_class = _LmiClass(self._client, lmi_namespace, i.classname) lmi_assoc_inst = _LmiInstance(self._client, lmi_class, i) result.append(lmi_assoc_inst) return result @@ -919,12 +921,8 @@ class _LmiInstance(BaseObject): references_args["Props"] = Props references_list = self._client._get_references(self._cim_instance, **references_args) for i in references_list: - (cim_class, _, errorstr) = self._client._get_class(i.classname, i.path.namespace, - LocalOnly = False) - if not cim_class: - return [] lmi_namespace = _LmiNamespace(self._client, i.path.namespace) - lmi_class = _LmiClass(self._client, lmi_namespace, cim_class) + lmi_class = _LmiClass(self._client, lmi_namespace, i.classname) lmi_references_inst = _LmiInstance(self._client, lmi_class, i) result.append(lmi_references_inst) return result
1
0
0
0
[cura-tools] master: switch LmiConnection objects to interactive mode, when inspect parameter provided (9b0fc15)
by phatina@fedoraproject.org
13 Mar '13
13 Mar '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 9b0fc1524fb28e1ecd13609c0efbc8b099de9de4 Author: Peter Hatina <phatina(a)redhat.com> Date: Tue Mar 12 13:52:08 2013 +0100 switch LmiConnection objects to interactive mode, when inspect parameter provided >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 6 +++--- cli-tools/lmishell | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 68e98af..232dfe5 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -980,11 +980,11 @@ class _LmiShellClient(LmiBaseClient): class LmiConnection(object): def __init__(self, hostname, username = "", password = "", interactive = False): - self._shell_client = _LmiShellClient(hostname, username, password, interactive) + self._client = _LmiShellClient(hostname, username, password, interactive) @property def hostname(self): - return self._shell_client._hostname + return self._client._hostname @property def namespaces(self): @@ -995,4 +995,4 @@ class LmiConnection(object): @property def root(self): - return _LmiNamespaceRoot(self._shell_client) + return _LmiNamespaceRoot(self._client) diff --git a/cli-tools/lmishell b/cli-tools/lmishell index 6ae4755..4bb3849 100755 --- a/cli-tools/lmishell +++ b/cli-tools/lmishell @@ -358,5 +358,8 @@ if __name__ == "__main__": if not options.inspect: sys.exit(e.code) if options.inspect: + for (k, v) in locals.iteritems(): + if isinstance(v, LmiConnection): + locals[k]._client._interactive = True _lmi_interact(locals) sys.exit(0)
1
0
0
0
[cura-tools] master: code cleanup in _LmiClass::print_methods() (667738f)
by phatina@fedoraproject.org
13 Mar '13
13 Mar '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 667738fb5ba345a1678354f796290f991400130c Author: Peter Hatina <phatina(a)redhat.com> Date: Tue Mar 12 13:20:55 2013 +0100 code cleanup in _LmiClass::print_methods() >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 06ba075..68e98af 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -614,8 +614,8 @@ class _LmiClass(BaseObject): return self._cim_class.methods.keys() def print_methods(self): - for (name, method) in self._cim_class.methods.iteritems(): - sys.stdout.write("%s\n" % name) + for method in self._cim_class.methods.keys(): + sys.stdout.write("%s\n" % method) @property def classname(self):
1
0
0
0
[cura-tools] master: code cleanup in _LmiClass::print_properties() (41e0e0d)
by phatina@fedoraproject.org
13 Mar '13
13 Mar '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 41e0e0d812b5369fd3861457447fc70c770b152d Author: Peter Hatina <phatina(a)redhat.com> Date: Tue Mar 12 13:20:30 2013 +0100 code cleanup in _LmiClass::print_properties() >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index f1118c8..06ba075 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -607,8 +607,8 @@ class _LmiClass(BaseObject): return self._cim_class.properties.keys() def print_properties(self): - for (name, prop) in self._cim_class.properties.iteritems(): - sys.stdout.write("%s\n" % name) + for prop in self._cim_class.properties.keys(): + sys.stdout.write("%s\n" % prop) def methods(self): return self._cim_class.methods.keys()
1
0
0
0
[cura-tools] master: drop default None parameter as self in possibly_deleted decorator (09c19a7)
by phatina@fedoraproject.org
13 Mar '13
13 Mar '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 09c19a7dd3bd5e7917dc68c20e1eec397a1b02ff Author: Peter Hatina <phatina(a)redhat.com> Date: Tue Mar 12 13:03:23 2013 +0100 drop default None parameter as self in possibly_deleted decorator >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 18cb7d2..f1118c8 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -655,7 +655,7 @@ class _LmiInstanceName(BaseObject): return self._cim_instance_name def possibly_deleted(fn): - def wrapped(self = None, *args, **kwargs): + def wrapped(self, *args, **kwargs): if not self._deleted: return fn(self, *args, **kwargs) errorstr = "This instance has been deleted from a CIM broker"
1
0
0
0
[cura-tools] master: optimize instances filtering in LmiBaseClient::_get_instances() (55f751f)
by phatina@fedoraproject.org
13 Mar '13
13 Mar '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 55f751f53bf22de4360af1084046694d19d033cc Author: Peter Hatina <phatina(a)redhat.com> Date: Tue Mar 12 12:30:22 2013 +0100 optimize instances filtering in LmiBaseClient::_get_instances() >--------------------------------------------------------------- cli-tools/lmi/lmi_client_base.py | 20 ++++++-------------- 1 files changed, 6 insertions(+), 14 deletions(-) diff --git a/cli-tools/lmi/lmi_client_base.py b/cli-tools/lmi/lmi_client_base.py index 267d55b..cf96987 100644 --- a/cli-tools/lmi/lmi_client_base.py +++ b/cli-tools/lmi/lmi_client_base.py @@ -142,21 +142,13 @@ class LmiBaseClient(object): if "Value" in kwargs: filter_value = kwargs["Value"] kwargs.pop("Value") - try: - inst_list_not_filtered = self._cliconn.EnumerateInstances(class_name, namespace, **kwargs) - except pywbem.cim_operations.CIMError, e: - raise_or_dump_exception(e) - return LmiReturnValue(rval = None, errorstr = e.args[1]) - except pywbem.cim_http.AuthError, e: - raise_or_dump_exception(e) - return LmiReturnValue(rval = None, errorstr = e.args[0]) - inst_list = [] - for inst in inst_list_not_filtered: - if not filter_value or filter_key in inst and inst[filter_key] == filter_value: - inst_list.append(inst) + query = "select * from %s" % class_name + if filter_value: + query += " where %s = \"%s\"" % (filter_key, filter_value) + (inst_list, _, errorstr) = self._exec_query("WQL", query, namespace) if not inst_list: - return LmiReturnValue(rval = None, errorstr = "Not found" if not "ErrorMsg" in kwargs else kwargs["ErrorMsg"]) - return LmiReturnValue(rval = inst_list, errorstr = "") + return LmiReturnValue(rval = None, errorstr = errorstr) + return LmiReturnValue(rval = inst_list) def _get_class_names(self, namespace = None, **kwargs): try:
1
0
0
0
[cura-tools] master: optimize _LmiClass::first_instance() (cc283f9)
by phatina@fedoraproject.org
13 Mar '13
13 Mar '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit cc283f9e1124d569988aef484e2ede8429c9583f Author: Peter Hatina <phatina(a)redhat.com> Date: Mon Mar 11 13:13:17 2013 +0100 optimize _LmiClass::first_instance() >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 7113c6e..18cb7d2 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -596,10 +596,12 @@ class _LmiClass(BaseObject): return map(lambda inst: _LmiInstance(self._client, self, inst), instance_list) def first_instance(self, **kwargs): - instance_list = self.instances(**kwargs) - if not instance_list: + inst_name = self.first_instance_name(**kwargs) + if not inst_name: + if LmiBaseClient._get_use_exceptions(): + raise return None - return instance_list[0] + return inst_name.to_instance() def properties(self): return self._cim_class.properties.keys()
1
0
0
0
← Newer
1
2
Older →
Jump to page:
1
2
Results per page:
10
25
50
100
200