From e8f548003cc65e1a0a1ee31817fbe2b02f67067d Mon Sep 17 00:00:00 2001 From: JeffreyChen <33644111+JE-Chen@users.noreply.github.com> Date: Tue, 16 Jul 2024 09:49:09 +0800 Subject: [PATCH] Fix windows problem and update README Fix windows problem and update README --- README.md | 8 ++++- .../process_executor/task_process_manager.py | 29 ++++++++++--------- dev_requirements.txt | 4 +-- pyproject.toml | 8 ++--- dev.toml => stable.toml | 8 ++--- 5 files changed, 33 insertions(+), 24 deletions(-) rename dev.toml => stable.toml (91%) diff --git a/README.md b/README.md index 7838437..4820391 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,12 @@ [Using this IDE edit tkinter video](https://www.youtube.com/watch?v=VXm8L2qrdSU&ab_channel=JEChen) +--- + +## Notice +> * If you can't run program and get argument or internal error on windows, Please update your powershell. +> * https://github.com/PowerShell/PowerShell/releases + --- ## What is Automation Editor > Project Kanban \ @@ -49,4 +55,4 @@ ### install > pip install automation_editor -![Architecture Diagram](architecture_diagram/AutomationEditorArchitectureDiagram.drawio.png) \ No newline at end of file +![Architecture Diagram](architecture_diagram/AutomationEditorArchitectureDiagram.drawio.png) diff --git a/automation_editor/extend/process_executor/task_process_manager.py b/automation_editor/extend/process_executor/task_process_manager.py index ac9bcc1..084f0b2 100644 --- a/automation_editor/extend/process_executor/task_process_manager.py +++ b/automation_editor/extend/process_executor/task_process_manager.py @@ -1,3 +1,4 @@ +import json import queue import subprocess import sys @@ -53,21 +54,24 @@ def renew_path(self) -> None: def start_test_process(self, package: str, exec_str: str): self.renew_path() - args = [ - self.compiler_path, - "-m", - package, - "--execute_str", - exec_str - ] - if sys.platform not in ["win32", "cygwin", "msys"]: + if sys.platform in ["win32", "cygwin", "msys"]: + exec_str = json.dumps(exec_str) + args = [ + self.compiler_path, + "-m", + package, + "--execute_str", + exec_str + ] + else: args = " ".join([f"{self.compiler_path}", f"-m {package}", "--execute_str", f"{exec_str}"]) - print(args) self.process: subprocess.Popen = subprocess.Popen( args, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - shell=True + shell=True, + encoding=self.program_encoding ) self.still_run_program = True # program output message queue thread @@ -145,7 +149,7 @@ def print_and_clear_queue(self): def read_program_output_from_process(self): while self.still_run_program: self.process: subprocess.Popen - program_output_data = self.process.stdout.read(self.program_buffer_size).decode(self.program_encoding) + program_output_data = self.process.stdout.read(self.program_buffer_size) if self.process: self.process.stdout.flush() if program_output_data.strip() != "": @@ -153,8 +157,7 @@ def read_program_output_from_process(self): def read_program_error_output_from_process(self): while self.still_run_program: - program_error_output_data = self.process.stderr.read(self.program_buffer_size).decode( - self.program_encoding) + program_error_output_data = self.process.stderr.read(self.program_buffer_size) if self.process: self.process.stderr.flush() if program_error_output_data.strip() != "": diff --git a/dev_requirements.txt b/dev_requirements.txt index cd842b7..7d2dfb9 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,4 +1,4 @@ -wheel +build twine sphinx sphinx-rtd-theme @@ -8,4 +8,4 @@ je-load-density je-auto-control je-web-runner je-mail-thunder -automation_editor_dev \ No newline at end of file +automation_editor_dev diff --git a/pyproject.toml b/pyproject.toml index 126ebd8..cae78ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ -# Rename to build stable version -# This is stable version +# Rename to dev version +# This is dev version [build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] -name = "automation_editor" -version = "0.0.33" +name = "automation_editor_dev" +version = "0.0.34" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" }, ] diff --git a/dev.toml b/stable.toml similarity index 91% rename from dev.toml rename to stable.toml index 72755a9..659ea56 100644 --- a/dev.toml +++ b/stable.toml @@ -1,12 +1,12 @@ -# Rename to dev version -# This is dev version +# Rename to build stable version +# This is stable version [build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] -name = "automation_editor_dev" -version = "0.0.33" +name = "automation_editor" +version = "0.0.34" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" }, ]