| 61 | lock = None |
| 62 | |
| 63 | class CmdExecutor(threading.Thread): |
| 64 | def __init__(self, cmd, output): |
| 65 | threading.Thread.__init__(self) |
| 66 | self.cmd = cmd |
| 67 | self.child = None |
| 68 | |
| 69 | def run(self): |
| 70 | global executor, builder, lock |
| 71 | |
| 72 | if platform.system() == 'Windows': |
| 73 | try: |
| 74 | from win32spawn import Win32Spawn |
| 75 | subprocess = Win32Spawn(self.cmd) |
| 76 | subprocess.start_pipe() |
| 77 | |
| 78 | builder.progressbar.start() |
| 79 | while not subprocess.is_terminated or subprocess.qsize() > 0: |
| 80 | try: |
| 81 | line = subprocess.get(timeout=1) |
| 82 | line = line.replace('\r', '') |
| 83 | if line: |
| 84 | lock.acquire() |
| 85 | builder.output.see(END) |
| 86 | builder.output.insert(END, line) |
| 87 | lock.release() |
| 88 | except: |
| 89 | pass |
| 90 | |
| 91 | builder.progressbar.stop() |
| 92 | except: |
| 93 | pass |
| 94 | |
| 95 | executor = None |
| 96 | if builder.is_makeing_project: |
| 97 | builder.output.insert(END, 'Done') |
| 98 | builder.is_makeing_project = False |
| 99 | |
| 100 | def ExecCmd(cmd): |
| 101 | global executor |