-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime_setup.py
More file actions
34 lines (26 loc) · 1018 Bytes
/
runtime_setup.py
File metadata and controls
34 lines (26 loc) · 1018 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
31
32
33
34
import os
import platform
import subprocess
from functools import wraps
import config
import logs
def setup_application_environment():
the_path = os.path.dirname(os.path.abspath(__file__))
path_to_remove = os.path.join("lib", "library.zip")
if the_path.endswith(path_to_remove):
the_path = the_path[: -len(path_to_remove)]
print("App path:", the_path)
os.chdir(the_path)
ffmpeg_path = os.path.join(os.getcwd(), "ffmpeg")
os.environ["PATH"] += os.pathsep + ffmpeg_path
config.initilize()
if platform.system() == "Windows":
old_popen = subprocess.Popen
@wraps(old_popen)
def new_popen(*args, startupinfo=None, **kwargs):
if startupinfo is None:
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
return old_popen(*args, startupinfo=startupinfo, **kwargs)
subprocess.Popen = new_popen