2018-01-24 17:43:35 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-03-04 12:29:25 -06:00
|
|
|
from __future__ import unicode_literals # at top of module
|
2018-10-08 11:20:45 -05:00
|
|
|
# this is the first fix we have to import just before the paths module would.
|
|
|
|
# it changes a call from wintypes to ctypes.
|
|
|
|
from fixes import fix_winpaths
|
|
|
|
fix_winpaths.fix()
|
2018-03-12 10:02:18 -06:00
|
|
|
import os
|
|
|
|
import logging
|
|
|
|
import storage
|
2018-03-12 12:27:15 -06:00
|
|
|
import traceback
|
2018-03-12 17:11:05 -06:00
|
|
|
import sys
|
2018-03-12 10:02:18 -06:00
|
|
|
storage.setup()
|
|
|
|
logging.basicConfig(filename=os.path.join(storage.data_directory, "info.log"), level=logging.DEBUG, filemode="w")
|
2018-04-01 04:44:12 -05:00
|
|
|
# Let's mute the google discovery_cache logger as we won't use it and we'll avoid some tracebacks.
|
|
|
|
glog = logging.getLogger("googleapiclient.discovery_cache")
|
|
|
|
glog.setLevel(logging.CRITICAL)
|
|
|
|
# Let's capture all exceptions raised in our log file (especially useful for pyinstaller builds).
|
2018-03-12 12:27:15 -06:00
|
|
|
sys.excepthook = lambda x, y, z: logging.critical(''.join(traceback.format_exception(x, y, z)))
|
2018-03-12 10:02:18 -06:00
|
|
|
log = logging.getLogger("main")
|
|
|
|
log.debug("Logger initialized. Saving debug to {0}".format(storage.data_directory,))
|
|
|
|
log.debug("Using Python version {0}".format(sys.version,))
|
2018-03-04 12:29:25 -06:00
|
|
|
if sys.version[0] == "2":
|
2018-03-12 09:28:21 -06:00
|
|
|
if hasattr(sys, "frozen"):
|
2018-03-12 10:02:18 -06:00
|
|
|
log.debug("Applying fixes for Python 2 frozen executables.")
|
2018-03-12 09:28:21 -06:00
|
|
|
import fixes
|
|
|
|
fixes.setup()
|
2018-01-24 17:43:35 -06:00
|
|
|
import i18n
|
2018-02-28 13:50:31 -06:00
|
|
|
i18n.setup()
|
2018-01-24 17:43:35 -06:00
|
|
|
import application
|
2018-03-12 12:27:15 -06:00
|
|
|
import widgetUtils
|
2018-07-15 09:15:05 -05:00
|
|
|
import paths
|
2018-01-24 17:43:35 -06:00
|
|
|
|
|
|
|
def setup():
|
2018-03-12 12:27:15 -06:00
|
|
|
log.debug("Starting music-dl %s" % (application.version,))
|
|
|
|
log.debug("Application path is %s" % (paths.app_path(),))
|
2018-01-24 17:43:35 -06:00
|
|
|
from controller import mainController
|
|
|
|
app = widgetUtils.mainLoopObject()
|
|
|
|
log.debug("Created Application mainloop object")
|
|
|
|
r = mainController.Controller()
|
|
|
|
app.run()
|
|
|
|
|
|
|
|
setup()
|