Michael Pasternak has uploaded a new change for review. Change subject: cli: do not write to file i/o during script execution ......................................................................
cli: do not write to file i/o during script execution Change-Id: I0b3e4fecfeef96430016f82d4396cab5f37c339b Signed-off-by: Michael Pasternak <[email protected]> --- M src/cli/context.py A src/cli/executionmode.py M src/ovirtcli/shell/filecmdshell.py 3 files changed, 40 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/00/7400/1 diff --git a/src/cli/context.py b/src/cli/context.py index bc3f10a..93d9d6b 100644 --- a/src/cli/context.py +++ b/src/cli/context.py @@ -31,6 +31,7 @@ import codecs import cStringIO from kitchen.text.converters import getwriter +from cli.executionmode import ExecutionMode class ExecutionContext(object): @@ -65,6 +66,7 @@ self._setup_logging() self._load_settings() self.setup_commands() + self.mode = ExecutionMode.SHELL def _setup_logging(self): """Configure logging.""" @@ -245,7 +247,7 @@ def _setup_pipeline(self, pipeline): """INTERNAL: set up the pipeline, if any.""" - if not pipeline: + if not pipeline or self.mode == ExecutionMode.SCRIPT:# or pipeline == 'less -FSRX': self._pipeline = None return self._pipeline = Popen(pipeline, stdin=PIPE, stderr=PIPE, shell=True) diff --git a/src/cli/executionmode.py b/src/cli/executionmode.py new file mode 100644 index 0000000..0ac576b --- /dev/null +++ b/src/cli/executionmode.py @@ -0,0 +1,33 @@ +# +# Copyright (c) 2010 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +class ExecutionMode(): + SHELL, SCRIPT, DEFAULT = range(3) + + def __init__(self, Type): + self.value = Type + + def __str__(self): + if self.value == ExecutionMode.SHELL: + return 'SHELL' + if self.value == ExecutionMode.SCRIPT: + return 'SCRIPT' + if self.value == ExecutionMode.DEFAULT: + return 'DEFAULT' + + def __eq__(self, y): + return self.value == y.value diff --git a/src/ovirtcli/shell/filecmdshell.py b/src/ovirtcli/shell/filecmdshell.py index 5df629a..89dc4df 100644 --- a/src/ovirtcli/shell/filecmdshell.py +++ b/src/ovirtcli/shell/filecmdshell.py @@ -14,8 +14,8 @@ # limitations under the License. # - from ovirtcli.shell.cmdshell import CmdShell +from cli.executionmode import ExecutionMode class FileCmdShell(CmdShell): @@ -40,6 +40,7 @@ """ try: + self.context.mode = ExecutionMode.SCRIPT with open(arg) as script: for line in script: line = self.owner.precmd(line) @@ -47,3 +48,5 @@ self.owner.onecmd(line) except Exception, e: self._error(str(e)) + finally: + self.context.mode = ExecutionMode.SHELL -- To view, visit http://gerrit.ovirt.org/7400 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0b3e4fecfeef96430016f82d4396cab5f37c339b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine-cli Gerrit-Branch: master Gerrit-Owner: Michael Pasternak <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
