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
April 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
5 discussions
Start a n
N
ew thread
[cura-tools] master: do not pack sample scripts (9a89e60)
by phatina@fedoraproject.org
30 Apr '13
30 Apr '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 9a89e60fc392b38d7465684449a15b1bc9a5ebb9 Author: Peter Hatina <phatina(a)redhat.com> Date: Mon Apr 29 14:56:01 2013 +0200 do not pack sample scripts >--------------------------------------------------------------- cli-tools/lmi/makefile.am | 7 ------- cli-tools/makefile.am | 7 +------ 2 files changed, 1 insertions(+), 13 deletions(-) diff --git a/cli-tools/lmi/makefile.am b/cli-tools/lmi/makefile.am index 9b92504..eb0d662 100644 --- a/cli-tools/lmi/makefile.am +++ b/cli-tools/lmi/makefile.am @@ -1,13 +1,6 @@ lmi_PYTHON = \ - lmi_address.py \ lmi_client_base.py \ - lmi_client_ip.py \ - lmi_client_power.py \ - lmi_client_service.py \ lmi_client_shell.py \ - lmi_client_user.py \ - lmi_listener.py \ - lmi_options.py \ __init__.py lmidir = $(pythondir)/lmi diff --git a/cli-tools/makefile.am b/cli-tools/makefile.am index 8f446c7..75241f9 100644 --- a/cli-tools/makefile.am +++ b/cli-tools/makefile.am @@ -1,11 +1,6 @@ SUBDIRS = lmi -bin_SCRIPTS = \ - lmiip \ - lmipower \ - lmiservice \ - lmishell \ - lmiuser +bin_SCRIPTS = lmishell EXTRA_DIST = $(bin_SCRIPTS)
1
0
0
0
[cura-tools] master: move indication routines to LmiConnection class (6d8f1fd)
by phatina@fedoraproject.org
30 Apr '13
30 Apr '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 6d8f1fd7f8a161cd457352f74d9dcf1a7be08e34 Author: Peter Hatina <phatina(a)redhat.com> Date: Wed Apr 3 16:02:48 2013 +0200 move indication routines to LmiConnection class >--------------------------------------------------------------- cli-tools/lmi/lmi_client_shell.py | 205 +++++++++++++++++++------------------ cli-tools/lmishell | 12 +- 2 files changed, 111 insertions(+), 106 deletions(-) diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 2f4b778..fe17097 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -74,42 +74,14 @@ def cast_lmi_to_cim(t, value): return tuple(map(cast_func, value)) return cast_func(value) -# Register _lmi_indications_cleanup at script exit, -# so we drop all the indication subscriptions for now -def _lmi_indications_cleanup(): - global _lmi_indications - for subscription in _lmi_indications.values(): - subscription.delete() - _lmi_indications = {} - def _lmi_indication_listeners_cleanup(): global _lmi_indication_listeners for listener in _lmi_indication_listeners.values(): listener.stop() _lmi_indication_listeners = {} -atexit.register(_lmi_indications_cleanup) atexit.register(_lmi_indication_listeners_cleanup) -def _lmi_delete_indication(indication_name): - if not indication_name in _lmi_indications: - errorstr = "No such indication subscribed" - if LmiBaseClient._get_use_exceptions(): - raise LmiIndicationError(errorstr) - return LmiReturnValue( - use_display_hook = True, - rval = False, - errorstr = errorstr) - indication = _lmi_indications[indication_name] - indication.delete() - _lmi_indications.pop(indication_name) - return LmiReturnValue( - hostname = indication._client.hostname, - use_display_hook = True, - rval = True, - rparams = {}, - errorstr = "") - def _lmi_start_indication_listener(hostname, port, handler, certfile = None, keyfile = None): global _lmi_indication_listeners listener = LmiIndicationListener( hostname, port, handler, certfile, keyfile) @@ -145,19 +117,10 @@ def _lmi_stop_indication_listener(hostname, port): use_display_hook = True, rval = True) -def _lmi_indications_list(): - global _lmi_indications - return _lmi_indications.keys() - def _lmi_indication_listeners_list(): global _lmi_indication_listeners return _lmi_indication_listeners.keys() -def _lmi_print_indications(): - global _lmi_indications - for i in _lmi_indications.keys(): - sys.stdout.write("%s\n" % i) - def _lmi_print_indication_listeners(): global _lmi_indication_listeners for i in _lmi_indication_listeners: @@ -380,8 +343,8 @@ class BaseObject(object): class _LmiSubscription(BaseObject): def __init__(self, client, cim_filter, cim_handler, cim_subscription): self._client = client - self._cim_filter = cim_filter - self._cim_handler = cim_handler + self._cim_filter_tpl = cim_filter + self._cim_handler_tpl = cim_handler self._cim_subscription = cim_subscription def __lt__(self, other): @@ -389,8 +352,10 @@ class _LmiSubscription(BaseObject): def delete(self): self._client._delete_instance(self._cim_subscription.path) - self._client._delete_instance(self._cim_filter.path) - self._client._delete_instance(self._cim_handler.path) + if self._cim_filter_tpl[1]: + self._client._delete_instance(self._cim_filter_tpl[0].path) + if self._cim_handler_tpl[1]: + self._client._delete_instance(self._cim_handler_tpl[0].path) class _LmiNamespace(BaseObject): def __init__(self, client, name): @@ -451,65 +416,6 @@ class _LmiNamespace(BaseObject): return [] return self.__transform_cim_to_lmi(inst_list) - def create_indication(self, **kwargs): - _return_value = lambda rval, errorstr = "": LmiReturnValue( - hostname = self._client.hostname, - use_display_hook = True, - rval = rval, - errorstr = errorstr) - try: - global _lmi_indications - system_name = self._client.hostname - filter_props = { - "CreationClassName" : kwargs["FilterCreationClassName"], - "SystemCreationClassName" : kwargs["FilterSystemCreationClassName"], - "SourceNamespace" : kwargs["FilterSourceNamespace"], - "SystemName" : system_name, - "Query" : kwargs["Query"], - "QueryLanguage" : kwargs["QueryLanguage"], - "Name" : kwargs["Name"] + "-filter" - } - handler_props = { - "CreationClassName" : kwargs["HandlerCreationClassName"], - "SystemCreationClassName" : kwargs["HandlerSystemCreationClassName"], - "SystemName" : system_name, - "Destination" : kwargs["Destination"], - "Name" : kwargs["Name"] + "-handler" - } - (cim_filter, _, errorstr) = self._client._create_instance( - "CIM_IndicationFilter", self._name, filter_props) - if not cim_filter: - if LmiBaseClient._get_use_exceptions(): - raise LmiIndicationError(errorstr) - return _return_value(False, errorstr) - (cim_handler, _, errorstr) = self._client._create_instance( - "CIM_IndicationHandlerCIMXML", self._name, handler_props) - if not cim_handler: - self._client._delete_instance(cim_filter.path) - if LmiBaseClient._get_use_exceptions(): - raise LmiIndicationError(errorstr) - return _return_value(False, errorstr) - subscription_props = { - "Filter" : cim_filter.path, - "Handler" : cim_handler.path - } - (cim_subscription, _, errorstr) = self._client._create_instance( - "CIM_IndicationSubscription", self._name, subscription_props) - if not cim_subscription: - self._client._delete_instance(cim_filter.path) - self._client._delete_instance(cim_handler.path) - if LmiBaseClient._get_use_exceptions(): - raise LmiIndicationError(errorstr) - return _return_value(False, errorstr) - _lmi_indications[kwargs["Name"]] = _LmiSubscription(self._client, - cim_filter, cim_handler, cim_subscription) - except KeyError, e: - errorstr = "Not all necessary parameters supported" - if LmiBaseClient._get_use_exceptions(): - raise LmiIndicationError(errorstr) - return _return_value(False, errorstr) - return _return_value(True, "") - @property def name(self): return self._name @@ -1042,6 +948,7 @@ class LmiConnection(object): def __init__(self, hostname, username = "", password = "", interactive = False, use_cache = True, \ conn_type = LmiBaseClient.CONN_TYPE_WBEM): self._client = _LmiShellClient(hostname, username, password, interactive, use_cache, conn_type) + self._indications = {} @property def hostname(self): @@ -1080,3 +987,101 @@ class LmiConnection(object): finally: LmiBaseClient._set_use_exceptions(use_exceptions) return True + + def subscribe_indication(self, **kwargs): + _return_value = lambda rval, errorstr = "": LmiReturnValue( + hostname = self._client.hostname, + use_display_hook = True, + rval = rval, + errorstr = errorstr) + try: + cim_filter_provided = "Filter" in kwargs + if cim_filter_provided: + cim_filter = kwargs["Filter"]._cim_instance + else: + cim_filter_props = { + "CreationClassName" : kwargs["FilterCreationClassName"], + "SystemCreationClassName" : kwargs["FilterSystemCreationClassName"], + "SourceNamespace" : kwargs["FilterSourceNamespace"], + "SystemName" : self._client.hostname, + "Query" : kwargs["Query"], + "QueryLanguage" : kwargs["QueryLanguage"], + "Name" : kwargs["Name"] + "-filter" + } + (cim_filter, _, errorstr) = self._client._create_instance( + kwargs["FilterCreationClassName"], kwargs["CreationNamespace"], + cim_filter_props) + if not cim_filter: + if LmiBaseClient._get_use_exceptions(): + raise LmiIndicationError(errorstr) + return _return_value(False, errorstr) + cim_handler_provided = "Handler" in kwargs + if cim_handler_provided: + cim_handler = kwargs["Handler"]._cim_instance + else: + cim_handler_props = { + "CreationClassName" : kwargs["HandlerCreationClassName"], + "SystemCreationClassName" : kwargs["HandlerSystemCreationClassName"], + "SystemName" : self._client.hostname, + "Destination" : kwargs["Destination"], + "Name" : kwargs["Name"] + "-handler" + } + (cim_handler, _, errorstr) = self._client._create_instance( + kwargs["HandlerCreationClassName"], kwargs["CreationNamespace"], + cim_handler_props) + if not cim_handler: + if not "Filter" in kwargs: + self._client._delete_instance(cim_filter.path) + if LmiBaseClient._get_use_exceptions(): + raise LmiIndicationError(errorstr) + return _return_value(False, errorstr) + cim_subscription_props = { + "Filter" : cim_filter.path, + "Handler" : cim_handler.path + } + (cim_subscription, _, errorstr) = self._client._create_instance( + kwargs["SubscriptionCreationClassName"], kwargs["CreationNamespace"], + cim_subscription_props) + if not cim_subscription: + if not "Filter" in kwargs: + self._client._delete_instance(cim_filter.path) + if not "Handler" in kwargs: + self._client._delete_instance(cim_handler.path) + if LmiBaseClient._get_use_exceptions(): + raise LmiIndicationError(errorstr) + return _return_value(False, errorstr) + self._indications[kwargs["Name"]] = _LmiSubscription( + self._client, + (cim_filter, not cim_filter_provided), + (cim_handler, not cim_handler_provided), + cim_subscription) + except KeyError, e: + errorstr = "Not all necessary parameters provided" + if LmiBaseClient._get_use_exceptions(): + raise LmiIndicationError(errorstr) + return _return_value(False, errorstr) + return _return_value(True) + + def unsubscribe_indication(self, name): + if not name in self._indications: + errorstr = "No such indication" + if LmiBaseClient._get_use_exceptions(): + raise LmiIndicationError(errorstr) + 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) + + def unsubscribe_all_indications(self): + for i in self._indications.values(): + i.delete() + self._indications = {} + + def print_subscribed_indications(self): + for i in self._indications.keys(): + sys.stdout.write("%s\n" % i) + + def subscribed_indications(self): + return self._indications.keys() diff --git a/cli-tools/lmishell b/cli-tools/lmishell index 89844d8..74f4728 100755 --- a/cli-tools/lmishell +++ b/cli-tools/lmishell @@ -31,12 +31,9 @@ from lmi.lmi_client_shell import _LmiNamespaceRoot from lmi.lmi_client_shell import _LmiClass from lmi.lmi_client_shell import _LmiInstance from lmi.lmi_client_shell import _LmiInstanceName -from lmi.lmi_client_shell import _lmi_delete_indication from lmi.lmi_client_shell import _lmi_start_indication_listener from lmi.lmi_client_shell import _lmi_stop_indication_listener -from lmi.lmi_client_shell import _lmi_print_indications from lmi.lmi_client_shell import _lmi_print_indication_listeners -from lmi.lmi_client_shell import _lmi_indications_list from lmi.lmi_client_shell import _lmi_indication_listeners_list def get_item_or_default(dic, item, default): @@ -219,12 +216,9 @@ class LmiInteractiveShell(code.InteractiveConsole): DEFAULT_LOCALS = { "LmiConnection" : LmiConnection, "use_exceptions" : LmiBaseClient._set_use_exceptions, - "delete_indication" : _lmi_delete_indication, "start_indication_listener" : _lmi_start_indication_listener, "stop_indication_listener" : _lmi_stop_indication_listener, - "print_indications" : _lmi_print_indications, "print_indication_listeners" : _lmi_print_indication_listeners, - "indications" : _lmi_indications_list, "indication_listeners" : _lmi_indication_listeners_list } @@ -284,6 +278,11 @@ class LmiInteractiveShell(code.InteractiveConsole): more = 0 self.save_history() + def cleanup(self): + for (k, v) in self.locals.iteritems(): + if isinstance(v, LmiConnection): + v.unsubscribe_all_indications() + def load_history(self): if self._history_length == 0 or not os.path.exists(self._history_file): return @@ -331,6 +330,7 @@ def __lmi_raw_input(prompt, use_echo = True): def _lmi_interact(locals = None): console = LmiInteractiveShell("> ", "... ", locals) console.interact() + console.cleanup() def _connect(hostname, username = "", password = "", interactive = False, use_cache = True): connection = None
1
0
0
0
[cura-tools] master: some code cleanup in LmiConnection (5781dc6)
by phatina@fedoraproject.org
30 Apr '13
30 Apr '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 5781dc63463ec56bd6f965efb6293ce52516fa0a Author: Peter Hatina <phatina(a)redhat.com> Date: Wed Apr 3 13:00:55 2013 +0200 some code cleanup in LmiConnection >--------------------------------------------------------------- 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 fb3a29e..2f4b778 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -1051,6 +1051,10 @@ class LmiConnection(object): def namespaces(self): return ["root"] + @property + def root(self): + return _LmiNamespaceRoot(self._client) + def print_namespaces(self): sys.stdout.write("root\n") @@ -1076,7 +1080,3 @@ class LmiConnection(object): finally: LmiBaseClient._set_use_exceptions(use_exceptions) return True - - @property - def root(self): - return _LmiNamespaceRoot(self._client)
1
0
0
0
[cura-tools] master: introduce UDS for root@localhost (8d58847)
by phatina@fedoraproject.org
03 Apr '13
03 Apr '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit 8d588474f80a7d13102b50ee3fbf00ae78804e4c Author: Peter Hatina <phatina(a)redhat.com> Date: Wed Apr 3 12:25:35 2013 +0200 introduce UDS for root@localhost no authentication needed when uid == 0 and managed machine is either localhost, 127.0.0.1 or ::1 >--------------------------------------------------------------- cli-tools/lmi/lmi_client_base.py | 11 ++++- cli-tools/lmi/lmi_client_shell.py | 27 +++++++++++-- cli-tools/lmishell | 80 +++++++++++++++++++----------------- 3 files changed, 73 insertions(+), 45 deletions(-) diff --git a/cli-tools/lmi/lmi_client_base.py b/cli-tools/lmi/lmi_client_base.py index 2b34823..a69cdfe 100644 --- a/cli-tools/lmi/lmi_client_base.py +++ b/cli-tools/lmi/lmi_client_base.py @@ -78,16 +78,21 @@ class LmiReturnValue(_RValue): class LmiBaseClient(object): QUERY_LANG_CQL = "CQL" QUERY_LANG_WQL = "WQL" + CONN_TYPE_WBEM, \ + CONN_TYPE_PEGASUS_UDS = range(2) use_exceptions_flag = False - def __init__(self, hostname, username = "", password = ""): + def __init__(self, hostname, username = "", password = "", conn_type = CONN_TYPE_WBEM): self._hostname = hostname self._username = username if not self._hostname.startswith("http://") and \ not self._hostname.startswith("https://"): self._hostname = "https://" + self._hostname - self._cliconn = pywbem.WBEMConnection(self._hostname, - (self._username, password)) + if conn_type == LmiBaseClient.CONN_TYPE_PEGASUS_UDS: + self._cliconn = pywbem.PegasusUDSConnection() + else: + self._cliconn = pywbem.WBEMConnection(self._hostname, + (self._username, password)) def _get_instance_names(self, class_name, namespace = None, **kwargs): filter_value = "" diff --git a/cli-tools/lmi/lmi_client_shell.py b/cli-tools/lmi/lmi_client_shell.py index 1aa593e..fb3a29e 100644 --- a/cli-tools/lmi/lmi_client_shell.py +++ b/cli-tools/lmi/lmi_client_shell.py @@ -1002,8 +1002,9 @@ class _LmiShellCache(object): self._active = val class _LmiShellClient(LmiBaseClient): - def __init__(self, hostname, username = "", password = "", interactive = False, use_cache = True): - super(self.__class__, self).__init__(hostname, username, password) + def __init__(self, hostname, username = "", password = "", interactive = False, use_cache = True, \ + conn_type = LmiBaseClient.CONN_TYPE_WBEM): + super(self.__class__, self).__init__(hostname, username, password, conn_type) self._interactive = interactive self._cache = _LmiShellCache(use_cache) @@ -1038,8 +1039,9 @@ class _LmiShellClient(LmiBaseClient): self._interactive = bool(i) class LmiConnection(object): - def __init__(self, hostname, username = "", password = "", interactive = False, use_cache = True): - self._client = _LmiShellClient(hostname, username, password, interactive, use_cache) + def __init__(self, hostname, username = "", password = "", interactive = False, use_cache = True, \ + conn_type = LmiBaseClient.CONN_TYPE_WBEM): + self._client = _LmiShellClient(hostname, username, password, interactive, use_cache, conn_type) @property def hostname(self): @@ -1058,6 +1060,23 @@ class LmiConnection(object): def use_cache(self, active = True): self._client._cache.active = active + def verify_credentials(self): + use_exceptions = LmiBaseClient._get_use_exceptions() + try: + LmiBaseClient._set_use_exceptions(True) + self._client._get_class("SomeNonExistingClass") + except pywbem.cim_operations.CIMError, e: + if e.args[0] == pywbem.cim_constants.CIM_ERR_NOT_FOUND: + return True + if use_exceptions: + raise + return False + except pywbem.cim_http.AuthError, e: + return False + finally: + LmiBaseClient._set_use_exceptions(use_exceptions) + return True + @property def root(self): return _LmiNamespaceRoot(self._client) diff --git a/cli-tools/lmishell b/cli-tools/lmishell index 882c30e..89844d8 100755 --- a/cli-tools/lmishell +++ b/cli-tools/lmishell @@ -20,6 +20,7 @@ import code import copy import pywbem import readline +import urlparse import rlcompleter import __builtin__ from lmi.lmi_client_base import LmiReturnValue @@ -305,53 +306,56 @@ class LmiInteractiveShell(code.InteractiveConsole): def clear_history(self): readline.clear_history() +def __lmi_raw_input(prompt, use_echo = True): + if not use_echo: + os.system("stty -echo") + try: + result = raw_input(prompt) + except EOFError, e: + if not use_echo: + os.system("stty echo") + sys.stdout.write("\n") + return None + except KeyboardInterrupt, e: + if not use_echo: + os.system("stty echo") + raise + if not use_echo: + os.system("stty echo") + sys.stdout.write("\n") + if result: + cur_hist_len = readline.get_current_history_length() + readline.remove_history_item(cur_hist_len - 1) + return result + def _lmi_interact(locals = None): console = LmiInteractiveShell("> ", "... ", locals) console.interact() def _connect(hostname, username = "", password = "", interactive = False, use_cache = True): - if not username: - while True: - try: - username = raw_input("username: ") - if username: - break - except EOFError, e: - sys.stdout.write("\n") - continue - except KeyboardInterrupt, e: - sys.stdout.write("\n") - return None - readline.remove_history_item(readline.get_current_history_length() - 1) - if not password: + connection = None + netloc = urlparse.urlparse(hostname).netloc + destination = netloc if netloc else hostname + if os.getuid() == 0 and destination in ("localhost", "127.0.0.1", "::1") and \ + os.path.exists("/var/run/tog-pegasus/cimxml.socket") and \ + not username and not password: + connection = LmiConnection(hostname, None, None, interactive, + use_cache, LmiBaseClient.CONN_TYPE_PEGASUS_UDS) + if not connection.verify_credentials(): + connection = None + if connection is None: try: - os.system("stty -echo") - password = raw_input("password: ") - os.system("stty echo") - except EOFError, e: - password = "" + if not username: + username = __lmi_raw_input("username: ", True) + if not password: + password = __lmi_raw_input("password: ", False) except KeyboardInterrupt, e: - os.system("stty echo") sys.stdout.write("\n") return None - 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, use_cache) - use_exceptions = LmiBaseClient._get_use_exceptions() - try: - LmiBaseClient._set_use_exceptions(True) - connection.root.cimv2.NonExistingClass - except pywbem.cim_operations.CIMError, e: - if e.args[0] == pywbem.cim_constants.CIM_ERR_NOT_FOUND: - return connection - if use_exceptions: - raise - return None - except pywbem.cim_http.AuthError, e: - return None - finally: - LmiBaseClient._set_use_exceptions(use_exceptions) + connection = LmiConnection(hostname, username, password, interactive, + use_cache, LmiBaseClient.CONN_TYPE_WBEM) + if not connection.verify_credentials(): + return None return connection def _use_display_sugar(use = True):
1
0
0
0
[cura-tools] master: fix handle IO exception when saving history (b9fc8e6)
by phatina@fedoraproject.org
03 Apr '13
03 Apr '13
Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master >--------------------------------------------------------------- commit b9fc8e6e959b5988b04f0efde8f6be6cf9b30fff Author: Peter Hatina <phatina(a)redhat.com> Date: Tue Apr 2 15:25:32 2013 +0200 fix handle IO exception when saving history >--------------------------------------------------------------- cli-tools/lmishell | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/cli-tools/lmishell b/cli-tools/lmishell index f50731b..882c30e 100755 --- a/cli-tools/lmishell +++ b/cli-tools/lmishell @@ -297,7 +297,10 @@ class LmiInteractiveShell(code.InteractiveConsole): return elif self._history_length > 0: readline.set_history_length(self._history_length) - readline.write_history_file(self._history_file) + try: + readline.write_history_file(self._history_file) + except IOError, e: + pass def clear_history(self): readline.clear_history()
1
0
0
0
Results per page:
10
25
50
100
200