Skip to content

Commit ea983b4

Browse files
committed
add install menu
add install menu
1 parent f71cb35 commit ea983b4

File tree

9 files changed

+81
-36
lines changed

9 files changed

+81
-36
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import sys
22

33
from PySide6.QtWidgets import QApplication
4-
from je_editor import EditorMain
4+
from je_editor import EditorMain, shell_manager
55
from qt_material import apply_stylesheet
66

77
from automation_editor.automation_editor_ui. \
88
menu.api_testka_menu.build_api_testka_menu import set_apitestka_menu
99
from automation_editor.automation_editor_ui. \
1010
menu.auto_control_menu.build_autocontrol_menu import set_autocontrol_menu
11+
from automation_editor.automation_editor_ui.menu.install_menu.build_install_menu import set_install_menu
1112
from automation_editor.automation_editor_ui.menu. \
1213
load_density_menu.build_load_density_menu import set_load_density_menu
1314
from automation_editor.automation_editor_ui \
@@ -16,7 +17,7 @@
1617
syntax_extend_package
1718

1819

19-
class ITE(EditorMain):
20+
class AutomationEditor(EditorMain):
2021

2122
def __init__(self):
2223
super().__init__()
@@ -26,13 +27,20 @@ def __init__(self):
2627
set_apitestka_menu(self)
2728
set_load_density_menu(self)
2829
set_web_runner_menu(self)
30+
set_install_menu(self)
2931
syntax_extend_package(self)
32+
shell_manager.main_window = self
33+
shell_manager.later_init()
3034
self.setWindowTitle("Automation Editor")
3135

3236

3337
def start_editor():
3438
new_editor = QApplication(sys.argv)
35-
window = ITE()
39+
window = AutomationEditor()
3640
apply_stylesheet(new_editor, theme='dark_amber.xml')
37-
window.show()
41+
window.showMaximized()
42+
try:
43+
window.startup_setting()
44+
except Exception as error:
45+
print(repr(error))
3846
sys.exit(new_editor.exec())

automation_editor/automation_editor_ui/menu/api_testka_menu/build_api_testka_menu.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,4 @@ def create_project():
9191
package = package_manager.installed_package_dict.get("je_api_testka", None)
9292
if package is not None:
9393
package.create_project_dir()
94+

automation_editor/automation_editor_ui/menu/install_menu/__init__.py

Whitespace-only changes.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
from PySide6.QtGui import QAction
2+
from PySide6.QtWidgets import QMainWindow
3+
4+
5+
def set_install_menu(ui_we_want_to_set: QMainWindow):
6+
ui_we_want_to_set.install_menu = ui_we_want_to_set.menu.addMenu("Install")
7+
# Try to install Build Tools
8+
ui_we_want_to_set.install_tool_action = QAction("Install Build Tools")
9+
ui_we_want_to_set.install_tool_action.triggered.connect(
10+
install_build_tools
11+
)
12+
ui_we_want_to_set.install_menu.addAction(ui_we_want_to_set.install_tool_action)
13+
# Try to install AutoControl
14+
ui_we_want_to_set.install_autocontrol_action = QAction("Install AutoControl")
15+
ui_we_want_to_set.install_autocontrol_action.triggered.connect(
16+
install_autocontrol
17+
)
18+
ui_we_want_to_set.install_menu.addAction(ui_we_want_to_set.install_autocontrol_action)
19+
# Try to install APITestka
20+
ui_we_want_to_set.install_api_testka = QAction("Install APITestka")
21+
ui_we_want_to_set.install_api_testka.triggered.connect(
22+
install_api_testka
23+
)
24+
ui_we_want_to_set.install_menu.addAction(ui_we_want_to_set.install_api_testka)
25+
# Try to install LoadDensity
26+
ui_we_want_to_set.install_load_density_action = QAction("Install LoadDensity")
27+
ui_we_want_to_set.install_load_density_action.triggered.connect(
28+
install_load_density
29+
)
30+
ui_we_want_to_set.install_menu.addAction(ui_we_want_to_set.install_load_density_action)
31+
# Try to install WebRunner
32+
ui_we_want_to_set.install_web_runner_action = QAction("Install WebRunner")
33+
ui_we_want_to_set.install_web_runner_action.triggered.connect(
34+
install_web_runner
35+
)
36+
ui_we_want_to_set.install_menu.addAction(ui_we_want_to_set.install_web_runner_action)
37+
38+
39+
def install_build_tools():
40+
from je_editor import shell_manager
41+
shell_manager.exec_shell("pip install --user --upgrade pip setuptools wheel")
42+
43+
44+
def install_autocontrol():
45+
from je_editor import shell_manager
46+
shell_manager.exec_shell("pip install --user --upgrade je_auto_control")
47+
48+
49+
def install_api_testka():
50+
from je_editor import shell_manager
51+
shell_manager.exec_shell("pip install --user --upgrade je_api_testka")
52+
53+
54+
def install_load_density():
55+
from je_editor import shell_manager
56+
shell_manager.exec_shell("pip install --user --upgrade je_load_density")
57+
58+
59+
def install_web_runner():
60+
from je_editor import shell_manager
61+
shell_manager.exec_shell("pip install --user --upgrade je_web_runner")

automation_editor/automation_editor_ui/menu/load_density_menu/build_load_density_menu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ def open_web_browser(url: str):
9191
def create_project():
9292
package = package_manager.installed_package_dict.get("je_load_density", None)
9393
if package is not None:
94-
package.create_project_dir()
94+
package.create_project_dir()
Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import os
2-
import sys
3-
from importlib import import_module
4-
from importlib.util import find_spec
52

63

74
class PackageManager(object):
@@ -21,32 +18,6 @@ def __init__(self):
2118
"je_api_testka",
2219
"je_web_runner"
2320
]
24-
try:
25-
import je_load_density
26-
import je_web_runner
27-
import je_auto_control
28-
import je_api_testka
29-
self.installed_package_dict.update(
30-
{
31-
"je_api_testka": je_api_testka,
32-
"je_web_runner": je_web_runner,
33-
"je_auto_control": je_auto_control,
34-
"je_load_density": je_load_density,
35-
}
36-
)
37-
except ImportError:
38-
pass
39-
40-
# This will make subprocess deadlock so emm we don't use this
41-
def check_package(self):
42-
for package, value in self.installed_package_dict.items():
43-
found_spec = find_spec(package)
44-
if found_spec is not None and value is None:
45-
try:
46-
installed_package = import_module(found_spec.name)
47-
self.installed_package_dict.update({found_spec.name: installed_package})
48-
except ModuleNotFoundError as error:
49-
print(repr(error), file=sys.stderr)
5021

5122

5223
package_manager = PackageManager()

automation_editor/utils/test_executor/task_process_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ def pull_text(self):
9191
except queue.Empty:
9292
pass
9393
if self.process.returncode == 0:
94+
self.timer.stop()
9495
self.exit_program()
9596
elif self.process.returncode is not None:
96-
self.exit_program()
9797
self.timer.stop()
98+
self.exit_program()
9899
if self.still_run_program:
99100
# poll return code
100101
self.process.poll()
@@ -122,6 +123,7 @@ def print_and_clear_queue(self):
122123
if std_err:
123124
self.code_result.append(std_err)
124125
self.code_result.setTextColor(output_color)
126+
print(f"Task exit with code {self.process.returncode}")
125127
except queue.Empty:
126128
pass
127129
self.run_output_queue = queue.Queue()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import sys
2+
print(sys.prefix)

0 commit comments

Comments
 (0)