[cura-tools] 0.9-fixes: unify LMIShell naming (cfc07fb)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : 0.9-fixes
>---------------------------------------------------------------
commit cfc07fbb7a41017e5a04c496cf2ec618a4cd01bc
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Dec 2 15:28:46 2013 +0100
unify LMIShell naming
>---------------------------------------------------------------
cli/completion/README_zsh.md | 2 +-
cli/completion/_lmishell | 4 ++--
cli/lmi/shell/LMIShellOptions.py | 2 +-
doc/src/man_page.rst | 4 ++--
doc/src/structure.rst | 12 ++++++------
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/cli/completion/README_zsh.md b/cli/completion/README_zsh.md
index 3c66c06..6385ed0 100644
--- a/cli/completion/README_zsh.md
+++ b/cli/completion/README_zsh.md
@@ -1,4 +1,4 @@
-# OpenLMI Shell Completion for Zsh
+# LMIShell Completion for Zsh
Supplied completion function defined in `_lmishell` supports completion of all
command line arguments of `lmishell`. The completion also works for script
filename completion with `.lmi` or `.py` extension.
diff --git a/cli/completion/_lmishell b/cli/completion/_lmishell
index f6e7c33..d3843b3 100644
--- a/cli/completion/_lmishell
+++ b/cli/completion/_lmishell
@@ -18,7 +18,7 @@
#
# Authors: Peter Hatina <phatina(a)redhat.com>
#
-# Zsh completion for OpenLMI Shell
+# Zsh completion for LMIShell
_lmishell() {
local curcontext="$curcontext" state line
@@ -26,7 +26,7 @@ _lmishell() {
_arguments -C \
'(- 1 *)'{-h,--help}'[print help message and exit]' \
- '(- 1 *):OpenLMI Shell Script:_files -g \*.\(lmi\|py\)' \
+ '(- 1 *):LMIShell Script:_files -g \*.\(lmi\|py\)' \
'(-i --interact)'{-i,--interact}'[inspect interactively after running a script]' \
'(-v --verbose)'{-v,--verbose}'[print log messages to stderr]' \
'(-m --more-verbose)'{-m,--more-verbose}'[print all log messages to stderr]' \
diff --git a/cli/lmi/shell/LMIShellOptions.py b/cli/lmi/shell/LMIShellOptions.py
index acabf2c..8695fec 100644
--- a/cli/lmi/shell/LMIShellOptions.py
+++ b/cli/lmi/shell/LMIShellOptions.py
@@ -29,7 +29,7 @@ class LMIShellOptionsHelpWithVersionFormatter(argparse.HelpFormatter):
LMIShell version to the usage message.
"""
return argparse.HelpFormatter._format_usage(self, usage, actions, groups,
- "OpenLMI Shell v%s\n\n" % __version__)
+ "LMIShell v%s\n\n" % __version__)
class LMIShellOptionParser(argparse.ArgumentParser):
"""
diff --git a/doc/src/man_page.rst b/doc/src/man_page.rst
index bf1c63f..8e0ec60 100644
--- a/doc/src/man_page.rst
+++ b/doc/src/man_page.rst
@@ -7,8 +7,8 @@ Description
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
-is possible to do in pure python, it is possible in LMIShell. There are classes
+LMIShell is based on a python interpreter and added logic, therefore what 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.
diff --git a/doc/src/structure.rst b/doc/src/structure.rst
index 07ce4ca..cacd234 100644
--- a/doc/src/structure.rst
+++ b/doc/src/structure.rst
@@ -1,10 +1,10 @@
Structure
=========
-OpenLMI Shell is based on a python interpreter and added logic, therefore what
-you can do in pure python, it is possible in OpenLMI Shell. 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.
+LMIShell 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 LMIShell.
.. image:: _static/lmi-scheme.png
10 years, 5 months
[cura-tools] master: unify LMIShell naming (d46ca13)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit d46ca13a6f50a446f46047bde775f93e0cc43717
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Dec 2 15:28:46 2013 +0100
unify LMIShell naming
>---------------------------------------------------------------
cli/completion/README_zsh.md | 2 +-
cli/completion/_lmishell | 4 ++--
cli/lmi/shell/LMIShellOptions.py | 2 +-
doc/src/man_page.rst | 4 ++--
doc/src/structure.rst | 12 ++++++------
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/cli/completion/README_zsh.md b/cli/completion/README_zsh.md
index 3c66c06..6385ed0 100644
--- a/cli/completion/README_zsh.md
+++ b/cli/completion/README_zsh.md
@@ -1,4 +1,4 @@
-# OpenLMI Shell Completion for Zsh
+# LMIShell Completion for Zsh
Supplied completion function defined in `_lmishell` supports completion of all
command line arguments of `lmishell`. The completion also works for script
filename completion with `.lmi` or `.py` extension.
diff --git a/cli/completion/_lmishell b/cli/completion/_lmishell
index f6e7c33..d3843b3 100644
--- a/cli/completion/_lmishell
+++ b/cli/completion/_lmishell
@@ -18,7 +18,7 @@
#
# Authors: Peter Hatina <phatina(a)redhat.com>
#
-# Zsh completion for OpenLMI Shell
+# Zsh completion for LMIShell
_lmishell() {
local curcontext="$curcontext" state line
@@ -26,7 +26,7 @@ _lmishell() {
_arguments -C \
'(- 1 *)'{-h,--help}'[print help message and exit]' \
- '(- 1 *):OpenLMI Shell Script:_files -g \*.\(lmi\|py\)' \
+ '(- 1 *):LMIShell Script:_files -g \*.\(lmi\|py\)' \
'(-i --interact)'{-i,--interact}'[inspect interactively after running a script]' \
'(-v --verbose)'{-v,--verbose}'[print log messages to stderr]' \
'(-m --more-verbose)'{-m,--more-verbose}'[print all log messages to stderr]' \
diff --git a/cli/lmi/shell/LMIShellOptions.py b/cli/lmi/shell/LMIShellOptions.py
index acabf2c..8695fec 100644
--- a/cli/lmi/shell/LMIShellOptions.py
+++ b/cli/lmi/shell/LMIShellOptions.py
@@ -29,7 +29,7 @@ class LMIShellOptionsHelpWithVersionFormatter(argparse.HelpFormatter):
LMIShell version to the usage message.
"""
return argparse.HelpFormatter._format_usage(self, usage, actions, groups,
- "OpenLMI Shell v%s\n\n" % __version__)
+ "LMIShell v%s\n\n" % __version__)
class LMIShellOptionParser(argparse.ArgumentParser):
"""
diff --git a/doc/src/man_page.rst b/doc/src/man_page.rst
index bf1c63f..8e0ec60 100644
--- a/doc/src/man_page.rst
+++ b/doc/src/man_page.rst
@@ -7,8 +7,8 @@ Description
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
-is possible to do in pure python, it is possible in LMIShell. There are classes
+LMIShell is based on a python interpreter and added logic, therefore what 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.
diff --git a/doc/src/structure.rst b/doc/src/structure.rst
index 07ce4ca..cacd234 100644
--- a/doc/src/structure.rst
+++ b/doc/src/structure.rst
@@ -1,10 +1,10 @@
Structure
=========
-OpenLMI Shell is based on a python interpreter and added logic, therefore what
-you can do in pure python, it is possible in OpenLMI Shell. 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.
+LMIShell 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 LMIShell.
.. image:: _static/lmi-scheme.png
10 years, 5 months
[cura-tools] 0.9-fixes: fix detached streams log message (92cef8d)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : 0.9-fixes
>---------------------------------------------------------------
commit 92cef8dfe0ec90b7794c5fa0b06111249818f55e
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Dec 2 13:28:21 2013 +0100
fix detached streams log message
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 6d228bf..7c693c7 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -58,8 +58,8 @@ def __lmi_raw_input(prompt, use_echo=True):
get_input = raw_input
stream = sys.stdout
if not sys.stderr.isatty() and not sys.stdout.isatty():
- LOG.warn('both stdout and stderr are detached from terminal,'
- ' using stdout for prompt')
+ logging.getLogger("").warn(
+ 'Both stdout and stderr are detached from terminal, using stdout for prompt')
if not use_echo:
os.system("stty -echo")
try:
10 years, 5 months
[cura-tools] master: fix detached streams log message (b521c29)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit b521c2999c0080985fff2e6724012effffce5194
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Dec 2 13:28:21 2013 +0100
fix detached streams log message
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 96d3354..af9379b 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -58,8 +58,8 @@ def __lmi_raw_input(prompt, use_echo=True):
get_input = raw_input
stream = sys.stdout
if not sys.stderr.isatty() and not sys.stdout.isatty():
- LOG.warn('both stdout and stderr are detached from terminal,'
- ' using stdout for prompt')
+ logging.getLogger("").warn(
+ 'Both stdout and stderr are detached from terminal, using stdout for prompt')
if not use_echo:
os.system("stty -echo")
try:
10 years, 5 months
[cura-tools] 0.9-fixes: extend connect() error messages (c8bf5b7)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : 0.9-fixes
>---------------------------------------------------------------
commit c8bf5b777fd7fef21c00ed48a5bbb68fa3b29bad
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Dec 2 10:40:58 2013 +0100
extend connect() error messages
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index da7cef9..6d228bf 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -137,7 +137,8 @@ def connect(uri, username="", password="", **kwargs):
connection = LMIConnection(uri, None, None, interactive=interactive,
use_cache=use_cache, conn_type=LMIBaseClient.CONN_TYPE_PEGASUS_UDS,
verify_server_cert=verify_server_cert)
- if not connection.verify_credentials():
+ (rval, _, errorstr) = connection.verify_credentials()
+ if not rval:
connection = None
else:
logger.info("Connected via Unix-socket")
@@ -154,8 +155,9 @@ def connect(uri, username="", password="", **kwargs):
connection = LMIConnection(uri, username, password, interactive=interactive,
use_cache=use_cache, conn_type=LMIBaseClient.CONN_TYPE_WBEM,
key_file=key_file, cert_file=cert_file, verify_server_cert=verify_server_cert)
- if not connection.verify_credentials():
- logger.error("Not connected to %s, wrong username/password or certificate", uri)
+ (rval, _, errorstr) = connection.verify_credentials()
+ if not rval:
+ logger.error("Error connecting to %s, %s", uri, errorstr)
return None
else:
logger.info("Connected to %s", uri)
@@ -289,8 +291,13 @@ class LMIConnection(object):
``CIM_ERR_NOT_FOUND`` set. Otherwise, the should receive
:py:exc:`pywbem.AuthError`.
- :returns: True if provided credentials are OK; False otherwise
+ :returns: :py:class:`LMIReturnValue` object with rval set to True, if
+ the user was properly authenticated; False otherwise. In case of any
+ error, rval is set to False and errorstr contains appropriate error
+ string.
+ :rtype: :py:class:`LMIReturnValue`
"""
+ errorstr = ""
try:
use_exceptions = lmi_get_use_exceptions()
lmi_set_use_exceptions(True)
@@ -302,13 +309,16 @@ class LMIConnection(object):
lmi_set_use_exceptions(use_exceptions)
except pywbem.cim_operations.CIMError, e:
if e.args[0] == pywbem.cim_constants.CIM_ERR_NOT_FOUND:
- return True
+ return LMIReturnValue(rval=True)
lmi_raise_or_dump_exception(e)
+ errorstr = e.args[1]
except pywbem.cim_http.AuthError, e:
lmi_raise_or_dump_exception(e)
+ errorstr = e.args[0]
except OpenSSL.SSL.Error, e:
lmi_raise_or_dump_exception(e)
- return False
+ errorstr = e.args[0][0][2]
+ return LMIReturnValue(rval=False, errorstr=errorstr)
def subscribe_indication(self, **kwargs):
"""
10 years, 5 months
[cura-tools] master: extend connect() error messages (23c9ecb)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 23c9ecbb2c43d86e31467cf8abd3952fcf112ac6
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Dec 2 10:40:58 2013 +0100
extend connect() error messages
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 5d19dda..96d3354 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -137,7 +137,8 @@ def connect(uri, username="", password="", **kwargs):
connection = LMIConnection(uri, None, None, interactive=interactive,
use_cache=use_cache, conn_type=LMIBaseClient.CONN_TYPE_PEGASUS_UDS,
verify_server_cert=verify_server_cert)
- if not connection.verify_credentials():
+ (rval, _, errorstr) = connection.verify_credentials()
+ if not rval:
connection = None
else:
logger.info("Connected via Unix-socket")
@@ -154,8 +155,9 @@ def connect(uri, username="", password="", **kwargs):
connection = LMIConnection(uri, username, password, interactive=interactive,
use_cache=use_cache, conn_type=LMIBaseClient.CONN_TYPE_WBEM,
key_file=key_file, cert_file=cert_file, verify_server_cert=verify_server_cert)
- if not connection.verify_credentials():
- logger.error("Not connected to %s, wrong username/password or certificate", uri)
+ (rval, _, errorstr) = connection.verify_credentials()
+ if not rval:
+ logger.error("Error connecting to %s, %s", uri, errorstr)
return None
else:
logger.info("Connected to %s", uri)
@@ -289,8 +291,13 @@ class LMIConnection(object):
``CIM_ERR_NOT_FOUND`` set. Otherwise, the should receive
:py:exc:`pywbem.AuthError`.
- :returns: True if provided credentials are OK; False otherwise
+ :returns: :py:class:`LMIReturnValue` object with rval set to True, if
+ the user was properly authenticated; False otherwise. In case of any
+ error, rval is set to False and errorstr contains appropriate error
+ string.
+ :rtype: :py:class:`LMIReturnValue`
"""
+ errorstr = ""
try:
use_exceptions = lmi_get_use_exceptions()
lmi_set_use_exceptions(True)
@@ -302,13 +309,16 @@ class LMIConnection(object):
lmi_set_use_exceptions(use_exceptions)
except pywbem.cim_operations.CIMError, e:
if e.args[0] == pywbem.cim_constants.CIM_ERR_NOT_FOUND:
- return True
+ return LMIReturnValue(rval=True)
lmi_raise_or_dump_exception(e)
+ errorstr = e.args[1]
except pywbem.cim_http.AuthError, e:
lmi_raise_or_dump_exception(e)
+ errorstr = e.args[0]
except OpenSSL.SSL.Error, e:
lmi_raise_or_dump_exception(e)
- return False
+ errorstr = e.args[0][0][2]
+ return LMIReturnValue(rval=False, errorstr=errorstr)
def subscribe_indication(self, **kwargs):
"""
10 years, 5 months
[cura-tools] master: add missing log messages in connect() (97d1023)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
>---------------------------------------------------------------
commit 97d10239a931fb71a73a4709d45232a0c6c877f0
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Dec 2 10:14:23 2013 +0100
add missing log messages in connect()
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 7 +++++++
cli/lmishell | 13 ++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 52c9922..5d19dda 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -17,6 +17,7 @@ import os
import sys
import atexit
import pywbem
+import logging
import readline
import urlparse
@@ -126,6 +127,7 @@ def connect(uri, username="", password="", **kwargs):
if kwargs:
raise TypeError("connect() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
+ logger = logging.getLogger("")
connection = None
netloc = urlparse.urlparse(uri).netloc
destination = netloc if netloc else uri
@@ -137,6 +139,8 @@ def connect(uri, username="", password="", **kwargs):
verify_server_cert=verify_server_cert)
if not connection.verify_credentials():
connection = None
+ else:
+ logger.info("Connected via Unix-socket")
if connection is None:
if interactive and not key_file and not cert_file:
try:
@@ -151,7 +155,10 @@ def connect(uri, username="", password="", **kwargs):
use_cache=use_cache, conn_type=LMIBaseClient.CONN_TYPE_WBEM,
key_file=key_file, cert_file=cert_file, verify_server_cert=verify_server_cert)
if not connection.verify_credentials():
+ logger.error("Not connected to %s, wrong username/password or certificate", uri)
return None
+ else:
+ logger.info("Connected to %s", uri)
return connection
class LMIConnection(object):
diff --git a/cli/lmishell b/cli/lmishell
index e493af5..aaa8f7b 100755
--- a/cli/lmishell
+++ b/cli/lmishell
@@ -22,24 +22,23 @@ from lmi.shell import LMIShellOptions
if __name__ == "__main__":
options = LMIShellOptions(sys.argv)
+ logging.basicConfig(format='%(levelname)s: %(message)s')
+ logger = logging.getLogger("")
if options.log == LMIShellOptions._LOG_MORE_VERBOSE:
# Print out all the log messages to stderr stream
- logger = logging.getLogger("")
logger.setLevel(logging.DEBUG)
- logger.addHandler(logging.StreamHandler(sys.stderr))
elif options.log == LMIShellOptions._LOG_VERBOSE:
# Print out only a set of log messages to stderr stream
- logger = logging.getLogger("")
logger.setLevel(logging.INFO)
- logger.addHandler(logging.StreamHandler(sys.stderr))
elif options.log == LMIShellOptions._LOG_QUIET:
# Quiet flag seen, drop all the log messages
- logging.getLogger("").addHandler(logging.NullHandler())
+ handlers = logger.handlers
+ for handler in handlers:
+ logger.removeHandler(handler)
+ logger.addHandler(logging.NullHandler())
else:
# By default, print error messages to stderr stream
- logger = logging.getLogger("")
logger.setLevel(logging.ERROR)
- logger.addHandler(logging.StreamHandler(sys.stderr))
console = LMIConsole()
console.set_verify_server_certificate(options.verify_server_cert)
10 years, 5 months
[cura-tools] 0.9-fixes: add missing log messages in connect() (1b8df51)
by phatina@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/cura-tools.git
On branch : 0.9-fixes
>---------------------------------------------------------------
commit 1b8df51c80e5455c9ca30a6ecf5956074de21e51
Author: Peter Hatina <phatina(a)redhat.com>
Date: Mon Dec 2 10:14:23 2013 +0100
add missing log messages in connect()
>---------------------------------------------------------------
cli/lmi/shell/LMIConnection.py | 7 +++++++
cli/lmishell | 13 ++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/cli/lmi/shell/LMIConnection.py b/cli/lmi/shell/LMIConnection.py
index 301fa52..da7cef9 100644
--- a/cli/lmi/shell/LMIConnection.py
+++ b/cli/lmi/shell/LMIConnection.py
@@ -17,6 +17,7 @@ import os
import sys
import atexit
import pywbem
+import logging
import readline
import urlparse
@@ -126,6 +127,7 @@ def connect(uri, username="", password="", **kwargs):
if kwargs:
raise TypeError("connect() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
+ logger = logging.getLogger("")
connection = None
netloc = urlparse.urlparse(uri).netloc
destination = netloc if netloc else uri
@@ -137,6 +139,8 @@ def connect(uri, username="", password="", **kwargs):
verify_server_cert=verify_server_cert)
if not connection.verify_credentials():
connection = None
+ else:
+ logger.info("Connected via Unix-socket")
if connection is None:
if interactive and not key_file and not cert_file:
try:
@@ -151,7 +155,10 @@ def connect(uri, username="", password="", **kwargs):
use_cache=use_cache, conn_type=LMIBaseClient.CONN_TYPE_WBEM,
key_file=key_file, cert_file=cert_file, verify_server_cert=verify_server_cert)
if not connection.verify_credentials():
+ logger.error("Not connected to %s, wrong username/password or certificate", uri)
return None
+ else:
+ logger.info("Connected to %s", uri)
return connection
class LMIConnection(object):
diff --git a/cli/lmishell b/cli/lmishell
index e493af5..aaa8f7b 100755
--- a/cli/lmishell
+++ b/cli/lmishell
@@ -22,24 +22,23 @@ from lmi.shell import LMIShellOptions
if __name__ == "__main__":
options = LMIShellOptions(sys.argv)
+ logging.basicConfig(format='%(levelname)s: %(message)s')
+ logger = logging.getLogger("")
if options.log == LMIShellOptions._LOG_MORE_VERBOSE:
# Print out all the log messages to stderr stream
- logger = logging.getLogger("")
logger.setLevel(logging.DEBUG)
- logger.addHandler(logging.StreamHandler(sys.stderr))
elif options.log == LMIShellOptions._LOG_VERBOSE:
# Print out only a set of log messages to stderr stream
- logger = logging.getLogger("")
logger.setLevel(logging.INFO)
- logger.addHandler(logging.StreamHandler(sys.stderr))
elif options.log == LMIShellOptions._LOG_QUIET:
# Quiet flag seen, drop all the log messages
- logging.getLogger("").addHandler(logging.NullHandler())
+ handlers = logger.handlers
+ for handler in handlers:
+ logger.removeHandler(handler)
+ logger.addHandler(logging.NullHandler())
else:
# By default, print error messages to stderr stream
- logger = logging.getLogger("")
logger.setLevel(logging.ERROR)
- logger.addHandler(logging.StreamHandler(sys.stderr))
console = LMIConsole()
console.set_verify_server_certificate(options.verify_server_cert)
10 years, 5 months