From 4ec145f9b83574a1cf23c43fd4ebf3aa805e7041 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Tue, 26 Jun 2018 18:36:20 -0700 Subject: [PATCH] Strip out random null bytes better in output fron conda WAT --- tljh/conda.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tljh/conda.py b/tljh/conda.py index 5b96249..dec553b 100644 --- a/tljh/conda.py +++ b/tljh/conda.py @@ -45,10 +45,11 @@ def ensure_conda_packages(prefix, packages): # parse this outside of this kludge. filtered_output = '\n'.join([ l for l in raw_output.split('\n') - # Sometimes the JSON messages start with a \00. The lstrip removes these. - if not l.lstrip().startswith('{"fetch"') + # Sometimes the JSON messages start with a \x00. The lstrip removes these. + # conda messages seem to randomly throw \x00 in places for no reason + if not l.lstrip('\x00').startswith('{"fetch"') ]) - output = json.loads(filtered_output) + output = json.loads(filtered_output.lstrip('\x00')) if 'success' in output and output['success'] == True: return