using more stable way of handling unicode printing, cleaning unicode delete from output of execute

This commit is contained in:
Martin Diehl 2016-03-04 17:23:38 +01:00
parent 75480bc677
commit 9a405ef41b
1 changed files with 5 additions and 5 deletions

View File

@ -165,7 +165,7 @@ class backgroundMessage(threading.Thread):
def print_message(self): def print_message(self):
length = len(self.symbols[self.counter] + self.gap + self.message) length = len(self.symbols[self.counter] + self.gap + self.message)
sys.stderr.write(chr(8)*length + ' '*length + chr(8)*length + \ 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() sys.stderr.flush()
self.message = self.new_message self.message = self.new_message
@ -442,9 +442,9 @@ def execute(cmd,streamIn=None,wd='./'):
os.chdir(wd) os.chdir(wd)
process = subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE,stderr = subprocess.PIPE,stdin=subprocess.PIPE) process = subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE,stderr = subprocess.PIPE,stdin=subprocess.PIPE)
if streamIn is not None: if streamIn is not None:
out,error = process.communicate(streamIn.read()) out,error = [i.replace("\x08","") for i in process.communicate(streamIn.read())]
else: else:
out,error = process.communicate() out,error =[i.replace("\x08","") for i in process.communicate()]
os.chdir(initialPath) os.chdir(initialPath)
if process.returncode !=0: raise RuntimeError(cmd+' failed with returncode '+str(process.returncode)) if process.returncode !=0: raise RuntimeError(cmd+' failed with returncode '+str(process.returncode))
return out,error return out,error