Skip to content

Commit

Permalink
conda json decoding now logs failing json input
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkinsc committed Jan 14, 2016
1 parent d0cc49f commit fe9c024
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions tools/__init__.py
Expand Up @@ -264,33 +264,36 @@ def _attempt_install(self):
python_version = "python=" + python_version if python_version else ""
run_cmd.extend([python_version])

result = util.misc.run_and_print(run_cmd, silent=False)
try:
result = util.misc.run_and_print(run_cmd, silent=False)
data = json.loads(result.stdout.decode("UTF-8"))
#data = json.loads("!!\"")
except:
_log.warning("failed to decode JSON output from conda create")
_log.warning("failed to decode JSON output from conda create: %s", result.stdout.decode("UTF-8"))
self.installed = False
return

if "error" in data.keys() and "prefix already exists" in data["error"]:
# the environment already exists
# the package may not be installed...
_log.debug("Conda environment already exists...")
try:
result = util.misc.run_and_print(
[
"conda", "install", "--json", "-c", self.channel, "-y", "-q", "-p", self.env_path,
self._package_str
],
silent=True
)
data = json.loads(result.stdout.decode("UTF-8"))
except:
_log.warning("failed to decode JSON output from conda install")
self.installed = False
return

result = util.misc.run_and_print(
[
"conda", "install", "--json", "-c", self.channel, "-y", "-q", "-p", self.env_path,
self._package_str
],
silent=True
)

if result.returncode == 0:
try:
data = json.loads(result.stdout.decode("UTF-8"))
except:
_log.warning("failed to decode JSON output from conda install: %s", result.stdout.decode("UTF-8"))
self.installed = False
return

if data["success"] == True:
# set self.installed = True
self.verify_install()
Expand Down

0 comments on commit fe9c024

Please sign in to comment.