Beispiel #1
0
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)
Beispiel #2
0
def play(sound):
    global sources, _volume
    try:
        f = unicode(os.path.join(paths.app_path(), sound), "utf-8")
    except:
        f = os.path.join(paths.app_path(), sound)
    src = sound_lib.stream.FileStream(file=f)
    src.volume = int(_volume) / 100.0
    src.play()
    sources.append(src)
    for src in sources[:]:
        if not src.is_playing:
            sources.remove(src)
Beispiel #3
0
def getDocFilePath(fileName, localized=True):
    import config
    if not getDocFilePath.rootPath:
        if hasattr(sys, "frozen"):
            getDocFilePath.rootPath = appLocation(u"help")
        else:
            getDocFilePath.rootPath = os.path.abspath(
                os.path.join("..", u"help"))
    if localized:
        lang = config.conf["general"]["language"]
        tryLangs = [lang]
        if "_" in lang:
            tryLangs.append(lang.split("_")[0])
        tryLangs.append("en")
        fileName, fileExt = os.path.splitext(fileName)
        for tryLang in tryLangs:
            tryDir = os.path.join(getDocFilePath.rootPath, tryLang)
            if not os.path.isdir(tryDir):
                continue
            for tryExt in ("html", "txt"):
                tryPath = os.path.join(tryDir, "%s.%s" % (fileName, tryExt))
                if os.path.isfile(tryPath):
                    return tryPath
    else:
        if not hasattr(sys, "frozen") and fileName in ("license.txt",
                                                       "contributors.txt"):
            return os.path.join(paths.app_path(), "..", fileName)
        else:
            return os.path.join(getDocFilePath.rootPath, "..", fileName)
Beispiel #4
0
def check_for_update():
    if not paths.is_frozen():
        return
    url = updater.find_update_url(application.update_url, application.version)
    if url is None:
        return
    new_path = os.path.join(paths.app_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.debug("User denied the update request!")
    logging.debug("User requested %s update.  Initialising update process." %
                  application.name)
    app_updater.start_update()
def getDocFilePath(fileName, localized=True):
	import config
	if not getDocFilePath.rootPath:
		if hasattr(sys, "frozen"):
			getDocFilePath.rootPath = appLocation(u"help")
		else:
			getDocFilePath.rootPath = os.path.abspath(os.path.join("..", u"help"))
	if localized:
		lang=config.conf["general"]["language"]
		tryLangs = [lang]
		if "_" in lang:
			tryLangs.append(lang.split("_")[0])
		tryLangs.append("en")
		fileName, fileExt = os.path.splitext(fileName)
		for tryLang in tryLangs:
			tryDir = os.path.join(getDocFilePath.rootPath, tryLang)
			if not os.path.isdir(tryDir):
				continue
			for tryExt in ("html", "txt"):
				tryPath = os.path.join(tryDir, "%s.%s" % (fileName, tryExt))
				if os.path.isfile(tryPath):
					return tryPath
	else:
		if not hasattr(sys, "frozen") and fileName in ("license.txt", "contributors.txt"):
			return os.path.join(paths.app_path(), "..", fileName)
		else:
			return os.path.join(getDocFilePath.rootPath, "..", fileName)
def dataFilesLocation():
	dataPathExists=os.path.exists(paths.app_data_path(versionInfo.name))
	if globalVars.installed:
		paths.prepare_app_data_path(versionInfo.name)
	if not globalVars.installed and dataPathExists or globalVars.installed and dataPathExists:
		return paths.app_data_path(versionInfo.name)
	else:
		return paths.app_path()
Beispiel #7
0
def dataFilesLocation():
    dataPathExists = os.path.exists(paths.app_data_path(versionInfo.name))
    if globalVars.installed:
        paths.prepare_app_data_path(versionInfo.name)
    if not globalVars.installed and dataPathExists or globalVars.installed and dataPathExists:
        return paths.app_data_path(versionInfo.name)
    else:
        return paths.app_path()
Beispiel #8
0
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")
Beispiel #9
0
def is_installed(app_subkey):
 """Checks if the currently running copy is installed or portable variant. Requires the name of the application subkey found under the uninstall section in Windows registry."""

 try:
  key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s" % app_subkey)
  inst_dir = _winreg.QueryValueEx(key,"InstallLocation")[0]
 except WindowsError:
  return False
 _winreg.CloseKey(key)
 try:
  return os.stat(inst_dir) == os.stat(paths.app_path())
 except WindowsError:
  return False
Beispiel #10
0
def check_for_update():
 if not paths.is_frozen():
  return
 url = updater.find_update_url(application.update_url, application.version)
 if url is None:
  return
 new_path = os.path.join(paths.app_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.debug("User denied the update request!")
 logging.debug("User requested %s update.  Initialising update process." % application.name)
 app_updater.start_update()
Beispiel #11
0
def appLocation():
	return paths.app_path()
Beispiel #12
0
def appLocation():
    return paths.app_path()
Beispiel #13
0
import sys
import winsound
import winpaths
from subprocess import list2cmdline
from functools import lru_cache
from pathlib import Path
from bookworm import app
from platform_utils.paths import app_path
from . import shellapi
from .win_registry import RegKey, Registry

PLAYER_FLAGS = winsound.SND_ASYNC | winsound.SND_FILENAME
UWP_SERVICES_AVAILABEL = False
try:
    _app_path = Path(app_path())
    _uwp_services_dll = _app_path / "BookwormUWPServices.dll"
    if not app.is_frozen:
        _uwp_services_dll = (Path.cwd() / "includes" / "BookwormUWPServices" /
                             "bin" / "Debug" / "BookwormUWPServices.dll")
    clr.AddReference(str(_uwp_services_dll))
    UWP_SERVICES_AVAILABEL = True
    del _uwp_services_dll
except Exception as e:
    if "--debug" in sys.argv:
        print(f"Failed to load BookwormUWPServices.dll. {e}")


class SoundFile:
    """Represent a sound file."""
Beispiel #14
0
def app_path():
    if CURRENT_PACKAGING_MODE in (PackagingMode.Installed,
                                  PackagingMode.Portable):
        return Path(path_finder.app_path())
    else:
        return Path(bookworm.__path__[0])
Beispiel #15
0
def app_path():
    return Path(paths_.app_path())
Beispiel #16
0
def app_path():
 return paths_.app_path()
Beispiel #17
0
#######################################################################
import sys
import os
import output
import fixes
import i18n
from platform_utils import paths

i18n.setup()
fixes.setup()
output.setup()

bootoptions = {
    "ui": "wx",
    "datadir": "",
    "moduledir": [os.path.join(paths.app_path(), "modules")],
    "readfile": [],
    "snoopdefault": 1
}

if len(sys.argv) >= 2:
    bootoptions["readfile"] = [sys.argv[1]]

if __name__ == '__main__':
    import application
    import lyntin.engine
    lyntin.engine.main(bootoptions)

# Local variables:
# mode:python
# py-indent-offset:2