def next_clicked(widget): os.environ["LANGUAGE"] = _SYSTEM_LANGUAGE app.config.set( prefs.LANGUAGE, str(lang_options[lang_option_menu.get_selected()][0])) gtcache.init() self.next_page(rebuild=True)
def _subprocess_setup(stdin, stdout): """Does initial setup for a subprocess. Returns a SubprocessHandler to use for the subprocess raises the same exceptions that _load_obj does, namely: :raises IOError: low-level error while reading from the pipe :raises LoadError: data read was corrupted """ # disable warnings so we don't get too much junk on stderr warnings.filterwarnings("ignore") # setup MessageHandler for messages going to the main process msg_handler = PipeMessageProxy(stdout) SubprocessResponse.install_handler(msg_handler) # load startup info msg = _load_obj(stdin) if not isinstance(msg, StartupInfo): raise LoadError("first message must a StartupInfo obj") # setup some basic modules like config and gtcache initialize_locale() config.load(config.ManualConfig()) app.config.set_dictionary(msg.config_dict) gtcache.init() # setup our handler msg = _load_obj(stdin) if not isinstance(msg, HandlerInfo): raise LoadError("second message must a HandlerInfo obj") try: return msg.handler_class(*msg.handler_args) except StandardError, e: # log this exception for easier debugging. _send_subprocess_error_for_exception() raise LoadError("Exception while constructing handler: %s" % e)
def bootstrap(): """Run this as soon as possible when starting up miro. This method sets up gtcache and the app.config object. Later on, we will replace this app.config with one that's theme aware. """ config.load() gtcache.init() eventloop.setup_config_watcher()
def update_language(widget, index): os.environ["LANGUAGE"] = _SYSTEM_LANGUAGE app.config.set(prefs.LANGUAGE, str(lang_options[index][0])) gtcache.init() # FIXME - this is totally awful and may break at some # point. what happens is that widgetconst translates at # import time, so if someone changes the language, then # the translations have already happened. we reload the # module to force them to happen again. bug 17515 if "miro.frontends.widgets.widgetconst" in sys.modules: reload(sys.modules["miro.frontends.widgets.widgetconst"]) self.this_page(rebuild=True)
def test_gettext_lazy(self): ok = gtcache.gettext_lazy("OK") channels = gtcache.gettext_lazy("Channels") self.assertEqual(ok, u'Valider') self.assertEqual(u'%s' % ok, u'Valider') self.assertEqual(channels, u'Cha\xeenes') self.assertEqual(u'%s' % channels, u'Cha\xeenes') gtcache.init(languages=['en'], localedir=resources.path("testdata/locale")) self.assertEqual(ok, u'OK') self.assertEqual(u'%s' % ok, u'OK') self.assertEqual(channels, u'Channels') self.assertEqual(u'%s' % channels, u'Channels')
def finish_startup_after_config(): """Finish startup tasks once we have config setup. Called from command.InitialConfigCommand. """ from miro import gtcache gtcache.init() from miro import httpclient from miro.dl_daemon import download download.startup() httpclient.init_libcurl() logging.info("Daemon ready")
def next_clicked(widget): os.environ["LANGUAGE"] = _SYSTEM_LANGUAGE app.config.set(prefs.LANGUAGE, str(lang_options[lang_option_menu.get_selected()][0])) gtcache.init() self.next_page(rebuild=True)
def _make_french(*args, **kwargs): gtcache.init(languages=['fr'], localedir=resources.path("testdata/locale")) f(*args, **kwargs)