forked from Leinad4Mind/1fichier-dl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1fichier-dl.py
34 lines (30 loc) · 1.15 KB
/
1fichier-dl.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
#!/usr/bin/env python3
import os
import sys
import logging
from core.gui import gui
log_level = logging.DEBUG
if getattr(sys, 'frozen', False):
# If the script is running as a bundled executable (e.g., PyInstaller)
log_dir = os.path.join(os.path.dirname(sys.executable), 'app')
log_level = logging.INFO
else:
# If the script is running in a development environment
log_dir = os.path.join(os.path.dirname(__file__), 'app')
if __name__ == '__main__':
try:
# Check if the log directory exists, and if not, create it
if not os.path.exists(log_dir):
os.makedirs(log_dir)
log_file = os.path.join(log_dir, 'logs.txt')
logging.basicConfig(filename=log_file,
level=log_level, filemode='w')
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
logger = logging.getLogger(__name__)
gui.Gui()
except Exception as e:
# 예외 발생 시 handle_exit() 호출
gui.Gui().actions.handle_exit()
logger = logging.getLogger(__name__) # Move logger definition here
logger.debug(__name__+' Exception')
logger.exception(e)