🐛 Fix unicode vs bytes issues in PipCaller
* environment for subprocess needs native str (at least under win)
* when reading a text file we should also be writing one inside the
test balloon
This commit is contained in:
1 parent
cc6f61c62e
commit
18b2ecd64c
2 files changed
+10
-6
No files matched your search
@@ -17,7 +17,7 @@ import os
|
||||
import pkg_resources
|
||||
|
||||
from .commandline import CommandlineCaller, clean_ansi
|
||||
from octoprint.util import to_unicode
|
||||
from octoprint.util import to_unicode, to_native_str
|
||||
|
||||
_cache = dict(version=dict(), setup=dict())
|
||||
_cache_mutex = threading.RLock()
|
||||
@@ -370,7 +370,7 @@ class PipCaller(CommandlineCaller):
|
||||
stdout=sarge.Capture(),
|
||||
stderr=sarge.Capture(),
|
||||
cwd=testballoon,
|
||||
env=dict(TESTBALLOON_OUTPUT=testballoon_output_file))
|
||||
env=dict(TESTBALLOON_OUTPUT=to_native_str(testballoon_output_file)))
|
||||
except Exception:
|
||||
self._logger.exception("Error while trying to install testballoon to figure out pip setup")
|
||||
return False, False, False, None
|
||||
|
||||
@@ -31,9 +31,13 @@ def produce_output(stream):
|
||||
virtual_env = hasattr(sys, "real_prefix")
|
||||
writable = os.access(install_dir, os.W_OK)
|
||||
|
||||
print("PIP_INSTALL_DIR={}".format(install_dir), file=stream)
|
||||
print("PIP_VIRTUAL_ENV={}".format(virtual_env), file=stream)
|
||||
print("PIP_WRITABLE={}".format(writable), file=stream)
|
||||
lines = ["PIP_INSTALL_DIR={}".format(install_dir),
|
||||
"PIP_VIRTUAL_ENV={}".format(virtual_env),
|
||||
"PIP_WRITABLE={}".format(writable)]
|
||||
|
||||
for line in lines:
|
||||
print(line, file=stream)
|
||||
|
||||
stream.flush()
|
||||
|
||||
|
||||
@@ -41,7 +45,7 @@ path = os.environ.get("TESTBALLOON_OUTPUT", None)
|
||||
if path is not None:
|
||||
# environment variable set, write to a log
|
||||
path = os.path.abspath(path)
|
||||
with io.open(path, 'wb+') as output:
|
||||
with io.open(path, 'wt+', encoding='utf-8') as output:
|
||||
produce_output(output)
|
||||
else:
|
||||
# write to stdout
|
||||
|
||||
Reference in new issue
Block a user