def setup (): global app log.debug("Loading global app settings...") app = config_utils.load_config(paths.config_path(MAINFILE), paths.app_path(MAINSPEC)) log.debug("Loading keymap...") global keymap keymap = config_utils.load_config(paths.config_path("keymap.keymap"), paths.app_path("keymaps/"+app['app-settings']['load_keymap']))
def tearDown(self): """ Removes uninstall.exe created for tests and data path.""" fix_winpaths.fix() if os.path.exists(paths.data_path("musicDL")): shutil.rmtree(paths.data_path("musicDL")) if os.path.exists(os.path.join(paths.app_path(), "uninstall.exe")): os.remove(os.path.join(paths.app_path(), "uninstall.exe"))
def tearDown(self): """ Removes uninstall.exe created for tests and data path.""" fix_winpaths.fix() if os.path.exists(paths.app_data_path("musicDL")): shutil.rmtree(paths.app_data_path("musicDL")) if os.path.exists(os.path.join(paths.app_path(), "uninstall.exe")): os.remove(os.path.join(paths.app_path(), "uninstall.exe"))
def setup(): global app log.debug("Loading global app settings...") app = config_utils.load_config(paths.config_path(MAINFILE), paths.app_path(MAINSPEC)) log.debug("Loading keymap...") global keymap keymap = config_utils.load_config( paths.config_path("keymap.keymap"), paths.app_path("keymaps/" + app['app-settings']['load_keymap']))
def setup(): lang = locale.getdefaultlocale()[0] os.environ["lang"] = lang log.debug("System detected language: {0}".format(lang, )) if sys.version[0] == "3": gettext.install("musicdl", localedir=os.path.join(paths.app_path(), "locales")) else: gettext.install("musicdl", localedir=os.path.join(paths.app_path(), "locales"), unicode=True)
def setup(): log.debug("Starting " + application.name + " %s" % (application.version, )) config.setup() fixes.setup() log.debug("Using %s %s" % (platform.system(), platform.architecture()[0])) log.debug("Application path is %s" % (paths.app_path(), )) log.debug("config path is %s" % (paths.config_path(), )) sound.setup() output.setup() languageHandler.setLanguage(config.app["app-settings"]["language"]) keys.setup() from controller import mainController from sessionmanager import sessionManager app = widgetUtils.mainLoopObject() if system == "Windows": if config.app["app-settings"]["donation_dialog_displayed"] == False: donation() updater.do_update() sm = sessionManager.sessionManagerController() sm.fill_list() if len(sm.sessions) == 0: sm.show() else: sm.do_ok() if hasattr(sm.view, "destroy"): sm.view.destroy() del sm r = mainController.Controller() r.view.show() r.do_work() r.check_invisible_at_startup() if system == "Windows": call_threaded(r.start) elif system == "Linux": GLib.idle_add(r.start) app.run()
def test_portable_path(self): """ Testing if paths are generated appropiately. """ storage.setup() self.assertEquals(storage.app_type, "portable") self.assertTrue(os.path.exists(storage.data_directory)) self.assertEquals(storage.data_directory, os.path.join(paths.app_path(), "data"))
def __init__(self): FILE = "sessions.conf" SPEC = "sessions.defaults" try: self.main = Configuration(paths.config_path(FILE), paths.app_path(SPEC)) except ConfigurationResetException: pass
def setup (): global main try: main = Configuration(data_path(MAINFILE), app_path(MAINSPEC)) except ConfigurationResetException: import output output.speak("Unable to load configuration file. Loading default configuration instead.", 0)
def setup (): global main try: main = Configuration(paths.config_path(MAINFILE), paths.app_path(MAINSPEC)) except ConfigurationResetException: pass # return main
def get_configuration(self): """ Gets settings for a session.""" file_ = "%s/session.conf" % (self.session_id,) # try: log.debug("Creating config file %s" % (file_,)) self.settings = Configuration(paths.config_path(file_), paths.app_path("session.defaults"))
def setup(): log.debug("Starting music-dl %s" % (application.version, )) log.debug("Application path is %s" % (paths.app_path(), )) from controller import mainController app = widgetUtils.mainLoopObject() log.debug("Created Application mainloop object") r = mainController.Controller() app.run()
def setup(): log.debug("Starting music-dl %s" % (application.version,)) log.debug("Application path is %s" % (paths.app_path(),)) from controller import mainController app = widgetUtils.mainLoopObject() log.debug("Created Application mainloop object") r = mainController.Controller() app.run()
def encode(self,filename, quality=4.5): system = platform.system() if system == "Windows": subprocess.call(r'"%s" -q %r "%s"' % (paths.app_path('oggenc2.exe'), quality, filename)) return self.filename.replace(".wav",".ogg") else: print "Converting not implimented for this operating system. WAV file incoming." return self.filename
def setup(): global main try: main = Configuration(data_path(MAINFILE), app_path(MAINSPEC)) except ConfigurationResetException: import output output.speak( "Unable to load configuration file. Loading default configuration instead.", 0)
def setup(): global main try: main = Configuration(paths.config_path(MAINFILE), paths.app_path(MAINSPEC)) except ConfigurationResetException: pass # return main
def execute_bootstrap(bootstrap_path, source_path): arguments = r'"%s" "%s" "%s" "%s"' % (os.getpid(), source_path, paths.app_path(), paths.get_executable()) if platform.system() == 'Windows': import win32api win32api.ShellExecute(0, 'open', bootstrap_path, arguments, '', 5) else: import subprocess make_executable(bootstrap_path) subprocess.Popen(['%s %s' % (bootstrap_path, arguments)], shell=True) logger.info("Bootstrap executed")
def make_kmmap(self): res = {} for i in os.listdir(paths.app_path('keymaps')): if ".keymap" not in i: continue try: res[i[:-7]] = i except: log.exception("Exception while loading keymap " + i) return res
def get_configuration(self): """ Gets settings for a session.""" file_ = "%s/session.conf" % (self.session_id,) # try: log.debug("Creating config file %s" % (file_,)) self.settings = config_utils.load_config(paths.config_path(file_), paths.app_path("Conf.defaults")) self.init_sound() self.deshelve()
def setup(): global data_directory if len(glob.glob("Uninstall.exe")) > 0: # installed copy if os.path.exists(paths.app_data_path("musicDL")) == False: paths.prepare_app_data_path("musicDL") data_directory = paths.app_data_path("musicDL") else: data_directory = os.path.join(paths.app_path(), "data") if os.path.exists(data_directory) == False: os.mkdir(data_directory)
def test_installer_path(self): """ Testing if paths are generated appropiately. """ # this is a temporary fix for winpaths. fake_installer_file = open(os.path.join(paths.app_path(), "uninstall.exe"), "w") fake_installer_file.close() fix_winpaths.fix() storage.setup() self.assertEquals(storage.app_type, "installed") self.assertTrue(os.path.exists(storage.data_directory)) self.assertEquals(storage.data_directory, paths.app_data_path("musicDL"))
def make_kmmap(self): res={} for i in os.listdir(paths.app_path('keymaps')): if ".keymap" not in i: continue try: res[i[:-7]] =i except: log.exception("Exception while loading keymap " + i) return res
def __init__(self): self.app = wx.App() self.lc = wx.Locale() lang = languageHandler.getLanguage() wxLang = self.lc.FindLanguageInfo(lang) if not wxLang and '_' in lang: wxLang = self.lc.FindLanguageInfo(lang.split('_')[0]) if hasattr(sys, 'frozen'): self.lc.AddCatalogLookupPathPrefix(paths.app_path("locales")) if wxLang: self.lc.Init(wxLang.Language)
def __init__(self): self.app = wx.App() self.lc = wx.Locale() lang=languageHandler.getLanguage() wxLang=self.lc.FindLanguageInfo(lang) if not wxLang and '_' in lang: wxLang=self.lc.FindLanguageInfo(lang.split('_')[0]) if hasattr(sys,'frozen'): self.lc.AddCatalogLookupPathPrefix(paths.app_path("locales")) if wxLang: self.lc.Init(wxLang.Language)
def test_installer_path(self): """ Testing if paths are generated appropiately. """ # this is a temporary fix for winpaths. fake_installer_file = open( os.path.join(paths.app_path(), "Uninstall.exe"), "w") fake_installer_file.close() fix_winpaths.fix() storage.setup() self.assertEquals(storage.app_type, "installed") self.assertTrue(os.path.exists(storage.data_directory)) self.assertEquals(storage.data_directory, paths.data_path("musicDL"))
def setup(): global data_directory, app_type if len(glob.glob("Uninstall.exe")) > 0: # installed copy if os.path.exists(paths.data_path("musicDL")) == False: os.mkdir(paths.data_path("musicDL")) data_directory = paths.data_path("musicDL") app_type = "installed" else: app_type = "portable" data_directory = os.path.join(paths.app_path(), "data") if os.path.exists(data_directory) == False: os.mkdir(data_directory)
def __init__(self, parent): super(TBIcon, self).__init__() icon = wx.Icon(os.path.join(app_path(), "icon.ico"), wx.BITMAP_TYPE_ICO) self.SetIcon(icon, "%s" % application.name) self.Menu = wx.Menu() ExitId = wx.NewId() ExitOption = wx.MenuItem(self.Menu, ExitId, "E&xit", "Exit %s" % application.name) self.Menu.AppendItem(ExitOption) wx.EVT_MENU(self.Menu, ExitId, lambda evt: interface.exit()) self.Bind(wx.EVT_TASKBAR_RIGHT_DOWN, self.onActivate)
def setup(): global data_directory, app_type if len(glob.glob("Uninstall.exe")) > 0: # installed copy if os.path.exists(paths.app_data_path("musicDL")) == False: paths.prepare_app_data_path("musicDL") data_directory = paths.app_data_path("musicDL") app_type = "installed" else: app_type = "portable" data_directory = os.path.join(paths.app_path(), "data") if os.path.exists(data_directory) == False: os.mkdir(data_directory)
def check_for_update(): if not is_frozen(): return url = updater.find_update_url(application.update_url, application.version) if url is None: return new_path = os.path.join(paths.data_path(application.name), 'updates', 'update.zip') app_updater = updater.AutoUpdater(url, new_path, 'bootstrap.exe', app_path=paths.app_path(), postexecute=paths.executable_path(), finish_callback=update_complete) d = question_dialog(parent=application.main_frame, caption=_("Update %s") % application.name, message=_("An update for %s is available, would you like to download and install it now?") % application.name, style=wx.YES|wx.NO|wx.ICON_WARNING) if d!= wx.ID_YES: return logging.warning("User denied the update request!") logging.debug("User requested %s update. Initializing update process." % application.name) app_updater.start_update()
def __init__(self): super(SysTrayIcon, self).__init__() icon=wx.Icon(os.path.join(paths.app_path(), "icon.ico"), wx.BITMAP_TYPE_ICO) self.SetIcon(icon, application.name) self.menu=wx.Menu() self.tweet = self.menu.Append(wx.ID_ANY, _(u"Tweet")) self.global_settings = self.menu.Append(wx.ID_ANY, _(u"&Global settings")) self.account_settings = self.menu.Append(wx.ID_ANY, _(u"Account se&ttings")) self.update_profile = self.menu.Append(wx.ID_ANY, _(u"Update &profile")) self.show_hide = self.menu.Append(wx.ID_ANY, _(u"&Show / hide")) self.doc = self.menu.Append(wx.ID_ANY, _(u"&Documentation")) self.doc.Enable(False) self.check_for_updates = self.menu.Append(wx.ID_ANY, _(u"Check for &updates")) self.exit = self.menu.Append(wx.ID_ANY, _(u"&Exit"))
def setup(): log.debug("Starting " + application.name + " %s" % (application.version,)) config.setup() log.debug("Using %s %s" % (platform.system(), platform.architecture()[0])) log.debug("Application path is %s" % (paths.app_path(),)) log.debug("config path is %s" % (paths.config_path(),)) sound.setup() output.setup() languageHandler.setLanguage(config.app["app-settings"]["language"]) message(message=_(u"Loading files and configuration, please wait...")) fixes.setup() keys.setup() from controller import mainController from sessionmanager import sessionManager app = widgetUtils.mainLoopObject() gplwarning() if system == "Windows": if config.app["app-settings"]["donation_dialog_displayed"] == False: donation() if config.app["app-settings"]["check_updates"] == True: updater.do_update() else: message(message=_(u"Set to ignore updates at startup. To change this preference, go to global config")) sm = sessionManager.sessionManagerController() sm.fill_list() if len(sm.sessions) == 0: sm.show() else: sm.do_ok() if hasattr(sm.view, "destroy"): sm.view.destroy() del sm r = mainController.Controller() r.view.show() r.do_work() r.check_invisible_at_startup() if system == "Windows": call_threaded(r.start) elif system == "Linux": GLib.idle_add(r.start) message( message=_(u"Welcome to %s. Main application's window will appears shortly. Happy tweeting!") % application.name ) app.run()
def setup(): log.debug("Starting Socializer %s" % (application.version,)) config.setup() log.debug("Using %s %s" % (platform.system(), platform.architecture()[0])) log.debug("Application path is %s" % (paths.app_path(),)) 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())) keys.setup() from controller import mainController from sessionmanager import sessionManager app = widgetUtils.mainLoopObject() log.debug("Created Application mainloop object") sm = sessionManager.sessionManagerController() del sm r = mainController.Controller() call_threaded(r.login) app.run()
def __init__(self): super(SysTrayIcon, self).__init__() icon = wx.Icon(os.path.join(paths.app_path(), "icon.ico"), wx.BITMAP_TYPE_ICO) self.SetIcon(icon, application.name) self.menu = wx.Menu() self.tweet = self.menu.Append(wx.ID_ANY, _(u"Tweet")) self.global_settings = self.menu.Append(wx.ID_ANY, _(u"&Global settings")) self.account_settings = self.menu.Append(wx.ID_ANY, _(u"Account se&ttings")) self.update_profile = self.menu.Append(wx.ID_ANY, _(u"Update &profile")) self.show_hide = self.menu.Append(wx.ID_ANY, _(u"&Show / hide")) self.doc = self.menu.Append(wx.ID_ANY, _(u"&Documentation")) self.doc.Enable(False) self.check_for_updates = self.menu.Append(wx.ID_ANY, _(u"Check for &updates")) self.exit = self.menu.Append(wx.ID_ANY, _(u"&Exit"))
def __init__(self, frame): super(SysTrayIcon, self).__init__() self.frame=frame icon=wx.Icon(os.path.join(paths.app_path(), "icon.ico"), wx.BITMAP_TYPE_ICO) self.SetIcon(icon, application.name) self.menu=wx.Menu() item=self.menu.Append(wx.ID_ANY, _(u"Tweet")) self.Bind(wx.EVT_MENU, frame.compose, item) item=self.menu.Append(wx.ID_ANY, _(u"Preferences")) self.Bind(wx.EVT_MENU, frame.preferences, item) item=self.menu.Append(wx.ID_ANY, _(u"Update profile")) self.Bind(wx.EVT_MENU, frame.update_profile, item) item=self.menu.Append(wx.ID_ANY, _(u"Show / hide")) self.Bind(wx.EVT_MENU, frame.show_hide, item) item=self.menu.Append(wx.ID_ANY, _(u"Documentation")) self.Bind(wx.EVT_MENU, frame.onManual, item) item=self.menu.Append(wx.ID_ANY, _(u"Check for updates")) self.Bind(wx.EVT_MENU, frame.onCheckForUpdates, item) item=self.menu.Append(wx.ID_ANY, _(u"Exit")) self.Bind(wx.EVT_MENU, frame.close, item) self.Bind(wx.EVT_TASKBAR_RIGHT_DOWN, self.onRightClick) self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.onLeftClick)
# -*- coding: utf-8 -*- import application import platform import exceptions from ctypes import c_char_p from libloader import load_library import paths if platform.architecture()[0][:2] == "32": lib = load_library("api_keys32", x86_path=paths.app_path("keys/lib")) else: lib = load_library("api_keys64", x64_path=paths.app_path("keys/lib")) # import linuxKeys # lib = linuxKeys keyring = None def setup(): global keyring if keyring == None: keyring = Keyring() class Keyring(object): def __init__(self): super(Keyring, self).__init__() def _call_method(self, function): result = getattr(lib, function) result = c_char_p(result.__call__()) return result.value def get(self, func):
def recode_audio(self, filename, quality=4.5): subprocess.call(r'"%s" -q %r "%s"' % (paths.app_path('oggenc2.exe'), quality, filename))
def patched_where(): return paths.app_path(u"cacert.pem")
def fix(): log.debug("Applying fix for requests...") os.environ["REQUESTS_CA_BUNDLE"] = os.path.join(paths.app_path(), "cacert.pem") log.debug("Changed CA path to %s" % (os.environ["REQUESTS_CA_BUNDLE"], ))
def fix(): log.debug("Applying fix for requests...") os.environ["REQUESTS_CA_BUNDLE"] = os.path.join(paths.app_path(), "cacerts.txt") log.debug("Changed CA path to %s" % (os.environ["REQUESTS_CA_BUNDLE"],))
def setup (): global app log.debug("Loading global app settings...") app = config_utils.load_config(paths.config_path(MAINFILE), paths.app_path(MAINSPEC))
# -*- coding: utf-8 -*- import application import platform import exceptions from ctypes import c_char_p from libloader import load_library import paths if platform.architecture()[0][:2] == "32": lib = load_library("api_keys32", x86_path=paths.app_path("keys/lib")) else: lib = load_library("api_keys64", x64_path=paths.app_path("keys/lib")) # import linuxKeys # lib = linuxKeys keyring = None def setup(): global keyring if keyring == None: keyring = Keyring() class Keyring(object): def __init__(self): super(Keyring, self).__init__() def _call_method(self, function): result = getattr(lib, function) result = c_char_p(result.__call__()) return result.value
def recode_audio(filename, quality=4.5): global system if system == "Windows": subprocess.call(r'"%s" -q %r "%s"' % (paths.app_path('oggenc2.exe'), quality, filename))
def get(): return os.path.join(paths.app_path(), "cacerts.txt")
def setup (): global app log.debug("Loading global app settings...") app = config_utils.load_config(os.path.join(storage.data_directory, MAINFILE), os.path.join(paths.app_path(), MAINSPEC))
system = platform.system() if system == "Windows": 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 paths # check if TWBlue is installed (Windows only) if os.path.exists(paths.app_path(u"Uninstall.exe")): paths.mode = "installed" import commandline import config import sound import output import logging import application import keys from mysc.thread_utils import call_threaded import fixes # extra variables to control the temporary 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. import widgetUtils import webbrowser from wxUI import commonMessageDialogs
def fix(): log.debug("Applying fix for requests...") os.environ["REQUESTS_CA_BUNDLE"] = paths.app_path("cacert.pem") log.debug("Changed CA path to %s" % (paths.app_path("cacert.pem"),))
def setup(): global app log.debug("Loading global app settings...") app = config_utils.load_config( os.path.join(storage.data_directory, MAINFILE), os.path.join(paths.app_path(), MAINSPEC))