[openlmi-tools/f19] fix interactive connect when run with -i
Peter Hatina
phatina at fedoraproject.org
Tue Dec 3 10:58:13 UTC 2013
commit 70d13b9abba17ffdb22a7b4c164cb9ea9d4bbe3b
Author: Peter Hatina <phatina at redhat.com>
Date: Tue Dec 3 11:49:06 2013 +0100
fix interactive connect when run with -i
openlmi-tools-07-fix-interactive-connect.patch | 93 ++++++++++++++++++++++++
openlmi-tools.spec | 7 ++-
2 files changed, 99 insertions(+), 1 deletions(-)
---
diff --git a/openlmi-tools-07-fix-interactive-connect.patch b/openlmi-tools-07-fix-interactive-connect.patch
new file mode 100644
index 0000000..fd1c321
--- /dev/null
+++ b/openlmi-tools-07-fix-interactive-connect.patch
@@ -0,0 +1,93 @@
+diff --git a/cli/lmi/shell/LMIConsole.py b/cli/lmi/shell/LMIConsole.py
+index 21238e2..f1c9c4f 100644
+--- a/cli/lmi/shell/LMIConsole.py
++++ b/cli/lmi/shell/LMIConsole.py
+@@ -118,6 +118,7 @@ class LMIConsole(code.InteractiveConsole):
+ * **cert_file** (*string*) -- path to x509 cert file; default value is None
+ * **verify_server_cert** (*bool*) -- tells, if the server side certificate
+ needs to be verified, if SSL used; default value is True
++ * **prompt_prefix** (*string*) -- used for username/password prompt
+
+ :returns: connection object
+ :rtype: :py:class:`LMIConnection`
+@@ -125,12 +126,13 @@ class LMIConsole(code.InteractiveConsole):
+ key_file = kwargs.pop("key_file", None)
+ cert_file = kwargs.pop("cert_file", None)
+ verify_server_cert = kwargs.pop("verify_server_cert", self._verify_server_cert)
++ prompt_prefix = kwargs.pop("propmpt_prefix", "")
+ if kwargs:
+ raise TypeError("connect() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
+
+ return connect_internal(uri, username, password, interactive=True,
+ use_cache=self._use_cache, key_file=key_file, cert_file=cert_file,
+- verify_server_cert=verify_server_cert)
++ verify_server_cert=verify_server_cert, prompt_prefix=prompt_prefix)
+
+ # Initialize the interpreter
+ if locals is None:
+@@ -187,7 +189,7 @@ class LMIConsole(code.InteractiveConsole):
+ sys.ps2 = old_sys_ps2
+ self.save_history()
+
+- def interpret(self, script_name, script_argv, locals=None):
++ def interpret(self, script_name, script_argv, locals=None, interactive=False):
+ """
+ Interprets a specified script within additional provided locals.
+ There are :py:attr:`LMIConsole.DEFAULT_LOCALS` present.
+@@ -195,10 +197,12 @@ class LMIConsole(code.InteractiveConsole):
+ :param string script_name: script name
+ :param list script_argv: script CLI arguments
+ :param dictionary locals: dictionary with locals
++ :param bool interactive: tells LMIShell, if the script should be treated
++ as if it was run in interactive mode
+ :returns: exit code of the script
+ :rtype: int
+ """
+- # Helper function for non-interactive connect
++ # Helper function for LMIShell's scripts
+ def connect(uri, username="", password="", **kwargs):
+ """
+ Returns :py:class:`LMIConnection` object with provided URI and credentials.
+@@ -212,6 +216,7 @@ class LMIConsole(code.InteractiveConsole):
+ * **cert_file** (*string*) -- path to x509 cert file; default value is None
+ * **verify_server_cert** (*bool*) -- tells, if the server side certificate
+ needs to be verified, if SSL used; default value is True
++ * **prompt_prefix** (*string*) -- used for username/password prompt
+
+ :returns: connection object
+ :rtype: :py:class:`LMIConnection`
+@@ -220,12 +225,13 @@ class LMIConsole(code.InteractiveConsole):
+ key_file = kwargs.pop("key_file", None)
+ cert_file = kwargs.pop("cert_file", None)
+ verify_server_cert = kwargs.pop("verify_server_cert", self._verify_server_cert)
++ prompt_prefix = kwargs.pop("prompt_prefix", "")
+ if kwargs:
+ raise TypeError("connect() got an unexpected keyword arguments: %s" % ", ".join(kwargs.keys()))
+
+- return connect_internal(uri, username, password, interactive=False,
++ return connect_internal(uri, username, password, interactive=interactive,
+ use_cache=self._use_cache, key_file=key_file, cert_file=cert_file,
+- verify_server_cert=verify_server_cert)
++ verify_server_cert=verify_server_cert, prompt_prefix=prompt_prefix)
+ # Initialize locals
+ if locals is None:
+ locals = {}
+diff --git a/cli/lmishell b/cli/lmishell
+index aaa8f7b..433d413 100755
+--- a/cli/lmishell
++++ b/cli/lmishell
+@@ -47,8 +47,12 @@ if __name__ == "__main__":
+ else:
+ script_name = options.script_name
+ script_argv = options.script_argv
+- exit_code = console.interpret(script_name, script_argv)
+- if options.interact:
++ interactive = options.interact
++ exit_code = console.interpret(
++ script_name,
++ script_argv,
++ interactive=interactive)
++ if interactive:
+ console.interact(console.locals)
+ else:
+ sys.exit(exit_code)
diff --git a/openlmi-tools.spec b/openlmi-tools.spec
index a18d497..cf0064a 100644
--- a/openlmi-tools.spec
+++ b/openlmi-tools.spec
@@ -1,6 +1,6 @@
Name: openlmi-tools
Version: 0.9
-Release: 7%{?dist}
+Release: 8%{?dist}
Summary: Set of CLI tools for Openlmi providers
License: GPLv2+
@@ -12,6 +12,7 @@ Patch2: openlmi-tools-03-fix-instance-comparision.patch
Patch3: openlmi-tools-04-fix-passing-method-params.patch
Patch4: openlmi-tools-05-fix-log-messages-connect.patch
Patch5: openlmi-tools-06-fix-unify-lmishell-naming.patch
+Patch6: openlmi-tools-07-fix-interactive-connect.patch
BuildArch: noarch
BuildRequires: automake
@@ -37,6 +38,7 @@ Obsoletes: cura-tools < 0.1-4
%patch3 -p1
%patch4 -p1
%patch5 -p1
+%patch6 -p1
%build
pushd cli
@@ -80,6 +82,9 @@ install -m 644 cli/completion/_lmishell $zsh_comp_dir
%{python_sitelib}/openlmi_tools-*
%changelog
+* Tue Dec 3 2013 Peter Hatina <phatina at redhat.com> - 0.9-8
+- fix interactive connect when run with -i
+
* Tue Dec 3 2013 Peter Hatina <phatina at redhat.com> - 0.9-7
- unify LMIShell naming
More information about the scm-commits
mailing list