本文整理汇总了Python中openlp.core.utils.AppLocation.get_section_data_path方法的典型用法代码示例。如果您正苦于以下问题:Python AppLocation.get_section_data_path方法的具体用法?Python AppLocation.get_section_data_path怎么用?Python AppLocation.get_section_data_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openlp.core.utils.AppLocation
的用法示例。
在下文中一共展示了AppLocation.get_section_data_path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def __init__(self, plugin=None, name=u'PresentationController',
document_class=PresentationDocument):
"""
This is the constructor for the presentationcontroller object. This
provides an easy way for descendent plugins to populate common data.
This method *must* be overridden, like so::
class MyPresentationController(PresentationController):
def __init__(self, plugin):
PresentationController.__init(
self, plugin, u'My Presenter App')
``plugin``
Defaults to *None*. The presentationplugin object
``name``
Name of the application, to appear in the application
"""
self.supports = []
self.alsosupports = []
self.docs = []
self.plugin = plugin
self.name = name
self.document_class = document_class
self.settings_section = self.plugin.settingsSection
self.available = None
self.temp_folder = os.path.join(AppLocation.get_section_data_path(self.settings_section), name)
self.thumbnail_folder = os.path.join(AppLocation.get_section_data_path(self.settings_section), u'thumbnails')
self.thumbnail_prefix = u'slide'
check_directory_exists(self.thumbnail_folder)
check_directory_exists(self.temp_folder)
示例2: _performWizard
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def _performWizard(self):
"""
Run the tasks in the wizard.
"""
# Set plugin states
self._incrementProgressBar(translate('OpenLP.FirstTimeWizard', 'Enabling selected plugins...'))
self._setPluginStatus(self.songsCheckBox, u'songs/status')
self._setPluginStatus(self.bibleCheckBox, u'bibles/status')
# TODO Presentation plugin is not yet working on Mac OS X.
# For now just ignore it.
if sys.platform != 'darwin':
self._setPluginStatus(self.presentationCheckBox, u'presentations/status')
self._setPluginStatus(self.imageCheckBox, u'images/status')
self._setPluginStatus(self.mediaCheckBox, u'media/status')
self._setPluginStatus(self.remoteCheckBox, u'remotes/status')
self._setPluginStatus(self.customCheckBox, u'custom/status')
self._setPluginStatus(self.songUsageCheckBox, u'songusage/status')
self._setPluginStatus(self.alertCheckBox, u'alerts/status')
if self.webAccess:
# Build directories for downloads
songs_destination = os.path.join(
unicode(gettempdir(), get_filesystem_encoding()), u'openlp')
bibles_destination = AppLocation.get_section_data_path(u'bibles')
themes_destination = AppLocation.get_section_data_path(u'themes')
# Download songs
for i in xrange(self.songsListWidget.count()):
item = self.songsListWidget.item(i)
if item.checkState() == QtCore.Qt.Checked:
filename = item.data(QtCore.Qt.UserRole)
self._incrementProgressBar(self.downloading % filename, 0)
self.previous_size = 0
destination = os.path.join(songs_destination, unicode(filename))
self.urlGetFile(u'%s%s' % (self.web, filename), destination)
# Download Bibles
bibles_iterator = QtGui.QTreeWidgetItemIterator(
self.biblesTreeWidget)
while bibles_iterator.value():
item = bibles_iterator.value()
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
bible = item.data(0, QtCore.Qt.UserRole)
self._incrementProgressBar(self.downloading % bible, 0)
self.previous_size = 0
self.urlGetFile(u'%s%s' % (self.web, bible), os.path.join(bibles_destination, bible))
bibles_iterator += 1
# Download themes
for i in xrange(self.themesListWidget.count()):
item = self.themesListWidget.item(i)
if item.checkState() == QtCore.Qt.Checked:
theme = item.data(QtCore.Qt.UserRole)
self._incrementProgressBar(self.downloading % theme, 0)
self.previous_size = 0
self.urlGetFile(u'%s%s' % (self.web, theme), os.path.join(themes_destination, theme))
# Set Default Display
if self.displayComboBox.currentIndex() != -1:
Settings().setValue(u'General/monitor', self.displayComboBox.currentIndex())
self.screens.set_current_display(self.displayComboBox.currentIndex())
# Set Global Theme
if self.themeComboBox.currentIndex() != -1:
Settings().setValue(u'themes/global theme', self.themeComboBox.currentText())
示例3: _perform_wizard
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def _perform_wizard(self):
"""
Run the tasks in the wizard.
"""
# Set plugin states
self._increment_progress_bar(translate('OpenLP.FirstTimeWizard', 'Enabling selected plugins...'))
self._set_plugin_status(self.songs_check_box, 'songs/status')
self._set_plugin_status(self.bible_check_box, 'bibles/status')
# TODO Presentation plugin is not yet working on Mac OS X.
# For now just ignore it.
if sys.platform != 'darwin':
self._set_plugin_status(self.presentation_check_box, 'presentations/status')
self._set_plugin_status(self.image_check_box, 'images/status')
self._set_plugin_status(self.media_check_box, 'media/status')
self._set_plugin_status(self.remote_check_box, 'remotes/status')
self._set_plugin_status(self.custom_check_box, 'custom/status')
self._set_plugin_status(self.song_usage_check_box, 'songusage/status')
self._set_plugin_status(self.alert_check_box, 'alerts/status')
if self.web_access:
# Build directories for downloads
songs_destination = os.path.join(gettempdir(), 'openlp')
bibles_destination = AppLocation.get_section_data_path('bibles')
themes_destination = AppLocation.get_section_data_path('themes')
# Download songs
for i in range(self.songs_list_widget.count()):
item = self.songs_list_widget.item(i)
if item.checkState() == QtCore.Qt.Checked:
filename = item.data(QtCore.Qt.UserRole)
self._increment_progress_bar(self.downloading % filename, 0)
self.previous_size = 0
destination = os.path.join(songs_destination, str(filename))
self.url_get_file('%s%s' % (self.web, filename), destination)
# Download Bibles
bibles_iterator = QtGui.QTreeWidgetItemIterator(
self.bibles_tree_widget)
while bibles_iterator.value():
item = bibles_iterator.value()
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
bible = item.data(0, QtCore.Qt.UserRole)
self._increment_progress_bar(self.downloading % bible, 0)
self.previous_size = 0
self.url_get_file('%s%s' % (self.web, bible), os.path.join(bibles_destination, bible))
bibles_iterator += 1
# Download themes
for i in range(self.themes_list_widget.count()):
item = self.themes_list_widget.item(i)
if item.checkState() == QtCore.Qt.Checked:
theme = item.data(QtCore.Qt.UserRole)
self._increment_progress_bar(self.downloading % theme, 0)
self.previous_size = 0
self.url_get_file('%s%s' % (self.web, theme), os.path.join(themes_destination, theme))
# Set Default Display
if self.display_combo_box.currentIndex() != -1:
Settings().setValue('core/monitor', self.display_combo_box.currentIndex())
self.screens.set_current_display(self.display_combo_box.currentIndex())
# Set Global Theme
if self.theme_combo_box.currentIndex() != -1:
Settings().setValue('themes/global theme', self.theme_combo_box.currentText())
示例4: _update_background_audio
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def _update_background_audio(self, song, item):
song.media_files = []
for i, bga in enumerate(item.background_audio):
dest_file = os.path.join(
AppLocation.get_section_data_path(self.plugin.name), 'audio', str(song.id), os.path.split(bga)[1])
check_directory_exists(os.path.split(dest_file)[0])
shutil.copyfile(os.path.join(AppLocation.get_section_data_path('servicemanager'), bga), dest_file)
song.media_files.append(MediaFile.populate(weight=i, file_name=dest_file))
self.plugin.manager.save_object(song, True)
示例5: __init__
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def __init__(self, plugin_name, init_schema, db_file_name=None, upgrade_mod=None):
"""
Runs the initialisation process that includes creating the connection to the database and the tables if they do
not exist.
``plugin_name``
The name to setup paths and settings section names
``init_schema``
The init_schema function for this database
``upgrade_schema``
The upgrade_schema function for this database
``db_file_name``
The file name to use for this database. Defaults to None resulting in the plugin_name being used.
"""
settings = Settings()
settings.beginGroup(plugin_name)
self.db_url = ''
self.is_dirty = False
self.session = None
db_type = settings.value('db type')
if db_type == 'sqlite':
if db_file_name:
self.db_url = 'sqlite:///%s/%s' % (AppLocation.get_section_data_path(plugin_name), db_file_name)
else:
self.db_url = 'sqlite:///%s/%s.sqlite' % (AppLocation.get_section_data_path(plugin_name), plugin_name)
else:
self.db_url = '%s://%s:%[email protected]%s/%s' % (db_type,
urlquote(settings.value('db username')),
urlquote(settings.value('db password')),
urlquote(settings.value('db hostname')),
urlquote(settings.value('db database')))
if db_type == 'mysql':
db_encoding = settings.value('db encoding')
self.db_url += '?charset=%s' % urlquote(db_encoding)
settings.endGroup()
if upgrade_mod:
db_ver, up_ver = upgrade_db(self.db_url, upgrade_mod)
if db_ver > up_ver:
critical_error_message_box(
translate('OpenLP.Manager', 'Database Error'),
translate('OpenLP.Manager', 'The database being loaded was created in a more recent version of '
'OpenLP. The database is version %d, while OpenLP expects version %d. The database will not '
'be loaded.\n\nDatabase: %s') % (db_ver, up_ver, self.db_url)
)
return
try:
self.session = init_schema(self.db_url)
except (SQLAlchemyError, DBAPIError):
log.exception('Error loading database: %s', self.db_url)
critical_error_message_box(
translate('OpenLP.Manager', 'Database Error'),
translate('OpenLP.Manager', 'OpenLP cannot load your database.\n\nDatabase: %s') % self.db_url
)
示例6: delete_database
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def delete_database(plugin_name, db_file_name=None):
"""
Remove a database file from the system.
``plugin_name``
The name of the plugin to remove the database for
``db_file_name``
The database file name. Defaults to None resulting in the plugin_name being used.
"""
db_file_path = None
if db_file_name:
db_file_path = os.path.join(AppLocation.get_section_data_path(plugin_name), db_file_name)
else:
db_file_path = os.path.join(AppLocation.get_section_data_path(plugin_name), plugin_name)
return delete_file(db_file_path)
示例7: initialise
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def initialise(self):
self.list_view.clear()
self.list_view.setIconSize(QtCore.QSize(88, 50))
self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settings_section), 'thumbnails')
check_directory_exists(self.servicePath)
self.load_list(Settings().value(self.settings_section + '/media files'))
self.populateDisplayTypes()
示例8: onDeleteClick
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def onDeleteClick(self):
"""
Remove a song from the list and database
"""
if check_item_selected(self.listView, UiStrings().SelectDelete):
items = self.listView.selectedIndexes()
if QtGui.QMessageBox.question(self,
UiStrings().ConfirmDelete,
translate('SongsPlugin.MediaItem', 'Are you sure you want to delete the %n selected song(s)?', '',
QtCore.QCoreApplication.CodecForTr, len(items)),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
return
self.application.set_busy_cursor()
self.main_window.displayProgressBar(len(items))
for item in items:
item_id = item.data(QtCore.Qt.UserRole)
media_files = self.plugin.manager.get_all_objects(MediaFile, MediaFile.song_id == item_id)
for media_file in media_files:
try:
os.remove(media_file.file_name)
except:
log.exception('Could not remove file: %s', media_file.file_name)
try:
save_path = os.path.join(AppLocation.get_section_data_path(self.plugin.name), 'audio', str(item_id))
if os.path.exists(save_path):
os.rmdir(save_path)
except OSError:
log.exception(u'Could not remove directory: %s', save_path)
self.plugin.manager.delete_object(Song, item_id)
self.main_window.incrementProgressBar()
self.main_window.finishedProgressBar()
self.application.set_normal_cursor()
self.onSearchTextButtonClicked()
示例9: initialise
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def initialise(self):
log.debug('initialise')
self.list_view.clear()
self.list_view.setIconSize(QtCore.QSize(88, 50))
self.list_view.setIndentation(self.list_view.default_indentation)
self.list_view.allow_internal_dnd = True
self.servicePath = os.path.join(AppLocation.get_section_data_path(self.settings_section), 'thumbnails')
check_directory_exists(self.servicePath)
# Load images from the database
self.load_full_list(
self.manager.get_all_objects(ImageFilenames, order_by_ref=ImageFilenames.filename), initial_load=True)
示例10: get_section_data_path_test
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def get_section_data_path_test(self):
"""
Test the AppLocation.get_section_data_path() method
"""
with patch(u'openlp.core.utils.AppLocation.get_data_path') as mocked_get_data_path, \
patch(u'openlp.core.utils.check_directory_exists') as mocked_check_directory_exists:
# GIVEN: A mocked out AppLocation.get_data_path()
mocked_get_data_path.return_value = u'test/dir'
mocked_check_directory_exists.return_value = True
# WHEN: we call AppLocation.get_data_path()
data_path = AppLocation.get_section_data_path(u'section')
# THEN: check that all the correct methods were called, and the result is correct
mocked_check_directory_exists.assert_called_with(u'test/dir/section')
assert data_path == u'test/dir/section', u'Result should be "test/dir/section"'
示例11: copyMediaFile
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def copyMediaFile(self, song_id, filename):
"""
This method copies the media file to the correct location and returns
the new file location.
``filename``
The file to copy.
"""
if not hasattr(self, 'save_path'):
self.save_path = os.path.join(AppLocation.get_section_data_path(self.import_wizard.plugin.name),
'audio', str(song_id))
check_directory_exists(self.save_path)
if not filename.startswith(self.save_path):
oldfile, filename = filename, os.path.join(self.save_path, os.path.split(filename)[1])
shutil.copyfile(oldfile, filename)
return filename
示例12: __init__
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def __init__(self, parent):
"""
Finds all the bibles defined for the system and creates an interface
object for each bible containing connection information. Throws
Exception if no Bibles are found.
Init confirms the bible exists and stores the database path.
"""
log.debug('Bible Initialising')
self.parent = parent
self.settings_section = 'bibles'
self.web = 'Web'
self.db_cache = None
self.path = AppLocation.get_section_data_path(self.settings_section)
self.proxy_name = Settings().value(self.settings_section + '/proxy name')
self.suffix = '.sqlite'
self.import_wizard = None
self.reload_bibles()
self.media = None
示例13: __init__
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def __init__(self, parent, manager, bibleplugin):
"""
Instantiate the wizard, and run any extra setup we need to.
``parent``
The QWidget-derived parent of the wizard.
``manager``
The Bible manager.
``bibleplugin``
The Bible plugin.
"""
self.manager = manager
self.mediaItem = bibleplugin.mediaItem
self.suffix = u'.sqlite'
self.settingsSection = u'bibles'
self.path = AppLocation.get_section_data_path(self.settingsSection)
self.temp_dir = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp')
self.files = self.manager.old_bible_databases
self.success = {}
self.newbibles = {}
OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp')
示例14: delete_song
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def delete_song(song_id, song_plugin):
"""
Deletes a song from the database. Media files associated to the song
are removed prior to the deletion of the song.
``song_id``
The ID of the song to delete.
``song_plugin``
The song plugin instance.
"""
media_files = song_plugin.manager.get_all_objects(MediaFile, MediaFile.song_id == song_id)
for media_file in media_files:
try:
os.remove(media_file.file_name)
except:
log.exception('Could not remove file: %s', media_file.file_name)
try:
save_path = os.path.join(AppLocation.get_section_data_path(song_plugin.name), 'audio', str(song_id))
if os.path.exists(save_path):
os.rmdir(save_path)
except OSError:
log.exception('Could not remove directory: %s', save_path)
song_plugin.manager.delete_object(Song, song_id)
示例15: __init__
# 需要导入模块: from openlp.core.utils import AppLocation [as 别名]
# 或者: from openlp.core.utils.AppLocation import get_section_data_path [as 别名]
def __init__(self, parent, manager, bible_plugin):
"""
Instantiate the wizard, and run any extra setup we need to.
``parent``
The QWidget-derived parent of the wizard.
``manager``
The Bible manager.
``bible_plugin``
The Bible plugin.
"""
self.manager = manager
self.media_item = bible_plugin.media_item
self.suffix = '.sqlite'
self.settings_section = 'bibles'
self.path = AppLocation.get_section_data_path(self.settings_section)
self.temp_dir = os.path.join(gettempdir(), 'openlp')
self.files = self.manager.old_bible_databases
self.success = {}
self.new_bibles = {}
super(BibleUpgradeForm, self).__init__(
parent, bible_plugin, 'bibleUpgradeWizard', ':/wizards/wizard_importbible.bmp')