Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
update for travis
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Sep 8, 2016
1 parent fc050f3 commit 0b3f2e8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
6 changes: 0 additions & 6 deletions _unittests/ut_cli/test_pymy_install_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ def test_install_set_schedule(self):
self._testMethodName,
OutputPrint=__name__ == "__main__")

if is_travis_or_appveyor() == "travis":
warnings.warn("cli not tested on travis")
return
this = os.path.abspath(os.path.dirname(__file__))
script = os.path.normpath(os.path.join(
this, "..", "..", "src", "pymyinstall", "cli", "pymy_install.py"))
Expand All @@ -78,9 +75,6 @@ def test_install_download(self):
self._testMethodName,
OutputPrint=__name__ == "__main__")

if is_travis_or_appveyor() == "travis":
warnings.warn("cli not tested on travis")
return
temp = get_temp_folder(__file__, "temp_install_download")
this = os.path.abspath(os.path.dirname(__file__))
script = os.path.normpath(os.path.join(
Expand Down
4 changes: 2 additions & 2 deletions src/pymyinstall/installhelper/install_cmd_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def run_cmd(cmd, sin="", shell=True, wait=False, log_error=True,
stop_running_if=None, encerror="ignore",
encoding="utf8", change_path=None, communicate=True,
preprocess=True, timeout=None, catch_exit=False, fLOG=None,
tell_if_no_output=None):
tell_if_no_output=None, old_behavior=True):
"""
run a command line and wait for the result,
@see fn run_cmd_private
Expand Down Expand Up @@ -453,4 +453,4 @@ def run_cmd(cmd, sin="", shell=True, wait=False, log_error=True,
stop_running_if=stop_running_if, encerror=encerror,
encoding=encoding, change_path=change_path, communicate=communicate,
preprocess=preprocess, timeout=timeout, catch_exit=catch_exit, fLOG=fLOG,
tell_if_no_output=tell_if_no_output)
tell_if_no_output=tell_if_no_output, old_behavior=old_behavior)
40 changes: 38 additions & 2 deletions src/pymyinstall/installhelper/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def skip_run_cmd(cmd, sin="", shell=True, wait=False, log_error=True,
def run_cmd_private(cmd, sin="", shell=True, wait=False, log_error=True,
stop_running_if=None, encerror="ignore", encoding="utf8",
change_path=None, communicate=True, preprocess=True, timeout=None,
catch_exit=False, fLOG=None, tell_if_no_output=None):
catch_exit=False, fLOG=None, tell_if_no_output=None, old_behavior=True):
"""
run a command line and wait for the result
@param cmd command line
Expand All @@ -140,6 +140,7 @@ def run_cmd_private(cmd, sin="", shell=True, wait=False, log_error=True,
@param catch_exit catch *SystemExit* exception
@param fLOG logging function (if not None, bypass others parameters)
@param tell_if_no_output tells if there is no output every *tell_if_no_output* seconds
@param old_behavior keep the previous behavior before the change
@return content of stdout, stdres (only if wait is True)
.. exref::
Expand Down Expand Up @@ -211,7 +212,42 @@ def run_cmd_private(cmd, sin="", shell=True, wait=False, log_error=True,
err_read = False
skip_waiting = False

if communicate:
if old_behavior:
for line in pproc.stdout:
if fLOG is not None:
fLOG(line.decode(encoding, errors=encerror).strip("\n"))
try:
out.append(
line.decode(
encoding,
errors=encerror).strip("\n"))
except UnicodeDecodeError as exu:
raise RunCmdException(
"issue with cmd:" +
str(cmd) +
"\n" +
str(exu))
if pproc.stdout.closed:
break
if stop_running_if is not None and stop_running_if(
line.decode("utf8", errors=encerror)):
skip_waiting = True
break

if not skip_waiting:
pproc.wait()

out = "\n".join(out)
err = pproc.stderr.read().decode(encoding, errors=encerror)
if fLOG is not None:
fLOG("end of execution ", cmd)
if len(err) > 0 and log_error and fLOG is not None:
fLOG("error (log)\n%s" % err)
pproc.stdout.close()
pproc.stderr.close()
return out, err

elif communicate:
# communicate is True
if tell_if_no_output is not None:
raise NotImplementedError(
Expand Down

0 comments on commit 0b3f2e8

Please sign in to comment.