diff --git a/openlp/core/api/endpoint/controller.py b/openlp/core/api/endpoint/controller.py index 9aa44cfff..85e9623f9 100644 --- a/openlp/core/api/endpoint/controller.py +++ b/openlp/core/api/endpoint/controller.py @@ -64,7 +64,7 @@ def controller_text(request): elif current_item.is_image() and not frame.get('image', '') and Settings().value('api/thumbnails'): item['tag'] = str(index + 1) thumbnail_path = os.path.join('images', 'thumbnails', frame['title']) - full_thumbnail_path = os.path.join(AppLocation.get_data_path(), thumbnail_path) + full_thumbnail_path = str(AppLocation.get_data_path() / thumbnail_path) # Create thumbnail if it doesn't exists if not os.path.exists(full_thumbnail_path): create_thumb(current_item.get_frame_path(index), full_thumbnail_path, False) @@ -82,7 +82,7 @@ def controller_text(request): if current_item.is_capable(ItemCapabilities.HasThumbnails) and \ Settings().value('api/thumbnails'): # If the file is under our app directory tree send the portion after the match - data_path = AppLocation.get_data_path() + data_path = str(AppLocation.get_data_path()) if frame['image'][0:len(data_path)] == data_path: item['img'] = urllib.request.pathname2url(frame['image'][len(data_path):]) Registry().get('image_manager').add_image(frame['image'], frame['title'], None, 88, 88) diff --git a/openlp/core/api/endpoint/pluginhelpers.py b/openlp/core/api/endpoint/pluginhelpers.py index cf3fac5ec..d2955ef61 100644 --- a/openlp/core/api/endpoint/pluginhelpers.py +++ b/openlp/core/api/endpoint/pluginhelpers.py @@ -125,12 +125,9 @@ def display_thumbnails(request, controller_name, log, dimensions, file_name, sli file_name = urllib.parse.unquote(file_name) if '..' not in file_name: # no hacking please if slide: - full_path = os.path.normpath(os.path.join(AppLocation.get_section_data_path(controller_name), - 'thumbnails', file_name, slide)) + full_path = str(AppLocation.get_section_data_path(controller_name) / 'thumbnails' / file_name / slide) else: - full_path = os.path.normpath(os.path.join(AppLocation.get_section_data_path(controller_name), - - 'thumbnails', file_name)) + full_path = str(AppLocation.get_section_data_path(controller_name) / 'thumbnails' / file_name) if os.path.exists(full_path): path, just_file_name = os.path.split(full_path) Registry().get('image_manager').add_image(full_path, just_file_name, None, width, height) diff --git a/openlp/core/api/http/endpoint.py b/openlp/core/api/http/endpoint.py index c20f1cb01..d6a923a50 100644 --- a/openlp/core/api/http/endpoint.py +++ b/openlp/core/api/http/endpoint.py @@ -68,11 +68,10 @@ class Endpoint(object): """ Render a mako template """ - root = os.path.join(str(AppLocation.get_section_data_path('remotes'))) + root = str(AppLocation.get_section_data_path('remotes')) if not self.template_dir: raise Exception('No template directory specified') path = os.path.join(root, self.template_dir, filename) - # path = os.path.abspath(os.path.join(self.template_dir, filename)) if self.static_dir: kwargs['static_url'] = '/{prefix}/static'.format(prefix=self.url_prefix) kwargs['static_url'] = kwargs['static_url'].replace('//', '/') diff --git a/openlp/core/api/http/wsgiapp.py b/openlp/core/api/http/wsgiapp.py index c852d5dc4..153344ab5 100644 --- a/openlp/core/api/http/wsgiapp.py +++ b/openlp/core/api/http/wsgiapp.py @@ -138,8 +138,12 @@ class WSGIApplication(object): Add a static directory as a route """ if route not in self.static_routes: - root = os.path.join(str(AppLocation.get_section_data_path('remotes'))) - self.static_routes[route] = DirectoryApp(os.path.abspath(os.path.join(root, static_dir))) + root = str(AppLocation.get_section_data_path('remotes')) + static_path = os.path.abspath(os.path.join(root, static_dir)) + if not os.path.exists(static_path): + log.error('Static path "%s" does not exist. Skipping creating static route/', static_path) + return + self.static_routes[route] = DirectoryApp(static_path) def dispatch(self, request): """ diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index f26446206..1344c66d1 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -59,21 +59,22 @@ class RemotesPlugin(Plugin, OpenLPMixin): Create the internal file structure if it does not exist :return: """ - check_directory_exists(os.path.join(AppLocation.get_section_data_path('remotes'), 'assets')) - check_directory_exists(os.path.join(AppLocation.get_section_data_path('remotes'), 'images')) - check_directory_exists(os.path.join(AppLocation.get_section_data_path('remotes'), 'static')) - check_directory_exists(os.path.join(AppLocation.get_section_data_path('remotes'), 'static', 'index')) - check_directory_exists(os.path.join(AppLocation.get_section_data_path('remotes'), 'templates')) + check_directory_exists(AppLocation.get_section_data_path('remotes') / 'assets') + check_directory_exists(AppLocation.get_section_data_path('remotes') / 'images') + check_directory_exists(AppLocation.get_section_data_path('remotes') / 'static') + check_directory_exists(AppLocation.get_section_data_path('remotes') / 'static', 'index') + check_directory_exists(AppLocation.get_section_data_path('remotes') / 'templates') @staticmethod def about(): """ Information about this plugin """ - about_text = translate('RemotePlugin', 'Web Interface' - '
The web interface plugin provides the ability develop web based ' - 'interfaces using openlp web services. \nPredefined interfaces can be ' - 'download as well as custom developed interfaces') + about_text = translate( + 'RemotePlugin', + 'Web Interface' + '
The web interface plugin provides the ability to develop web based interfaces using OpenLP web ' + 'services.\nPredefined interfaces can be download as well as custom developed interfaces.') return about_text def set_plugin_text_strings(self):