mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-18 09:57:40 +03:00
Tweak EDMarketConnector.py startup so the redirect is first
* Don't want any output until the redirect is done when running frozen. * Make the line buffering in the redirect more obvious.
This commit is contained in:
parent
4ecb4f573a
commit
3b87df17af
@ -1020,13 +1020,15 @@ def test_logging():
|
|||||||
|
|
||||||
# Run the app
|
# Run the app
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# Keep this as the very first code run to be as sure as possible of no
|
||||||
enforce_single_instance()
|
# output until after this redirect is done, if needed.
|
||||||
if getattr(sys, 'frozen', False):
|
if getattr(sys, 'frozen', False):
|
||||||
# By default py2exe tries to write log to dirname(sys.executable) which fails when installed
|
# By default py2exe tries to write log to dirname(sys.executable) which fails when installed
|
||||||
import tempfile
|
import tempfile
|
||||||
# unbuffered not allowed for text in python3, so use line buffering
|
# unbuffered not allowed for text in python3, so use `1 for line buffering
|
||||||
sys.stdout = sys.stderr = open(join(tempfile.gettempdir(), f'{appname}.log'), 'wt', 1)
|
sys.stdout = sys.stderr = open(join(tempfile.gettempdir(), f'{appname}.log'), mode='wt', buffering=1)
|
||||||
|
|
||||||
|
enforce_single_instance()
|
||||||
|
|
||||||
logger = EDMCLogging.Logger(appname).get_logger()
|
logger = EDMCLogging.Logger(appname).get_logger()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user