当前位置: 首页>>代码示例>>Python>>正文


Python AppLocation.get_directory方法代码示例

本文整理汇总了Python中openlp.core.utils.AppLocation.get_directory方法的典型用法代码示例。如果您正苦于以下问题:Python AppLocation.get_directory方法的具体用法?Python AppLocation.get_directory怎么用?Python AppLocation.get_directory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openlp.core.utils.AppLocation的用法示例。


在下文中一共展示了AppLocation.get_directory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_qm_files

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def find_qm_files():
     """
     Find all available language files in this OpenLP install
     """
     log.debug('Translation files: %s', AppLocation.get_directory(
         AppLocation.LanguageDir))
     trans_dir = QtCore.QDir(AppLocation.get_directory(AppLocation.LanguageDir))
     file_names = trans_dir.entryList('*.qm', QtCore.QDir.Files, QtCore.QDir.Name)
     # Remove qm files from the list which start with "qt_".
     file_names = [file_ for file_ in file_names if not file_.startswith('qt_')]
     return list(map(trans_dir.filePath, file_names))
开发者ID:marmyshev,项目名称:bug_1117098,代码行数:13,代码来源:languagemanager.py

示例2: define_config

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def define_config(self):
     """
     Define the configuration of the server.
     """
     if Settings().value(self.settings_section + '/https enabled'):
         port = Settings().value(self.settings_section + '/https port')
         address = Settings().value(self.settings_section + '/ip address')
         local_data = AppLocation.get_directory(AppLocation.DataDir)
         cherrypy.config.update({'server.socket_host': str(address),
                                 'server.socket_port': port,
                                 'server.ssl_certificate': os.path.join(local_data, 'remotes', 'openlp.crt'),
                                 'server.ssl_private_key': os.path.join(local_data, 'remotes', 'openlp.key')})
     else:
         port = Settings().value(self.settings_section + '/port')
         address = Settings().value(self.settings_section + '/ip address')
         cherrypy.config.update({'server.socket_host': str(address)})
         cherrypy.config.update({'server.socket_port': port})
     cherrypy.config.update({'environment': 'embedded'})
     cherrypy.config.update({'engine.autoreload_on': False})
     directory_config = {'/': {'tools.staticdir.on': True,
                             'tools.staticdir.dir': self.router.html_dir,
                             'tools.basic_auth.on': Settings().value('remotes/authentication enabled'),
                             'tools.basic_auth.realm': 'OpenLP Remote Login',
                             'tools.basic_auth.users': fetch_password,
                             'tools.basic_auth.encrypt': make_sha_hash},
                      '/files': {'tools.staticdir.on': True,
                                  'tools.staticdir.dir': self.router.html_dir,
                                  'tools.basic_auth.on': False},
                      '/stage': {'tools.staticdir.on': True,
                                  'tools.staticdir.dir': self.router.html_dir,
                                  'tools.basic_auth.on': False},
                      '/main': {'tools.staticdir.on': True,
                                  'tools.staticdir.dir': self.router.html_dir,
                                  'tools.basic_auth.on': False}}
     return directory_config
开发者ID:marmyshev,项目名称:bug_1117098,代码行数:37,代码来源:httpserver.py

示例3: check_available_media_players

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def check_available_media_players(self):
     """
     Check to see if we have any media Player's available.
     """
     log.debug('_check_available_media_players')
     controller_dir = os.path.join(AppLocation.get_directory(AppLocation.AppDir), 'core', 'ui', 'media')
     for filename in os.listdir(controller_dir):
         if filename.endswith('player.py') and not filename == 'mediaplayer.py':
             path = os.path.join(controller_dir, filename)
             if os.path.isfile(path):
                 modulename = 'openlp.core.ui.media.' + os.path.splitext(filename)[0]
                 log.debug('Importing controller %s', modulename)
                 try:
                     __import__(modulename, globals(), locals(), [])
                 # On some platforms importing vlc.py might cause
                 # also OSError exceptions. (e.g. Mac OS X)
                 except (ImportError, OSError):
                     log.warn('Failed to import %s on path %s', modulename, path)
     player_classes = MediaPlayer.__subclasses__()
     for player_class in player_classes:
         player = player_class(self)
         self.register_players(player)
     if not self.media_players:
         return False
     savedPlayers, overriddenPlayer = get_media_players()
     invalid_media_players = [mediaPlayer for mediaPlayer in savedPlayers
         if not mediaPlayer in self.media_players or not self.media_players[mediaPlayer].check_available()]
     if invalid_media_players:
         for invalidPlayer in invalid_media_players:
             savedPlayers.remove(invalidPlayer)
         set_media_players(savedPlayers, overriddenPlayer)
     self._set_active_players()
     self._generate_extensions_lists()
     return True
开发者ID:marmyshev,项目名称:bug_1117098,代码行数:36,代码来源:mediacontroller.py

示例4: __init__

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def __init__(self, parent, **kwargs):
     log.debug(self.__class__.__name__)
     BibleDB.__init__(self, parent, **kwargs)
     self.filename = kwargs[u'filename']
     self.language_regex = re.compile(r'<language.*>(.*?)</language>')
     self.verse_regex = re.compile(
         r'<verse osisID="([a-zA-Z0-9 ]*).([0-9]*).([0-9]*)">(.*?)</verse>')
     self.note_regex = re.compile(r'<note(.*?)>(.*?)</note>')
     self.title_regex = re.compile(r'<title(.*?)>(.*?)</title>')
     self.milestone_regex = re.compile(r'<milestone(.*?)/>')
     self.fi_regex = re.compile(r'<FI>(.*?)<Fi>')
     self.rf_regex = re.compile(r'<RF>(.*?)<Rf>')
     self.lb_regex = re.compile(r'<lb(.*?)>')
     self.lg_regex = re.compile(r'<lg(.*?)>')
     self.l_regex = re.compile(r'<l (.*?)>')
     self.w_regex = re.compile(r'<w (.*?)>')
     self.q_regex = re.compile(r'<q(.*?)>')
     self.q1_regex = re.compile(r'<q(.*?)level="1"(.*?)>')
     self.q2_regex = re.compile(r'<q(.*?)level="2"(.*?)>')
     self.trans_regex = re.compile(r'<transChange(.*?)>(.*?)</transChange>')
     self.divine_name_regex = re.compile(
         r'<divineName(.*?)>(.*?)</divineName>')
     self.spaces_regex = re.compile(r'([ ]{2,})')
     filepath = os.path.join(
         AppLocation.get_directory(AppLocation.PluginsDir), u'bibles', u'resources', u'osisbooks.csv')
开发者ID:marmyshev,项目名称:transitions,代码行数:27,代码来源:osis.py

示例5: __init__

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def __init__(self):
     """
     Initialise the router
     """
     self.routes = [
         ('^/$', self.serve_file),
         ('^/(stage)$', self.serve_file),
         ('^/(main)$', self.serve_file),
         (r'^/files/(.*)$', self.serve_file),
         (r'^/api/poll$', self.poll),
         (r'^/stage/poll$', self.poll),
         (r'^/main/poll$', self.main_poll),
         (r'^/main/image$', self.main_image),
         (r'^/api/controller/(live|preview)/(.*)$', self.controller),
         (r'^/stage/controller/(live|preview)/(.*)$', self.controller),
         (r'^/api/service/(.*)$', self.service),
         (r'^/stage/service/(.*)$', self.service),
         (r'^/api/display/(hide|show|blank|theme|desktop)$', self.display),
         (r'^/api/alert$', self.alert),
         (r'^/api/plugin/(search)$', self.plugin_info),
         (r'^/api/(.*)/search$', self.search),
         (r'^/api/(.*)/live$', self.go_live),
         (r'^/api/(.*)/add$', self.add_to_service)
     ]
     self.translate()
     self.html_dir = os.path.join(AppLocation.get_directory(AppLocation.PluginsDir), 'remotes', 'html')
开发者ID:marmyshev,项目名称:bug_1117098,代码行数:28,代码来源:httpserver.py

示例6: checkPreConditions

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def checkPreConditions(self):
     """
     Check to see if we have any presentation software available
     If Not do not install the plugin.
     """
     log.debug(u'checkPreConditions')
     controller_dir = os.path.join(
         AppLocation.get_directory(AppLocation.PluginsDir),
         u'presentations', u'lib')
     for filename in os.listdir(controller_dir):
         if filename.endswith(u'controller.py') and not filename == 'presentationcontroller.py':
             path = os.path.join(controller_dir, filename)
             if os.path.isfile(path):
                 modulename = u'openlp.plugins.presentations.lib.' + os.path.splitext(filename)[0]
                 log.debug(u'Importing controller %s', modulename)
                 try:
                     __import__(modulename, globals(), locals(), [])
                 except ImportError:
                     log.warn(u'Failed to import %s on path %s',
                         modulename, path)
     controller_classes = PresentationController.__subclasses__()
     for controller_class in controller_classes:
         controller = controller_class(self)
         self.registerControllers(controller)
     return bool(self.controllers)
开发者ID:marmyshev,项目名称:transitions,代码行数:27,代码来源:presentationplugin.py

示例7: check_installed

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
    def check_installed(self):
        """
        Check the viewer is installed.

        :return: True if program to open PDF-files was found, otherwise False.
        """
        log.debug('check_installed Pdf')
        self.mudrawbin = ''
        self.gsbin = ''
        self.also_supports = []
        # Use the user defined program if given
        if Settings().value('presentations/enable_pdf_program'):
            pdf_program = Settings().value('presentations/pdf_program')
            program_type = self.check_binary(pdf_program)
            if program_type == 'gs':
                self.gsbin = pdf_program
            elif program_type == 'mudraw':
                self.mudrawbin = pdf_program
        else:
            # Fallback to autodetection
            application_path = AppLocation.get_directory(AppLocation.AppDir)
            if is_win():
                # for windows we only accept mudraw.exe in the base folder
                application_path = AppLocation.get_directory(AppLocation.AppDir)
                if os.path.isfile(os.path.join(application_path, 'mudraw.exe')):
                    self.mudrawbin = os.path.join(application_path, 'mudraw.exe')
            else:
                DEVNULL = open(os.devnull, 'wb')
                # First try to find mupdf
                self.mudrawbin = which('mudraw')
                # if mupdf isn't installed, fallback to ghostscript
                if not self.mudrawbin:
                    self.gsbin = which('gs')
                # Last option: check if mudraw is placed in OpenLP base folder
                if not self.mudrawbin and not self.gsbin:
                    application_path = AppLocation.get_directory(AppLocation.AppDir)
                    if os.path.isfile(os.path.join(application_path, 'mudraw')):
                        self.mudrawbin = os.path.join(application_path, 'mudraw')
        if self.mudrawbin:
            self.also_supports = ['xps', 'oxps']
            return True
        elif self.gsbin:
            return True
        else:
            return False
开发者ID:crossroadchurch,项目名称:paul,代码行数:47,代码来源:pdfcontroller.py

示例8: get_cursor

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def get_cursor():
     """
     Return the cursor object. Instantiate one if it doesn't exist yet.
     """
     if BiblesResourcesDB.cursor is None:
         filepath = os.path.join(AppLocation.get_directory(AppLocation.PluginsDir),
             u'bibles', u'resources', u'bibles_resources.sqlite')
         conn = sqlite3.connect(filepath)
         BiblesResourcesDB.cursor = conn.cursor()
     return BiblesResourcesDB.cursor
开发者ID:marmyshev,项目名称:transitions,代码行数:12,代码来源:db.py

示例9: get_directory_for_app_dir_test

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def get_directory_for_app_dir_test(self):
     """
     Test the AppLocation.get_directory() method for AppLocation.AppDir
     """
     with patch(u'openlp.core.utils._get_frozen_path') as mocked_get_frozen_path:
         mocked_get_frozen_path.return_value = u'app/dir'
         # WHEN: We call AppLocation.get_directory
         directory = AppLocation.get_directory(AppLocation.AppDir)
         # THEN:
         assert directory == u'app/dir', u'Directory should be "app/dir"'
开发者ID:marmyshev,项目名称:transitions,代码行数:12,代码来源:test_applocation.py

示例10: __init__

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def __init__(self, plugin):
     """
     Initialise the httpserver, and start the server.
     """
     log.debug(u'Initialise httpserver')
     self.plugin = plugin
     self.html_dir = os.path.join(AppLocation.get_directory(AppLocation.PluginsDir), u'remotes', u'html')
     self.connections = []
     self.current_item = None
     self.current_slide = None
     self.start_tcp()
开发者ID:marmyshev,项目名称:transitions,代码行数:13,代码来源:httpserver.py

示例11: start_process

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def start_process(self):
     """
     Loads the PPTVIEWLIB library.
     """
     if self.process:
         return
     log.debug('start PPTView')
     dll_path = os.path.join(AppLocation.get_directory(AppLocation.AppDir),
                             'plugins', 'presentations', 'lib', 'pptviewlib', 'pptviewlib.dll')
     self.process = cdll.LoadLibrary(dll_path)
     if log.isEnabledFor(logging.DEBUG):
         self.process.SetDebug(1)
开发者ID:crossroadchurch,项目名称:paul,代码行数:14,代码来源:pptviewcontroller.py

示例12: __init__

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def __init__(self):
     """
     The constructor for the plugin manager. Passes the controllers on to
     the plugins for them to interact with via their ServiceItems.
     """
     log.info('Plugin manager Initialising')
     Registry().register('plugin_manager', self)
     Registry().register_function('bootstrap_initialise', self.bootstrap_initialise)
     self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir))
     log.debug('Base path %s ', self.base_path)
     self.plugins = []
     log.info('Plugin manager Initialised')
开发者ID:marmyshev,项目名称:bug_1117098,代码行数:14,代码来源:pluginmanager.py

示例13: get_directory_for_plugins_dir_test

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
 def get_directory_for_plugins_dir_test(self):
     """
     Test the AppLocation.get_directory() method for AppLocation.PluginsDir
     """
     with patch(u'openlp.core.utils._get_frozen_path') as mocked_get_frozen_path, \
          patch(u'openlp.core.utils.os.path.abspath') as mocked_abspath, \
          patch(u'openlp.core.utils.os.path.split') as mocked_split, \
          patch(u'openlp.core.utils.sys') as mocked_sys:
         mocked_abspath.return_value = u'plugins/dir'
         mocked_split.return_value = [u'openlp']
         mocked_get_frozen_path.return_value = u'plugins/dir'
         mocked_sys.frozen = 1
         mocked_sys.argv = ['openlp']
         # WHEN: We call AppLocation.get_directory
         directory = AppLocation.get_directory(AppLocation.PluginsDir)
         # THEN:
         assert directory == u'plugins/dir', u'Directory should be "plugins/dir"'
开发者ID:marmyshev,项目名称:transitions,代码行数:19,代码来源:test_applocation.py

示例14: get_translator

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
    def get_translator(language):
        """
        Set up a translator to use in this instance of OpenLP

        ``language``
            The language to load into the translator
        """
        if LanguageManager.auto_language:
            language = QtCore.QLocale.system().name()
        lang_path = AppLocation.get_directory(AppLocation.LanguageDir)
        app_translator = QtCore.QTranslator()
        app_translator.load(language, lang_path)
        # A translator for buttons and other default strings provided by Qt.
        if sys.platform != 'win32' and sys.platform != 'darwin':
            lang_path = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)
        default_translator = QtCore.QTranslator()
        default_translator.load('qt_%s' % language, lang_path)
        return app_translator, default_translator
开发者ID:marmyshev,项目名称:bug_1117098,代码行数:20,代码来源:languagemanager.py

示例15: gs_get_resolution

# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_directory [as 别名]
    def gs_get_resolution(self, size):
        """
        Only used when using ghostscript
        Ghostscript can't scale automatically while keeping aspect like mupdf, so we need
        to get the ratio between the screen size and the PDF to scale

        :param size: Size struct containing the screen size.
        :return: The resolution dpi to be used.
        """
        # Use a postscript script to get size of the pdf. It is assumed that all pages have same size
        gs_resolution_script = AppLocation.get_directory(
            AppLocation.PluginsDir) + '/presentations/lib/ghostscript_get_resolution.ps'
        # Run the script on the pdf to get the size
        runlog = []
        try:
            runlog = check_output([self.controller.gsbin, '-dNOPAUSE', '-dNODISPLAY', '-dBATCH',
                                   '-sFile=' + self.file_path, gs_resolution_script],
                                  startupinfo=self.startupinfo)
        except CalledProcessError as e:
            log.debug(' '.join(e.cmd))
            log.debug(e.output)
        # Extract the pdf resolution from output, the format is " Size: x: <width>, y: <height>"
        width = 0.0
        height = 0.0
        for line in runlog.splitlines():
            try:
                width = float(re.search('.*Size: x: (\d+\.?\d*), y: \d+.*', line.decode()).group(1))
                height = float(re.search('.*Size: x: \d+\.?\d*, y: (\d+\.?\d*).*', line.decode()).group(1))
                break
            except AttributeError:
                continue
        # Calculate the ratio from pdf to screen
        if width > 0 and height > 0:
            width_ratio = size.width() / width
            height_ratio = size.height() / height
            # return the resolution that should be used. 72 is default.
            if width_ratio > height_ratio:
                return int(height_ratio * 72)
            else:
                return int(width_ratio * 72)
        else:
            return 72
开发者ID:crossroadchurch,项目名称:paul,代码行数:44,代码来源:pdfcontroller.py


注:本文中的openlp.core.utils.AppLocation.get_directory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。