socializer/src/main.py

77 lines
2.5 KiB
Python
Raw Normal View History

2016-02-13 17:06:36 -06:00
# -*- coding: utf-8 -*-
2016-06-29 17:21:00 -05:00
import logger
import sys
import fixes
import traceback
#if hasattr(sys, "frozen"):
fixes.setup()
2016-02-13 17:06:36 -06:00
import platform
import languageHandler
import widgetUtils
import paths
import config
import output
import logging
import keys
import application
from wxUI.commonMessages import alpha_reminder
if hasattr(sys, "frozen"):
sys.excepthook = lambda x, y, z: logging.critical(''.join(traceback.format_exception(x, y, z)))
2016-02-13 17:06:36 -06:00
from mysc.thread_utils import call_threaded
2019-01-15 16:20:08 -06:00
from wxUI import commonMessages
from extra.SpellChecker import checker # Load dictionaries in advance for spelling correction
2016-02-13 17:06:36 -06:00
log = logging.getLogger("main")
orig_session_init = None
2016-02-13 17:06:36 -06:00
def setup():
global orig_session_init
2016-02-13 17:06:36 -06:00
log.debug("Starting Socializer %s" % (application.version,))
config.setup()
log.debug("Using %s %s" % (platform.system(), platform.architecture()[0]))
2019-01-01 19:42:53 -06:00
log.debug("Application path is %s" % (paths.app_path(),))
2016-02-13 17:06:36 -06:00
log.debug("config path is %s" % (paths.config_path(),))
output.setup()
languageHandler.setLanguage(config.app["app-settings"]["language"])
log.debug("Language set to %s" % (languageHandler.getLanguage()))
2016-02-13 17:06:36 -06:00
keys.setup()
2019-01-15 16:20:08 -06:00
app = widgetUtils.mainLoopObject()
if config.app["app-settings"]["first_start"]:
proxy_option = commonMessages.proxy_question()
if proxy_option == widgetUtils.YES:
config.app["app-settings"]["use_proxy"] = True
config.app["app-settings"]["first_start"] = False
config.app.write()
2019-01-15 16:20:08 -06:00
if config.app["app-settings"]["use_proxy"]:
log.debug("Enabling proxy support... ")
import requests
orig_session_init=requests.sessions.Session.__init__
requests.sessions.Session.__init__=patched_session_init
requests.Session.__init__=patched_session_init
2016-02-13 17:06:36 -06:00
from controller import mainController
from sessionmanager import sessionManager
2019-01-15 16:20:08 -06:00
log.debug("Created Application mainloop object")
if application.is_pyinstaller():
log.debug("Showing reminder about next Socializer alpha... ")
alpha_reminder()
2016-02-13 17:06:36 -06:00
sm = sessionManager.sessionManagerController()
sm.show()
2016-02-13 17:06:36 -06:00
del sm
log.debug("Loading dictionaries for spelling correction...")
# Let's copy dictionary files for the selected language just in case it is not present already.
2019-12-03 12:06:36 -06:00
checker.prepare_dicts(languageHandler.curLang[:2])
call_threaded(checker.load_dicts)
2016-02-13 17:06:36 -06:00
r = mainController.Controller()
call_threaded(r.login)
app.run()
def patched_session_init(self):
global orig_session_init
orig_session_init(self)
2019-01-15 10:06:17 -06:00
self.proxies={"http": "http://socializer:socializer@socializer.su:3128",
"https": "http://socializer:socializer@socializer.su:3128"}
2017-03-13 02:16:34 -06:00
setup()