forked from SuwilanjiTrey/SimpleAiProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_dependancies.py
More file actions
30 lines (24 loc) · 906 Bytes
/
install_dependancies.py
File metadata and controls
30 lines (24 loc) · 906 Bytes
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
import os
import subprocess
def run_command_in_cmd(command, base_directory=None, new_window=False):
if base_directory is None:
base_directory = os.path.join(os.path.expanduser('~'), 'Desktop')
if base_directory:
os.chdir(base_directory)
if new_window:
# Use 'start' with 'cmd' to open a new window
cmd = f'start cmd /K "{command}"'
else:
# Execute in the same window
cmd = f'cmd /C "{command}"'
try:
process = subprocess.Popen(cmd, shell=True)
process.communicate(timeout=600) # 10 minutes timeout
except subprocess.TimeoutExpired:
process.kill()
raise
def install():
command = "pip install pygame"
run_command_in_cmd(command, new_window=True)
if __name__ == '__main__':
install()