-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
65 lines (56 loc) · 2.37 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import time
import subprocess
import pyautogui
import time
import sys
pyautogui.PAUSE = 2
if(sys.argv[1] == "vs"):
program_path = r'"C:\Users\zeger\AppData\Local\Programs\Microsoft VS Code\Code.exe"'
if(sys.argv[1] == "intellij"):
program_path = r'"C:\Program Files\JetBrains\IntelliJ IDEA 2022.2.3\bin\idea64.exe"'
if(sys.argv[2] == "python"):
script_path = "testcode.py"
if(sys.argv[2] == "javascript"):
script_path = "server.js"
if(sys.argv[2] == "java"):
script_path = "Main.java"
command1 = f"{program_path} {script_path} --wait"
# command2 =
print(command1)
try:
result = subprocess.Popen(command1, stdout=subprocess.PIPE, universal_newlines=True)
if(sys.argv[1] == "vs"):
for stdout_line in iter(result.stdout.readline, ""):
print(stdout_line)
if "successfully created" in stdout_line:
if(sys.argv[2] == "python"):
pyautogui.hotkey('ctrl', 'shit', 'p')
pyautogui.write('>python: run python file in terminal')
pyautogui.press('enter')
if(sys.argv[2] == "javascript"):
pyautogui.hotkey('ctrl', 'alt', 'n')
if(sys.argv[2] == "java"):
pyautogui.hotkey('ctrl', 'alt', 'n')
# pyautogui.click(1800,60)
result.stdout.close()
return_code = result.wait()
if return_code:
raise subprocess.CalledProcessError(return_code, cmd)
if(sys.argv[1] == "intellij"):
for stdout_line in iter(result.stdout.readline, ""):
if "RdCoroutineScope" in stdout_line:
time.sleep(10)
if(sys.argv[2] == "python"):
pyautogui.hotkey('alt', 'f12')
pyautogui.write("python testcode.py intellij")
pyautogui.press('enter')
if(sys.argv[2] == "javascript"):
pyautogui.hotkey('alt', 'f12')
pyautogui.write("node server.js intellij")
pyautogui.press('enter')
if(sys.argv[2] == "java"):
pyautogui.hotkey('alt', 'f12')
pyautogui.write("javac Main.java ; java Main intellij")
pyautogui.press('enter')
except subprocess.CalledProcessError as err:
print(err.stderr)