本文整理汇总了Python中openlp.core.common.AppLocation.get_directory方法的典型用法代码示例。如果您正苦于以下问题:Python AppLocation.get_directory方法的具体用法?Python AppLocation.get_directory怎么用?Python AppLocation.get_directory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openlp.core.common.AppLocation
的用法示例。
在下文中一共展示了AppLocation.get_directory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_qm_files
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.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))
示例2: check_installed
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.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.mutoolbin = ''
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.process_check_binary(pdf_program)
if program_type == 'gs':
self.gsbin = pdf_program
elif program_type == 'mudraw':
self.mudrawbin = pdf_program
elif program_type == 'mutool':
self.mutoolbin = pdf_program
else:
# Fallback to autodetection
application_path = AppLocation.get_directory(AppLocation.AppDir)
if is_win():
# for windows we only accept mudraw.exe or mutool.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')
elif os.path.isfile(os.path.join(application_path, 'mutool.exe')):
self.mutoolbin = os.path.join(application_path, 'mutool.exe')
else:
DEVNULL = open(os.devnull, 'wb')
# First try to find mudraw
self.mudrawbin = which('mudraw')
# if mudraw isn't installed, try mutool
if not self.mudrawbin:
self.mutoolbin = which('mutool')
# Check we got a working mutool
if not self.mutoolbin or self.process_check_binary(self.mutoolbin) != 'mutool':
self.gsbin = which('gs')
# Last option: check if mudraw or mutool is placed in OpenLP base folder
if not self.mudrawbin and not self.mutoolbin 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')
elif os.path.isfile(os.path.join(application_path, 'mutool')):
self.mutoolbin = os.path.join(application_path, 'mutool')
if self.mudrawbin or self.mutoolbin:
self.also_supports = ['xps', 'oxps']
return True
elif self.gsbin:
return True
else:
return False
示例3: load
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.AppLocation import get_directory [as 别名]
def load(self):
"""
Load the configuration and update the server configuration if necessary
"""
self.is_secure = Settings().value(self.settings_section + '/https enabled')
self.port_spin_box.setValue(Settings().value(self.settings_section + '/port'))
self.https_port_spin_box.setValue(Settings().value(self.settings_section + '/https port'))
self.address_edit.setText(Settings().value(self.settings_section + '/ip address'))
self.twelve_hour = Settings().value(self.settings_section + '/twelve hour')
self.twelve_hour_check_box.setChecked(self.twelve_hour)
self.thumbnails = Settings().value(self.settings_section + '/thumbnails')
self.thumbnails_check_box.setChecked(self.thumbnails)
local_data = AppLocation.get_directory(AppLocation.DataDir)
if not os.path.exists(os.path.join(local_data, 'remotes', 'openlp.crt')) or \
not os.path.exists(os.path.join(local_data, 'remotes', 'openlp.key')):
self.https_settings_group_box.setChecked(False)
self.https_settings_group_box.setEnabled(False)
self.https_error_label.setVisible(True)
else:
self.https_settings_group_box.setChecked(Settings().value(self.settings_section + '/https enabled'))
self.https_settings_group_box.setEnabled(True)
self.https_error_label.setVisible(False)
self.user_login_group_box.setChecked(Settings().value(self.settings_section + '/authentication enabled'))
self.user_id.setText(Settings().value(self.settings_section + '/user id'))
self.password.setText(Settings().value(self.settings_section + '/password'))
self.set_urls()
self.https_changed()
示例4: bootstrap_initialise
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.AppLocation import get_directory [as 别名]
def bootstrap_initialise(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):
module_name = 'openlp.core.ui.media.' + os.path.splitext(filename)[0]
log.debug('Importing controller %s', module_name)
try:
__import__(module_name, globals(), locals(), [])
# On some platforms importing vlc.py might cause
# also OSError exceptions. (e.g. Mac OS X)
except (ImportError, OSError):
log.warning('Failed to import %s on path %s', module_name, 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
saved_players, overridden_player = get_media_players()
invalid_media_players = \
[media_player for media_player in saved_players if media_player not in self.media_players or
not self.media_players[media_player].check_available()]
if invalid_media_players:
for invalidPlayer in invalid_media_players:
saved_players.remove(invalidPlayer)
set_media_players(saved_players, overridden_player)
self._set_active_players()
self._generate_extensions_lists()
return True
示例5: initialise
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.AppLocation import get_directory [as 别名]
def initialise(self):
"""
Initialise the router stack and any other variables.
"""
auth_code = "%s:%s" % (Settings().value('remotes/user id'), Settings().value('remotes/password'))
try:
self.auth = base64.b64encode(auth_code)
except TypeError:
self.auth = base64.b64encode(auth_code.encode()).decode()
self.routes = [
('^/$', {'function': self.serve_file, 'secure': False}),
('^/(stage)$', {'function': self.serve_file, 'secure': False}),
('^/(main)$', {'function': self.serve_file, 'secure': False}),
('^/(music)$', {'function': self.serve_file, 'secure': False}),
(r'^/files/(.*)$', {'function': self.serve_file, 'secure': False}),
(r'^/(\w+)/thumbnails([^/]+)?/(.*)$', {'function': self.serve_thumbnail, 'secure': False}),
(r'^/api/poll$', {'function': self.poll, 'secure': False}),
(r'^/main/poll$', {'function': self.main_poll, 'secure': False}),
(r'^/main/image$', {'function': self.main_image, 'secure': False}),
(r'^/api/controller/(live|preview)/text$', {'function': self.controller_text, 'secure': False}),
(r'^/api/controller/(live|preview)/(.*)$', {'function': self.controller, 'secure': True}),
(r'^/api/service/list$', {'function': self.service_list, 'secure': False}),
(r'^/api/service/(.*)$', {'function': self.service, 'secure': True}),
(r'^/api/display/(hide|show|blank|theme|desktop)$', {'function': self.display, 'secure': True}),
(r'^/api/alert$', {'function': self.alert, 'secure': True}),
(r'^/api/plugin/(search)$', {'function': self.plugin_info, 'secure': False}),
(r'^/api/(.*)/search$', {'function': self.search, 'secure': False}),
(r'^/api/(.*)/live$', {'function': self.go_live, 'secure': True}),
(r'^/api/(.*)/add$', {'function': self.add_to_service, 'secure': True}),
(r'^/silas/(.*)$', {'function': self.process_chord_view, 'secure': False})
]
self.settings_section = 'remotes'
self.translate()
self.html_dir = os.path.join(AppLocation.get_directory(AppLocation.PluginsDir), 'remotes', 'html')
示例6: on_data_directory_default_button_clicked
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.AppLocation import get_directory [as 别名]
def on_data_directory_default_button_clicked(self):
"""
Re-set the data directory location to the 'default' location.
"""
new_data_path = AppLocation.get_directory(AppLocation.DataDir)
if self.current_data_path.lower() != new_data_path.lower():
# Make sure they want to change the data location back to the
# default.
answer = QtWidgets.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Reset Data Directory'),
translate('OpenLP.AdvancedTab', 'Are you sure you want to change '
'the location of the OpenLP data '
'directory to the default location?'
'\n\nThis location will be used '
'after OpenLP is closed.'),
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes |
QtWidgets.QMessageBox.No),
QtWidgets.QMessageBox.No)
if answer != QtWidgets.QMessageBox.Yes:
return
self.check_data_overwrite(new_data_path)
# Save the new location.
self.main_window.set_new_data_path(new_data_path)
self.new_data_directory_edit.setText(os.path.abspath(new_data_path))
self.data_directory_cancel_button.show()
else:
# We cancel the change in case user changed their mind.
self.on_data_directory_cancel_button_clicked()
示例7: get_cursor
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.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:
file_path = os.path.join(AppLocation.get_directory(AppLocation.PluginsDir),
'bibles', 'resources', 'bibles_resources.sqlite')
conn = sqlite3.connect(file_path)
BiblesResourcesDB.cursor = conn.cursor()
return BiblesResourcesDB.cursor
示例8: __init__
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.AppLocation import get_directory [as 别名]
def __init__(self):
"""
Initialise the theme object.
"""
# basic theme object with defaults
json_dir = os.path.join(AppLocation.get_directory(AppLocation.AppDir), 'core', 'lib', 'json')
json_file = os.path.join(json_dir, 'theme.json')
jsn = get_text_file_string(json_file)
jsn = json.loads(jsn)
self.expand_json(jsn)
示例9: __init__
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.AppLocation import get_directory [as 别名]
def __init__(self, parent=None):
"""
The constructor for the plugin manager. Passes the controllers on to
the plugins for them to interact with via their ServiceItems.
"""
super(PluginManager, self).__init__(parent)
self.log_info('Plugin manager Initialising')
self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir))
self.log_debug('Base path %s ' % self.base_path)
self.plugins = []
self.log_info('Plugin manager Initialised')
示例10: start_process
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.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)
示例11: check_pre_conditions
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.AppLocation import get_directory [as 别名]
def check_pre_conditions(self):
"""
Check it we have a valid environment.
:return: true or false
"""
log.debug('check_installed Mediainfo')
# Try to find mediainfo in the path
exists = process_check_binary('mediainfo')
# If mediainfo is not in the path, try to find it in the application folder
if not exists:
exists = process_check_binary(os.path.join(AppLocation.get_directory(AppLocation.AppDir), 'mediainfo'))
return exists
示例12: get_directory_for_app_dir_test
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.AppLocation import get_directory [as 别名]
def get_directory_for_app_dir_test(self):
"""
Test the AppLocation.get_directory() method for AppLocation.AppDir
"""
# GIVEN: A mocked out _get_frozen_path function
with patch('openlp.core.common.applocation.get_frozen_path') as mocked_get_frozen_path:
mocked_get_frozen_path.return_value = os.path.join('app', 'dir')
# WHEN: We call AppLocation.get_directory
directory = AppLocation.get_directory(AppLocation.AppDir)
# THEN: check that the correct directory is returned
self.assertEqual(os.path.join('app', 'dir'), directory, 'Directory should be "app/dir"')
示例13: __init__
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.AppLocation import get_directory [as 别名]
def __init__(self, address, handler):
"""
Initialise the secure handlers for the SSL server if required.s
"""
BaseServer.__init__(self, address, handler)
local_data = AppLocation.get_directory(AppLocation.DataDir)
self.socket = ssl.SSLSocket(
sock=socket.socket(self.address_family, self.socket_type),
certfile=os.path.join(local_data, 'remotes', 'openlp.crt'),
keyfile=os.path.join(local_data, 'remotes', 'openlp.key'),
server_side=True)
self.server_bind()
self.server_activate()
示例14: get_translator
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.AppLocation import get_directory [as 别名]
def get_translator(language):
"""
Set up a translator to use in this instance of OpenLP
:param 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 not is_win() and not is_macosx():
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
示例15: gs_get_resolution
# 需要导入模块: from openlp.core.common import AppLocation [as 别名]
# 或者: from openlp.core.common.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(r'.*Size: x: (\d+\.?\d*), y: \d+.*', line.decode()).group(1))
height = float(re.search(r'.*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