Skip to content

Commit

Permalink
Revert "失败的尝试,要么读不全,要么读重复"
Browse files Browse the repository at this point in the history
This reverts commit c4e542d.
  • Loading branch information
LiuJiewenTT committed Jan 31, 2024
1 parent c4e542d commit 8c19ce7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 16 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
venv
keep_local
.idea
__pycache__
Empty file.
16 changes: 2 additions & 14 deletions src/CBJQ_SS_FrontEnd_tk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,6 @@ def execAction_threading(self, **kwargs):
thread.start()

def execAction(self, **kwargs):

def waitlast():
nonlocal output
output = sp.stdout.readline()

self.displayLog_text.insertAndScrollToEnd('[+]' + '运行前报告' + '=' * 15)
self.displayLog_text.insertAndScrollToEnd(kwargs)
launch_args = []
Expand All @@ -225,22 +220,15 @@ def waitlast():
with subprocess.Popen(launch_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf-8') as sp:
self.displayLog_text.insertAndScrollToEnd(f'sp.pid: {sp.pid}')
self.displayLog_text.insertAndScrollToEnd('[+]' + '运行报告' + '-' * 15)
thread = threading.Thread(target=waitlast)
while True:
while sp.poll() is None:
# print('to read')
# output = sp.communicate(timeout=1)[0]
if sp.poll() is not None:
thread.start()
if not thread.is_alive():
break
else:
output = sp.stdout.readline()
output = sp.stdout.readline()
# print(f'[stdout]: {i}', end='')
# self.displayLog_text.insert('end', i)
# self.displayLog_text.yview_moveto(1)
self.displayLog_text.insertAndScrollToEnd(output, end='') # instance method
# self.displayLog_text.update()
thread.join(timeout=3)
print('')
self.displayLog_text.insertAndScrollToEnd('[-]' + '运行后报告' + '-' * 15)
self.displayLog_text.insertAndScrollToEnd('[-]' + '' + '=' * 15)
Expand Down

0 comments on commit 8c19ce7

Please sign in to comment.