def runCommand(cmd, start_directory, prefix, *args): """ Run command cmd and asynchronize put it to LogWindow Each string logged with prefix """ import subprocess import os try: pipe = subprocess.Popen(cmd, bufsize = 0, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) while True: text = pipe.stdout.readline().decode() if not text: break sgPyQt.message( prefix + text, False ) except OSError as e: sgPyQt.message( prefix + "Exception had occured during script execution " + e.__str__(), True )
def runCommand(cmd, start_directory, prefix, *args): """ Run command cmd and asynchronize put it to LogWindow Each string logged with prefix """ import subprocess import os if start_directory != None and start_directory != "": os.chdir(start_directory) try: pipe = subprocess.Popen(cmd, bufsize = 0, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) while True: text = pipe.stdout.readline() if not text: break sgPyQt.message( prefix + text, False ) except OSError, e: sgPyQt.message( prefix + "Exception had occured during script execution " + e.__str__(), True )