diff --git a/src/main.py b/src/main.py index c44a65a3..3022dbad 100644 --- a/src/main.py +++ b/src/main.py @@ -1,4 +1,11 @@ # -*- coding: utf-8 -*- +import sys +import os +#redirect the original stdout and stderr +stdout=sys.stdout +stderr=sys.stderr +sys.stdout = open(os.path.join(os.getenv("temp"), "stdout.log"), "w") +sys.stderr = open(os.path.join(os.getenv("temp"), "stderr.log"), "w") import languageHandler import wx import paths @@ -14,6 +21,22 @@ import keys from mysc.thread_utils import call_threaded from update import updater import fixes +#extra variables to control the temporal stdout and stderr, while the final files are opened. We understand that some errors could happen while all outputs are closed, so let's try to avoid it. +stdout_temp=sys.stdout +stderr_temp=sys.stderr +#if it's a binary version +if hasattr(sys, 'frozen'): + sys.stderr = open(paths.logs_path("stderr.log"), 'w') + sys.stdout = open(paths.logs_path("stdout.log"), 'w') +else: + sys.stdout=stdout + sys.stderr=stderr +#the final log files have been opened succesfully, let's close the temporal files +stdout_temp.close() +stderr_temp.close() +#finally, remove the temporal files. TW Blue doesn't need them anymore, and we will get more free space on the harddrive +os.remove(stdout_temp.name) +os.remove(stderr_temp.name) log = logging.getLogger("main") def setup(): diff --git a/src/setup.py b/src/setup.py index 2b7eed40..6bdf51eb 100644 --- a/src/setup.py +++ b/src/setup.py @@ -21,7 +21,7 @@ from setuptools import setup, find_packages import py2exe import os -import gettext, gettext_windows; gettext_windows.setup_env_windows() +import gettext import application import platform from glob import glob @@ -43,7 +43,7 @@ def get_data(): import sound_lib import enchant return [ - ("", ["conf.defaults", "sessions.defaults", "icon.ico"]), + ("", ["conf.defaults", "app-configuration.defaults", "icon.ico"]), ("dropbox", ["trusted-certs.crt"]), ("requests", ["cacert.pem"]), ("accessible_output2/lib", glob("accessible_output2/lib/*.dll")), @@ -85,11 +85,12 @@ if __name__ == '__main__': author_email = application.authorEmail, version = application.version, url = application.url, -packages=find_packages(), +packages= find_packages(), data_files = get_data(), options = { 'py2exe': { 'optimize':2, + 'packages': ["pubsub", "pubsub.core", "pubsub.core.kwargs"], 'dll_excludes': ["MPR.dll", "api-ms-win-core-apiquery-l1-1-0.dll", "api-ms-win-core-console-l1-1-0.dll", "api-ms-win-core-delayload-l1-1-1.dll", "api-ms-win-core-errorhandling-l1-1-1.dll", "api-ms-win-core-file-l1-2-0.dll", "api-ms-win-core-handle-l1-1-0.dll", "api-ms-win-core-heap-obsolete-l1-1-0.dll", "api-ms-win-core-libraryloader-l1-1-1.dll", "api-ms-win-core-localization-l1-2-0.dll", "api-ms-win-core-processenvironment-l1-2-0.dll", "api-ms-win-core-processthreads-l1-1-1.dll", "api-ms-win-core-profile-l1-1-0.dll", "api-ms-win-core-registry-l1-1-0.dll", "api-ms-win-core-synch-l1-2-0.dll", "api-ms-win-core-sysinfo-l1-2-0.dll", "api-ms-win-security-base-l1-2-0.dll", "api-ms-win-core-heap-l1-2-0.dll", "api-ms-win-core-interlocked-l1-2-0.dll", "api-ms-win-core-localization-obsolete-l1-1-0.dll", "api-ms-win-core-string-l1-1-0.dll", "api-ms-win-core-string-obsolete-l1-1-0.dll", "WLDAP32.dll", "MSVCP90.dll"], 'skip_archive': True },