def inner(): module_path = get_caller_path() # Must be called before anything else app = wx.App(False) i18n.load(language) # load gui components after loading the language pack from gooey.gui.client_app import ClientApp from gooey.gui.client_app import EmptyClientApp from gooey.gui.base_window import BaseWindow from gooey.gui.advanced_config import AdvancedConfigPanel from gooey.gui.basic_config_panel import BasicConfigPanel if config: parser = get_parser(module_path) client_app = ClientApp(parser, payload) if advanced: BodyPanel = partial(AdvancedConfigPanel, action_groups=client_app.action_groups) else: BodyPanel = BasicConfigPanel # User doesn't want to display configuration screen # Just jump straight to the run panel else: BodyPanel = BasicConfigPanel client_app = EmptyClientApp() frame = BaseWindow(BodyPanel, client_app, params) if not config: frame.ManualStart() frame.Show(True) app.MainLoop()
def inner(): module_path = get_caller_path() # Must be called before anything else app = wx.App(False) i18n.load(language) # load gui components after loading the language pack from gooey.gui.client_app import ClientApp from gooey.gui.client_app import EmptyClientApp from gooey.gui.base_window import BaseWindow from gooey.gui.advanced_config import AdvancedConfigPanel from gooey.gui.basic_config_panel import BasicConfigPanel if config: parser = get_parser(module_path) client_app = ClientApp(parser, payload) if advanced: BodyPanel = partial(AdvancedConfigPanel, action_groups=client_app.action_groups) else: BodyPanel = BasicConfigPanel # User doesn't want to display configuration screen # Just jump straight to the run panel else: BodyPanel = BasicConfigPanel client_app = EmptyClientApp(payload) frame = BaseWindow(BodyPanel, client_app, params) if not config: frame.ManualStart() frame.Show(True) app.MainLoop()
def test_i18n_loads_module_by_name(self): self.assertTrue(i18n._DICTIONARY is None) i18n.load('english') self.assertTrue(i18n._DICTIONARY is not None) self.assertEqual('Cancel', i18n.translate('cancel')) i18n.load('french') self.assertEqual('Annuler', i18n.translate('cancel'))
def __init__(self, language: int = 0, log_level: int = 0, screen_time_out: int = 0, screen_long_time_out: int = 0, screen_post_timeout: int = 0, connect_mode: int = 0, port: int = 0, log_handler=None, host: int = 0): self._ID = None if log_handler is not None and not callable(log_handler): raise TypeError('[PyPtt] log_handler is must callable!!') if log_handler is not None: has_log_handler = True set_log_handler_result = True try: log_handler(f'PyPtt v {version.V}') log_handler('Developed by CodingMan') except Exception: log_handler = None set_log_handler_result = False else: has_log_handler = False print(f'PyPtt v {version.V}') print('Developed by CodingMan') self._login_status = False self._unregistered_user = True self.config = config.Config() if not isinstance(language, int): raise TypeError('[PyPtt] language must be integer') if not isinstance(log_level, int): raise TypeError('[PyPtt] log_level must be integer') if not isinstance(screen_time_out, int): raise TypeError('[PyPtt] screen_timeout must be integer') if not isinstance(screen_long_time_out, int): raise TypeError('[PyPtt] screen_long_timeout must be integer') if not isinstance(host, int): raise TypeError('[PyPtt] host must be integer') if screen_time_out != 0: self.config.screen_timeout = screen_time_out if screen_long_time_out != 0: self.config.screen_long_timeout = screen_long_time_out if screen_post_timeout != 0: self.config.screen_post_timeout = screen_post_timeout if log_level == 0: log_level = self.config.log_level elif not lib_util.check_range(log.level, log_level): raise ValueError('[PyPtt] Unknown log_level', log_level) else: self.config.log_level = log_level if language == 0: language = self.config.language elif not lib_util.check_range(i18n.language, language): raise ValueError('[PyPtt] Unknown language', language) else: self.config.language = language i18n.load(self.config.language) if log_handler is not None: self.config.log_handler = log_handler log.show_value(self.config, log.level.INFO, i18n.log_handler, i18n.Init) elif has_log_handler and not set_log_handler_result: log.show_value(self.config, log.level.INFO, i18n.log_handler, [i18n.Init, i18n.Fail]) if self.config.language == i18n.language.CHINESE: log.show_value(self.config, log.level.INFO, [i18n.ChineseTranditional, i18n.languageModule], i18n.Init) elif self.config.language == i18n.language.ENGLISH: log.show_value(self.config, log.level.INFO, [i18n.English, i18n.languageModule], i18n.Init) if connect_mode == 0: connect_mode = self.config.connect_mode elif not lib_util.check_range(connect_core.connect_mode, connect_mode): raise ValueError('[PyPtt] Unknown connect_mode', connect_mode) else: self.config.connect_mode = connect_mode if port == 0: port = self.config.port elif not 0 < port < 65535: raise ValueError('[PyPtt] Unknown port', port) else: self.config.port = port if host == 0: host = self.config.host elif not lib_util.check_range(data_type.host_type, host): raise ValueError('[PyPtt] Unknown host', host) self.config.host = host if self.config.host == data_type.host_type.PTT1: log.show_value(self.config, log.level.INFO, [i18n.Connect, i18n.host], i18n.PTT) elif self.config.host == data_type.host_type.PTT2: log.show_value(self.config, log.level.INFO, [i18n.Connect, i18n.host], i18n.PTT2) elif self.config.host == data_type.host_type.LOCALHOST: log.show_value(self.config, log.level.INFO, [i18n.Connect, i18n.host], i18n.Localhost) self.connect_core = connect_core.API(self.config) self._ExistBoardList = [] self._ModeratorList = dict() self._LastThrowWaterBallTime = 0 self._ThreadID = threading.get_ident() log.show_value(self.config, log.level.DEBUG, 'ThreadID', self._ThreadID) log.show_value(self.config, log.level.INFO, [ i18n.Library, ' v ' + version.V, ], i18n.Init)
import conf import db import error import photo import spec import util import i18n from jsonencoder import jsond urls = ("/", "page", "/login", "login", "/logout", "logout", "/tmpl", "tmpl", "/api/?", "api_info", "/api/(.+)", "api") web.config.debug = conf.debug app = web.application(urls, globals()) i18n.load(conf.locale) render = web.template.render("template/", globals={"_": i18n.gettext}) # Setup session def createSession(): if conf.session_type == "mongo": import session_mongo store = session_mongo.MongoStore(db.db, "sessions") elif conf.session_type == "memcache": import session_memcache store = session_memcache.MemcacheStore(conf.session_memcache_servers, conf.session_timeout) return web.session.Session(app, store)
'page', '/login', 'login', '/logout', 'logout', '/tmpl', 'tmpl', '/api/?', 'api_info', '/api/(.+)', 'api', ) web.config.debug = conf.debug app = web.application(urls, globals()) i18n.load(conf.locale) render = web.template.render('template/', globals={'_': i18n.gettext}) # Setup session def createSession(): if conf.session_type == 'mongo': import session_mongo store = session_mongo.MongoStore(db.db, 'sessions') elif conf.session_type == 'memcache': import session_memcache store = session_memcache.MemcacheStore(conf.session_memcache_servers, conf.session_timeout) return web.session.Session(app, store)