From 9a405ef41b9a220fe08f0e3ce83c96e01f33e7a8 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 4 Mar 2016 17:23:38 +0100 Subject: [PATCH] using more stable way of handling unicode printing, cleaning unicode delete from output of execute --- lib/damask/util.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/damask/util.py b/lib/damask/util.py index 1b239b7b0..77bc30403 100644 --- a/lib/damask/util.py +++ b/lib/damask/util.py @@ -147,10 +147,10 @@ class backgroundMessage(threading.Thread): sys.stderr.flush() def stop(self): - self._stop.set() + self._stop.set() def stopped(self): - return self._stop.is_set() + return self._stop.is_set() def run(self): while not threading.enumerate()[0]._Thread__stopped: @@ -165,7 +165,7 @@ class backgroundMessage(threading.Thread): def print_message(self): length = len(self.symbols[self.counter] + self.gap + self.message) sys.stderr.write(chr(8)*length + ' '*length + chr(8)*length + \ - self.symbols[self.counter] + self.gap + self.new_message) # delete former and print new message + self.symbols[self.counter].encode('utf-8') + self.gap + self.new_message) # delete former and print new message sys.stderr.flush() self.message = self.new_message @@ -442,9 +442,9 @@ def execute(cmd,streamIn=None,wd='./'): os.chdir(wd) process = subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE,stderr = subprocess.PIPE,stdin=subprocess.PIPE) if streamIn is not None: - out,error = process.communicate(streamIn.read()) + out,error = [i.replace("\x08","") for i in process.communicate(streamIn.read())] else: - out,error = process.communicate() + out,error =[i.replace("\x08","") for i in process.communicate()] os.chdir(initialPath) if process.returncode !=0: raise RuntimeError(cmd+' failed with returncode '+str(process.returncode)) return out,error