-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_app_wrapper.py
40 lines (32 loc) · 1.26 KB
/
start_app_wrapper.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
# Jacob Lowe
import subprocess
import os
import sys
import logging
# Set up logging
logging.basicConfig(filename='app.log', level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s')
def main():
try:
# Get the directory of the executable
if getattr(sys, 'frozen', False):
script_dir = sys._MEIPASS
else:
script_dir = os.path.dirname(os.path.abspath(__file__))
# Change to the script directory
os.chdir(script_dir)
batch_file = os.path.join(script_dir, 'start_app.bat')
if not os.path.exists(batch_file):
logging.error(f"Batch file not found at {batch_file}")
raise FileNotFoundError(f"Batch file not found at {batch_file}")
# Call batch file
logging.info(f"Attempting to call {batch_file}")
result = subprocess.run([batch_file], shell=True, capture_output=True, text=True)
logging.info(f"Subprocess return code: {result.returncode}")
logging.info(f"Subprocess stdout: {result.stdout}")
logging.info(f"Subprocess stderr: {result.stderr}")
except Exception as e:
logging.exception("An error occurred")
if __name__ == "__main__":
main()
input("Press Enter to exit...")