Merge lp:~trb143/openlp/webfixes into lp:openlp

Proposed by Tim Bentley
Status: Merged
Merged at revision: 2773
Proposed branch: lp:~trb143/openlp/webfixes
Merge into: lp:openlp
Diff against target: 903 lines (+279/-392)
20 files modified
openlp/core/api/deploy.py (+69/-0)
openlp/core/api/endpoint/remote.py (+41/-0)
openlp/core/api/endpoint/service.py (+1/-1)
openlp/core/api/http/server.py (+90/-2)
openlp/core/api/tab.py (+2/-0)
openlp/core/common/settings.py (+1/-0)
openlp/plugins/bibles/endpoint.py (+2/-2)
openlp/plugins/custom/endpoint.py (+2/-2)
openlp/plugins/images/endpoint.py (+2/-2)
openlp/plugins/media/endpoint.py (+2/-2)
openlp/plugins/presentations/endpoint.py (+2/-2)
openlp/plugins/remotes/__init__.py (+0/-21)
openlp/plugins/remotes/deploy.py (+0/-69)
openlp/plugins/remotes/endpoint.py (+0/-46)
openlp/plugins/remotes/remoteplugin.py (+0/-155)
openlp/plugins/songs/endpoint.py (+2/-2)
tests/functional/openlp_core_api/test_deploy.py (+63/-0)
tests/functional/openlp_plugins/remotes/__init__.py (+0/-21)
tests/functional/openlp_plugins/remotes/test_deploy.py (+0/-64)
tests/interfaces/openlp_core_lib/test_pluginmanager.py (+0/-1)
To merge this branch: bzr merge lp:~trb143/openlp/webfixes
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tomas Groth Pending
Review via email: mp+331600@code.launchpad.net

This proposal supersedes a proposal from 2017-09-27.

Description of the change

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) wrote : Posted in a previous version of this proposal

For the webclient download, should we add a folder level for openlp version? I can easily imaging a scenario where one webclient will not work with all active openlp versions.
Where is the code for the webclient stored ATM? I don't see a repo on LP.

review: Needs Information
Revision history for this message
Tim Bentley (trb143) wrote : Posted in a previous version of this proposal

https://code.launchpad.net/~trb143/openlp/remoteweb is how the web has been deployed but this will be changed when the angular code comes.

If we need version then that can be added later but this is the same as we have now.

The update of the web version is optional and can allow for other clients to be developed if required,

Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

> For the webclient download, should we add a folder level for openlp version? I
> can easily imaging a scenario where one webclient will not work with all
> active openlp versions.
> Where is the code for the webclient stored ATM? I don't see a repo on LP.

+1
I take it we're downloading version specific code. There's been numerous times in OpenLP when we've needed to 'upgrade' something thing and had to rely on a guess to which version something is. (I.e. has it got this feature) many of these situations could have been advised if version info was added from the start.

Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

> For the webclient download, should we add a folder level for openlp version? I
> can easily imaging a scenario where one webclient will not work with all
> active openlp versions.
> Where is the code for the webclient stored ATM? I don't see a repo on LP.

+1
I take it we're downloading version specific code. There's been numerous times in OpenLP when we've needed to 'upgrade' something thing and had to rely on a guess to which version something is. (I.e. has it got this feature) many of these situations could have been advised if version info was added from the start.

Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

> For the webclient download, should we add a folder level for openlp version? I
> can easily imaging a scenario where one webclient will not work with all
> active openlp versions.
> Where is the code for the webclient stored ATM? I don't see a repo on LP.

+1
I take it we're downloading version specific code. There's been numerous times in OpenLP when we've needed to 'upgrade' something thing and had to rely on a guess to which version something is. (I.e. has it got this feature) many of these situations could have been advised if version info was added from the start.

Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

Sorry about the triplicate!

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Please rename the dialog, and let's talk about version numbers.

review: Needs Fixing
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'openlp/core/api/deploy.py'
2--- openlp/core/api/deploy.py 1970-01-01 00:00:00 +0000
3+++ openlp/core/api/deploy.py 2017-09-29 19:03:48 +0000
4@@ -0,0 +1,69 @@
5+# -*- coding: utf-8 -*-
6+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
7+
8+###############################################################################
9+# OpenLP - Open Source Lyrics Projection #
10+# --------------------------------------------------------------------------- #
11+# Copyright (c) 2008-2017 OpenLP Developers #
12+# --------------------------------------------------------------------------- #
13+# This program is free software; you can redistribute it and/or modify it #
14+# under the terms of the GNU General Public License as published by the Free #
15+# Software Foundation; version 2 of the License. #
16+# #
17+# This program is distributed in the hope that it will be useful, but WITHOUT #
18+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
19+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
20+# more details. #
21+# #
22+# You should have received a copy of the GNU General Public License along #
23+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
24+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
25+###############################################################################
26+"""
27+Download and "install" the remote web client
28+"""
29+import os
30+from zipfile import ZipFile
31+
32+from openlp.core.common import AppLocation, Registry
33+from openlp.core.common.httputils import url_get_file, get_web_page, get_url_file_size
34+
35+
36+def deploy_zipfile(app_root, zip_name):
37+ """
38+ Process the downloaded zip file and add to the correct directory
39+
40+ :param zip_name: the zip file to be processed
41+ :param app_root: the directory where the zip get expanded to
42+
43+ :return: None
44+ """
45+ zip_file = os.path.join(app_root, zip_name)
46+ web_zip = ZipFile(zip_file)
47+ web_zip.extractall(app_root)
48+
49+
50+def download_sha256():
51+ """
52+ Download the config file to extract the sha256 and version number
53+ """
54+ user_agent = 'OpenLP/' + Registry().get('application').applicationVersion()
55+ try:
56+ web_config = get_web_page('https://get.openlp.org/webclient/download.cfg', headers={'User-Agent': user_agent})
57+ except ConnectionError:
58+ return False
59+ file_bits = web_config.split()
60+ return file_bits[0], file_bits[2]
61+
62+
63+def download_and_check(callback=None):
64+ """
65+ Download the web site and deploy it.
66+ """
67+ sha256, version = download_sha256()
68+ file_size = get_url_file_size('https://get.openlp.org/webclient/site.zip')
69+ callback.setRange(0, file_size)
70+ if url_get_file(callback, 'https://get.openlp.org/webclient/site.zip',
71+ AppLocation.get_section_data_path('remotes') / 'site.zip',
72+ sha256=sha256):
73+ deploy_zipfile(str(AppLocation.get_section_data_path('remotes')), 'site.zip')
74
75=== added file 'openlp/core/api/endpoint/remote.py'
76--- openlp/core/api/endpoint/remote.py 1970-01-01 00:00:00 +0000
77+++ openlp/core/api/endpoint/remote.py 2017-09-29 19:03:48 +0000
78@@ -0,0 +1,41 @@
79+# -*- coding: utf-8 -*-
80+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
81+
82+###############################################################################
83+# OpenLP - Open Source Lyrics Projection #
84+# --------------------------------------------------------------------------- #
85+# Copyright (c) 2008-2017 OpenLP Developers #
86+# --------------------------------------------------------------------------- #
87+# This program is free software; you can redistribute it and/or modify it #
88+# under the terms of the GNU General Public License as published by the Free #
89+# Software Foundation; version 2 of the License. #
90+# #
91+# This program is distributed in the hope that it will be useful, but WITHOUT #
92+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
93+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
94+# more details. #
95+# #
96+# You should have received a copy of the GNU General Public License along #
97+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
98+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
99+###############################################################################
100+import logging
101+
102+from openlp.core.api.http.endpoint import Endpoint
103+from openlp.core.api.endpoint.core import TRANSLATED_STRINGS
104+
105+
106+log = logging.getLogger(__name__)
107+
108+remote_endpoint = Endpoint('remote', template_dir='remotes', static_dir='remotes')
109+
110+
111+@remote_endpoint.route('{view}')
112+def index(request, view):
113+ """
114+ Handles requests for /remotes url
115+
116+ :param request: The http request object.
117+ :param view: The view name to be servered.
118+ """
119+ return remote_endpoint.render_template('{view}.mako'.format(view=view), **TRANSLATED_STRINGS)
120
121=== modified file 'openlp/core/api/endpoint/service.py'
122--- openlp/core/api/endpoint/service.py 2017-03-04 19:17:59 +0000
123+++ openlp/core/api/endpoint/service.py 2017-09-29 19:03:48 +0000
124@@ -23,7 +23,7 @@
125 import json
126
127 from openlp.core.api.http.endpoint import Endpoint
128-from openlp.core.api.http import register_endpoint, requires_auth
129+from openlp.core.api.http import requires_auth
130 from openlp.core.common import Registry
131
132
133
134=== modified file 'openlp/core/api/http/server.py'
135--- openlp/core/api/http/server.py 2017-06-18 05:21:23 +0000
136+++ openlp/core/api/http/server.py 2017-09-29 19:03:48 +0000
137@@ -26,17 +26,24 @@
138 """
139
140 import logging
141+import time
142
143-from PyQt5 import QtCore
144+from PyQt5 import QtCore, QtWidgets
145 from waitress import serve
146
147 from openlp.core.api.http import register_endpoint
148 from openlp.core.api.http import application
149-from openlp.core.common import RegistryMixin, RegistryProperties, OpenLPMixin, Settings, Registry
150+from openlp.core.common import AppLocation, RegistryMixin, RegistryProperties, OpenLPMixin, \
151+ Settings, Registry, UiStrings, check_directory_exists
152+from openlp.core.lib import translate
153+
154+from openlp.core.api.deploy import download_and_check, download_sha256
155 from openlp.core.api.poll import Poller
156 from openlp.core.api.endpoint.controller import controller_endpoint, api_controller_endpoint
157 from openlp.core.api.endpoint.core import chords_endpoint, stage_endpoint, blank_endpoint, main_endpoint
158 from openlp.core.api.endpoint.service import service_endpoint, api_service_endpoint
159+from openlp.core.api.endpoint.remote import remote_endpoint
160+
161
162 log = logging.getLogger(__name__)
163
164@@ -59,6 +66,7 @@
165 """
166 address = Settings().value('api/ip address')
167 port = Settings().value('api/port')
168+ Registry().execute('get_website_version')
169 serve(application, host=address, port=port)
170
171 def stop(self):
172@@ -79,11 +87,15 @@
173 self.worker.moveToThread(self.thread)
174 self.thread.started.connect(self.worker.run)
175 self.thread.start()
176+ Registry().register_function('download_website', self.first_time)
177+ Registry().register_function('get_website_version', self.website_version)
178+ Registry().set_flag('website_version', '0.0')
179
180 def bootstrap_post_set_up(self):
181 """
182 Register the poll return service and start the servers.
183 """
184+ self.initialise()
185 self.poller = Poller()
186 Registry().register('poller', self.poller)
187 application.initialise()
188@@ -95,3 +107,79 @@
189 register_endpoint(main_endpoint)
190 register_endpoint(service_endpoint)
191 register_endpoint(api_service_endpoint)
192+ register_endpoint(remote_endpoint)
193+
194+ @staticmethod
195+ def initialise():
196+ """
197+ Create the internal file structure if it does not exist
198+ :return:
199+ """
200+ check_directory_exists(AppLocation.get_section_data_path('remotes') / 'assets')
201+ check_directory_exists(AppLocation.get_section_data_path('remotes') / 'images')
202+ check_directory_exists(AppLocation.get_section_data_path('remotes') / 'static')
203+ check_directory_exists(AppLocation.get_section_data_path('remotes') / 'static' / 'index')
204+ check_directory_exists(AppLocation.get_section_data_path('remotes') / 'templates')
205+
206+ def first_time(self):
207+ """
208+ Import web site code if active
209+ """
210+ self.application.process_events()
211+ progress = DownloadProgressDialog(self)
212+ progress.forceShow()
213+ self.application.process_events()
214+ time.sleep(1)
215+ download_and_check(progress)
216+ self.application.process_events()
217+ time.sleep(1)
218+ progress.close()
219+ self.application.process_events()
220+ Settings().setValue('remotes/download version', self.version)
221+
222+ def website_version(self):
223+ """
224+ Download and save the website version and sha256
225+ :return: None
226+ """
227+ sha256, self.version = download_sha256()
228+ Registry().set_flag('website_sha256', sha256)
229+ Registry().set_flag('website_version', self.version)
230+
231+
232+class DownloadProgressDialog(QtWidgets.QProgressDialog):
233+ """
234+ Local class to handle download display based and supporting httputils:get_web_page
235+ """
236+ def __init__(self, parent):
237+ super(DownloadProgressDialog, self).__init__(parent.main_window)
238+ self.parent = parent
239+ self.setWindowModality(QtCore.Qt.WindowModal)
240+ self.setWindowTitle(translate('RemotePlugin', 'Importing Website'))
241+ self.setLabelText(UiStrings().StartingImport)
242+ self.setCancelButton(None)
243+ self.setRange(0, 1)
244+ self.setMinimumDuration(0)
245+ self.was_cancelled = False
246+ self.previous_size = 0
247+
248+ def _download_progress(self, count, block_size):
249+ """
250+ Calculate and display the download progress.
251+ """
252+ increment = (count * block_size) - self.previous_size
253+ self._increment_progress_bar(None, increment)
254+ self.previous_size = count * block_size
255+
256+ def _increment_progress_bar(self, status_text, increment=1):
257+ """
258+ Update the wizard progress page.
259+
260+ :param status_text: Current status information to display.
261+ :param increment: The value to increment the progress bar by.
262+ """
263+ if status_text:
264+ self.setText(status_text)
265+ if increment > 0:
266+ self.setValue(self.value() + increment)
267+ self.parent.application.process_events()
268
269=== modified file 'openlp/core/api/tab.py'
270--- openlp/core/api/tab.py 2017-06-17 08:51:01 +0000
271+++ openlp/core/api/tab.py 2017-09-29 19:03:48 +0000
272@@ -222,6 +222,8 @@
273 self.remote_url.setText('<a href="{url}">{url}</a>'.format(url=http_url))
274 http_url_temp = http_url + 'stage'
275 self.stage_url.setText('<a href="{url}">{url}</a>'.format(url=http_url_temp))
276+ http_url_temp = http_url + 'chords'
277+ self.chords_url.setText('<a href="{url}">{url}</a>'.format(url=http_url_temp))
278 http_url_temp = http_url + 'main'
279 self.live_url.setText('<a href="{url}">{url}</a>'.format(url=http_url_temp))
280
281
282=== modified file 'openlp/core/common/settings.py'
283--- openlp/core/common/settings.py 2017-09-28 23:28:18 +0000
284+++ openlp/core/common/settings.py 2017-09-29 19:03:48 +0000
285@@ -178,6 +178,7 @@
286 'images/background color': '#000000',
287 'media/players': 'system,webkit',
288 'media/override player': QtCore.Qt.Unchecked,
289+ 'remotes/download version': '0.0',
290 'players/background color': '#000000',
291 'servicemanager/last directory': None,
292 'servicemanager/last file': None,
293
294=== modified file 'openlp/plugins/bibles/endpoint.py'
295--- openlp/plugins/bibles/endpoint.py 2017-08-13 06:17:47 +0000
296+++ openlp/plugins/bibles/endpoint.py 2017-09-29 19:03:48 +0000
297@@ -62,7 +62,7 @@
298
299 :param request: The http request object.
300 """
301- service(request, 'bibles', log)
302+ return service(request, 'bibles', log)
303
304
305 @api_bibles_endpoint.route('bibles/search')
306@@ -95,6 +95,6 @@
307 :param request: The http request object.
308 """
309 try:
310- search(request, 'bibles', log)
311+ return search(request, 'bibles', log)
312 except NotFound:
313 return {'results': {'items': []}}
314
315=== modified file 'openlp/plugins/custom/endpoint.py'
316--- openlp/plugins/custom/endpoint.py 2017-08-13 06:29:04 +0000
317+++ openlp/plugins/custom/endpoint.py 2017-09-29 19:03:48 +0000
318@@ -62,7 +62,7 @@
319
320 :param request: The http request object.
321 """
322- service(request, 'custom', log)
323+ return service(request, 'custom', log)
324
325
326 @api_custom_endpoint.route('custom/search')
327@@ -95,6 +95,6 @@
328 :param request: The http request object.
329 """
330 try:
331- search(request, 'custom', log)
332+ return search(request, 'custom', log)
333 except NotFound:
334 return {'results': {'items': []}}
335
336=== modified file 'openlp/plugins/images/endpoint.py'
337--- openlp/plugins/images/endpoint.py 2017-08-13 06:17:47 +0000
338+++ openlp/plugins/images/endpoint.py 2017-09-29 19:03:48 +0000
339@@ -75,7 +75,7 @@
340
341 :param request: The http request object.
342 """
343- service(request, 'images', log)
344+ return service(request, 'images', log)
345
346
347 @api_images_endpoint.route('images/search')
348@@ -108,6 +108,6 @@
349 :param request: The http request object.
350 """
351 try:
352- search(request, 'images', log)
353+ return search(request, 'images', log)
354 except NotFound:
355 return {'results': {'items': []}}
356
357=== modified file 'openlp/plugins/media/endpoint.py'
358--- openlp/plugins/media/endpoint.py 2017-08-13 06:17:47 +0000
359+++ openlp/plugins/media/endpoint.py 2017-09-29 19:03:48 +0000
360@@ -62,7 +62,7 @@
361
362 :param request: The http request object.
363 """
364- service(request, 'media', log)
365+ return service(request, 'media', log)
366
367
368 @api_media_endpoint.route('media/search')
369@@ -95,6 +95,6 @@
370 :param request: The http request object.
371 """
372 try:
373- search(request, 'media', log)
374+ return search(request, 'media', log)
375 except NotFound:
376 return {'results': {'items': []}}
377
378=== modified file 'openlp/plugins/presentations/endpoint.py'
379--- openlp/plugins/presentations/endpoint.py 2017-08-13 06:17:47 +0000
380+++ openlp/plugins/presentations/endpoint.py 2017-09-29 19:03:48 +0000
381@@ -76,7 +76,7 @@
382
383 :param request: The http request object.
384 """
385- service(request, 'presentations', log)
386+ return service(request, 'presentations', log)
387
388
389 @api_presentations_endpoint.route('presentations/search')
390@@ -109,6 +109,6 @@
391 :param request: The http request object.
392 """
393 try:
394- search(request, 'presentations', log)
395+ return search(request, 'presentations', log)
396 except NotFound:
397 return {'results': {'items': []}}
398
399=== removed directory 'openlp/plugins/remotes'
400=== removed file 'openlp/plugins/remotes/__init__.py'
401--- openlp/plugins/remotes/__init__.py 2017-03-03 19:27:31 +0000
402+++ openlp/plugins/remotes/__init__.py 1970-01-01 00:00:00 +0000
403@@ -1,21 +0,0 @@
404-# -*- coding: utf-8 -*-
405-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
406-
407-###############################################################################
408-# OpenLP - Open Source Lyrics Projection #
409-# --------------------------------------------------------------------------- #
410-# Copyright (c) 2008-2017 OpenLP Developers #
411-# --------------------------------------------------------------------------- #
412-# This program is free software; you can redistribute it and/or modify it #
413-# under the terms of the GNU General Public License as published by the Free #
414-# Software Foundation; version 2 of the License. #
415-# #
416-# This program is distributed in the hope that it will be useful, but WITHOUT #
417-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
418-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
419-# more details. #
420-# #
421-# You should have received a copy of the GNU General Public License along #
422-# with this program; if not, write to the Free Software Foundation, Inc., 59 #
423-# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
424-###############################################################################
425
426=== removed file 'openlp/plugins/remotes/deploy.py'
427--- openlp/plugins/remotes/deploy.py 2017-09-23 04:04:41 +0000
428+++ openlp/plugins/remotes/deploy.py 1970-01-01 00:00:00 +0000
429@@ -1,69 +0,0 @@
430-# -*- coding: utf-8 -*-
431-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
432-
433-###############################################################################
434-# OpenLP - Open Source Lyrics Projection #
435-# --------------------------------------------------------------------------- #
436-# Copyright (c) 2008-2017 OpenLP Developers #
437-# --------------------------------------------------------------------------- #
438-# This program is free software; you can redistribute it and/or modify it #
439-# under the terms of the GNU General Public License as published by the Free #
440-# Software Foundation; version 2 of the License. #
441-# #
442-# This program is distributed in the hope that it will be useful, but WITHOUT #
443-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
444-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
445-# more details. #
446-# #
447-# You should have received a copy of the GNU General Public License along #
448-# with this program; if not, write to the Free Software Foundation, Inc., 59 #
449-# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
450-###############################################################################
451-"""
452-Download and "install" the remote web client
453-"""
454-import os
455-from zipfile import ZipFile
456-
457-from openlp.core.common import AppLocation, Registry
458-from openlp.core.common.httputils import url_get_file, get_web_page, get_url_file_size
459-
460-
461-def deploy_zipfile(app_root, zip_name):
462- """
463- Process the downloaded zip file and add to the correct directory
464-
465- :param zip_name: the zip file to be processed
466- :param app_root: the directory where the zip get expanded to
467-
468- :return: None
469- """
470- zip_file = os.path.join(app_root, zip_name)
471- web_zip = ZipFile(zip_file)
472- web_zip.extractall(app_root)
473-
474-
475-def download_sha256():
476- """
477- Download the config file to extract the sha256 and version number
478- """
479- user_agent = 'OpenLP/' + Registry().get('application').applicationVersion()
480- try:
481- web_config = get_web_page('https://get.openlp.org/webclient/download.cfg', headers={'User-Agent': user_agent})
482- except ConnectionError:
483- return False
484- file_bits = web_config.split()
485- return file_bits[0], file_bits[2]
486-
487-
488-def download_and_check(callback=None):
489- """
490- Download the web site and deploy it.
491- """
492- sha256, version = download_sha256()
493- file_size = get_url_file_size('https://get.openlp.org/webclient/site.zip')
494- callback.setRange(0, file_size)
495- if url_get_file(callback, '{host}{name}'.format(host='https://get.openlp.org/webclient/', name='site.zip'),
496- AppLocation.get_section_data_path('remotes') / 'site.zip',
497- sha256=sha256):
498- deploy_zipfile(str(AppLocation.get_section_data_path('remotes')), 'site.zip')
499
500=== removed file 'openlp/plugins/remotes/endpoint.py'
501--- openlp/plugins/remotes/endpoint.py 2017-08-13 05:44:10 +0000
502+++ openlp/plugins/remotes/endpoint.py 1970-01-01 00:00:00 +0000
503@@ -1,46 +0,0 @@
504-# -*- coding: utf-8 -*-
505-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
506-
507-###############################################################################
508-# OpenLP - Open Source Lyrics Projection #
509-# --------------------------------------------------------------------------- #
510-# Copyright (c) 2008-2017 OpenLP Developers #
511-# --------------------------------------------------------------------------- #
512-# This program is free software; you can redistribute it and/or modify it #
513-# under the terms of the GNU General Public License as published by the Free #
514-# Software Foundation; version 2 of the License. #
515-# #
516-# This program is distributed in the hope that it will be useful, but WITHOUT #
517-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
518-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
519-# more details. #
520-# #
521-# You should have received a copy of the GNU General Public License along #
522-# with this program; if not, write to the Free Software Foundation, Inc., 59 #
523-# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
524-###############################################################################
525-import logging
526-
527-import os
528-
529-from openlp.core.api.http.endpoint import Endpoint
530-from openlp.core.api.endpoint.core import TRANSLATED_STRINGS
531-from openlp.core.common import AppLocation
532-
533-
534-static_dir = os.path.join(str(AppLocation.get_section_data_path('remotes')))
535-
536-log = logging.getLogger(__name__)
537-
538-remote_endpoint = Endpoint('remote', template_dir=static_dir, static_dir=static_dir)
539-
540-
541-@remote_endpoint.route('{view}')
542-def index(request, view):
543- """
544- Handles requests for /remotes url
545-
546- :param request: The http request object.
547- :param view: The view name to be servered.
548- """
549- return remote_endpoint.render_template('{view}.mako'.format(view=view), **TRANSLATED_STRINGS)
550
551=== removed file 'openlp/plugins/remotes/remoteplugin.py'
552--- openlp/plugins/remotes/remoteplugin.py 2017-08-24 19:53:55 +0000
553+++ openlp/plugins/remotes/remoteplugin.py 1970-01-01 00:00:00 +0000
554@@ -1,155 +0,0 @@
555-# -*- coding: utf-8 -*-
556-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
557-
558-###############################################################################
559-# OpenLP - Open Source Lyrics Projection #
560-# --------------------------------------------------------------------------- #
561-# Copyright (c) 2008-2017 OpenLP Developers #
562-# --------------------------------------------------------------------------- #
563-# This program is free software; you can redistribute it and/or modify it #
564-# under the terms of the GNU General Public License as published by the Free #
565-# Software Foundation; version 2 of the License. #
566-# #
567-# This program is distributed in the hope that it will be useful, but WITHOUT #
568-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
569-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
570-# more details. #
571-# #
572-# You should have received a copy of the GNU General Public License along #
573-# with this program; if not, write to the Free Software Foundation, Inc., 59 #
574-# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
575-###############################################################################
576-
577-import logging
578-import os
579-import time
580-
581-from PyQt5 import QtCore, QtWidgets
582-
583-from openlp.core.api.http import register_endpoint
584-from openlp.core.common import AppLocation, Registry, Settings, OpenLPMixin, UiStrings, check_directory_exists
585-from openlp.core.lib import Plugin, StringContent, translate, build_icon
586-from openlp.plugins.remotes.endpoint import remote_endpoint
587-from openlp.plugins.remotes.deploy import download_and_check, download_sha256
588-
589-log = logging.getLogger(__name__)
590-__default_settings__ = {
591- 'remotes/download version': '0000_00_00'
592-}
593-
594-
595-class RemotesPlugin(Plugin, OpenLPMixin):
596- log.info('Remotes Plugin loaded')
597-
598- def __init__(self):
599- """
600- remotes constructor
601- """
602- super(RemotesPlugin, self).__init__('remotes', __default_settings__, {})
603- self.icon_path = ':/plugins/plugin_remote.png'
604- self.icon = build_icon(self.icon_path)
605- self.weight = -1
606- register_endpoint(remote_endpoint)
607- Registry().register_function('download_website', self.first_time)
608- Registry().register_function('get_website_version', self.website_version)
609- Registry().set_flag('website_version', '0001_01_01')
610-
611- def initialise(self):
612- """
613- Create the internal file structure if it does not exist
614- :return:
615- """
616- check_directory_exists(AppLocation.get_section_data_path('remotes') / 'assets')
617- check_directory_exists(AppLocation.get_section_data_path('remotes') / 'images')
618- check_directory_exists(AppLocation.get_section_data_path('remotes') / 'static')
619- check_directory_exists(AppLocation.get_section_data_path('remotes') / 'static', 'index')
620- check_directory_exists(AppLocation.get_section_data_path('remotes') / 'templates')
621-
622- @staticmethod
623- def about():
624- """
625- Information about this plugin
626- """
627- about_text = translate(
628- 'RemotePlugin',
629- '<strong>Web Interface</strong>'
630- '<br />The web interface plugin provides the ability to develop web based interfaces using OpenLP web '
631- 'services.\nPredefined interfaces can be download as well as custom developed interfaces.')
632- return about_text
633-
634- def set_plugin_text_strings(self):
635- """
636- Called to define all translatable texts of the plugin
637- """
638- # Name PluginList
639- self.text_strings[StringContent.Name] = {
640- 'singular': translate('RemotePlugin', 'Web Interface', 'name singular'),
641- 'plural': translate('RemotePlugin', 'Web Interface', 'name plural')
642- }
643- # Name for MediaDockManager, SettingsManager
644- self.text_strings[StringContent.VisibleName] = {
645- 'title': translate('RemotePlugin', 'Web Remote', 'container title')
646- }
647-
648- def first_time(self):
649- """
650- Import web site code if active
651- """
652- self.application.process_events()
653- progress = Progress(self)
654- progress.forceShow()
655- self.application.process_events()
656- time.sleep(1)
657- download_and_check(progress)
658- self.application.process_events()
659- time.sleep(1)
660- progress.close()
661- self.application.process_events()
662- Settings().setValue('remotes/download version', self.version)
663-
664- def website_version(self):
665- """
666- Download and save the website version and sha256
667- :return: None
668- """
669- sha256, self.version = download_sha256()
670- Registry().set_flag('website_sha256', sha256)
671- Registry().set_flag('website_version', self.version)
672-
673-
674-class Progress(QtWidgets.QProgressDialog):
675- """
676- Local class to handle download display based and supporting httputils:get_web_page
677- """
678- def __init__(self, parent):
679- super(Progress, self).__init__(parent.main_window)
680- self.parent = parent
681- self.setWindowModality(QtCore.Qt.WindowModal)
682- self.setWindowTitle(translate('RemotePlugin', 'Importing Website'))
683- self.setLabelText(UiStrings().StartingImport)
684- self.setCancelButton(None)
685- self.setRange(0, 1)
686- self.setMinimumDuration(0)
687- self.was_cancelled = False
688- self.previous_size = 0
689-
690- def _download_progress(self, count, block_size):
691- """
692- Calculate and display the download progress.
693- """
694- increment = (count * block_size) - self.previous_size
695- self._increment_progress_bar(None, increment)
696- self.previous_size = count * block_size
697-
698- def _increment_progress_bar(self, status_text, increment=1):
699- """
700- Update the wizard progress page.
701-
702- :param status_text: Current status information to display.
703- :param increment: The value to increment the progress bar by.
704- """
705- if status_text:
706- self.setText(status_text)
707- if increment > 0:
708- self.setValue(self.value() + increment)
709- self.parent.application.process_events()
710
711=== modified file 'openlp/plugins/songs/endpoint.py'
712--- openlp/plugins/songs/endpoint.py 2017-08-13 06:17:47 +0000
713+++ openlp/plugins/songs/endpoint.py 2017-09-29 19:03:48 +0000
714@@ -62,7 +62,7 @@
715
716 :param request: The http request object.
717 """
718- service(request, 'songs', log)
719+ return service(request, 'songs', log)
720
721
722 @api_songs_endpoint.route('songs/search')
723@@ -95,6 +95,6 @@
724 :param request: The http request object.
725 """
726 try:
727- search(request, 'songs', log)
728+ return service(request, 'songs', log)
729 except NotFound:
730 return {'results': {'items': []}}
731
732=== added file 'tests/functional/openlp_core_api/test_deploy.py'
733--- tests/functional/openlp_core_api/test_deploy.py 1970-01-01 00:00:00 +0000
734+++ tests/functional/openlp_core_api/test_deploy.py 2017-09-29 19:03:48 +0000
735@@ -0,0 +1,63 @@
736+# -*- coding: utf-8 -*-
737+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
738+
739+###############################################################################
740+# OpenLP - Open Source Lyrics Projection #
741+# --------------------------------------------------------------------------- #
742+# Copyright (c) 2008-2017 OpenLP Developers #
743+# --------------------------------------------------------------------------- #
744+# This program is free software; you can redistribute it and/or modify it #
745+# under the terms of the GNU General Public License as published by the Free #
746+# Software Foundation; version 2 of the License. #
747+# #
748+# This program is distributed in the hope that it will be useful, but WITHOUT #
749+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
750+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
751+# more details. #
752+# #
753+# You should have received a copy of the GNU General Public License along #
754+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
755+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
756+###############################################################################
757+
758+import os
759+import shutil
760+from tempfile import mkdtemp
761+from unittest import TestCase
762+
763+from openlp.core.api.deploy import deploy_zipfile
764+
765+TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources'))
766+
767+
768+class TestRemoteDeploy(TestCase):
769+ """
770+ Test the Remote plugin deploy functions
771+ """
772+
773+ def setUp(self):
774+ """
775+ Setup for tests
776+ """
777+ self.app_root = mkdtemp()
778+
779+ def tearDown(self):
780+ """
781+ Clean up after tests
782+ """
783+ shutil.rmtree(self.app_root)
784+
785+ def test_deploy_zipfile(self):
786+ """
787+ Remote Deploy tests - test the dummy zip file is processed correctly
788+ """
789+ # GIVEN: A new downloaded zip file
790+ aa = TEST_PATH
791+ zip_file = os.path.join(TEST_PATH, 'remotes', 'site.zip')
792+ app_root = os.path.join(self.app_root, 'site.zip')
793+ shutil.copyfile(zip_file, app_root)
794+ # WHEN: I process the zipfile
795+ deploy_zipfile(self.app_root, 'site.zip')
796+
797+ # THEN test if www directory has been created
798+ self.assertTrue(os.path.isdir(os.path.join(self.app_root, 'www')), 'We should have a www directory')
799
800=== removed directory 'tests/functional/openlp_plugins/remotes'
801=== removed file 'tests/functional/openlp_plugins/remotes/__init__.py'
802--- tests/functional/openlp_plugins/remotes/__init__.py 2017-03-05 17:07:21 +0000
803+++ tests/functional/openlp_plugins/remotes/__init__.py 1970-01-01 00:00:00 +0000
804@@ -1,21 +0,0 @@
805-# -*- coding: utf-8 -*-
806-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
807-
808-###############################################################################
809-# OpenLP - Open Source Lyrics Projection #
810-# --------------------------------------------------------------------------- #
811-# Copyright (c) 2008-2017 OpenLP Developers #
812-# --------------------------------------------------------------------------- #
813-# This program is free software; you can redistribute it and/or modify it #
814-# under the terms of the GNU General Public License as published by the Free #
815-# Software Foundation; version 2 of the License. #
816-# #
817-# This program is distributed in the hope that it will be useful, but WITHOUT #
818-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
819-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
820-# more details. #
821-# #
822-# You should have received a copy of the GNU General Public License along #
823-# with this program; if not, write to the Free Software Foundation, Inc., 59 #
824-# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
825-###############################################################################
826
827=== removed file 'tests/functional/openlp_plugins/remotes/test_deploy.py'
828--- tests/functional/openlp_plugins/remotes/test_deploy.py 2017-08-12 19:34:56 +0000
829+++ tests/functional/openlp_plugins/remotes/test_deploy.py 1970-01-01 00:00:00 +0000
830@@ -1,64 +0,0 @@
831-# -*- coding: utf-8 -*-
832-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
833-
834-###############################################################################
835-# OpenLP - Open Source Lyrics Projection #
836-# --------------------------------------------------------------------------- #
837-# Copyright (c) 2008-2017 OpenLP Developers #
838-# --------------------------------------------------------------------------- #
839-# This program is free software; you can redistribute it and/or modify it #
840-# under the terms of the GNU General Public License as published by the Free #
841-# Software Foundation; version 2 of the License. #
842-# #
843-# This program is distributed in the hope that it will be useful, but WITHOUT #
844-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
845-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
846-# more details. #
847-# #
848-# You should have received a copy of the GNU General Public License along #
849-# with this program; if not, write to the Free Software Foundation, Inc., 59 #
850-# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
851-###############################################################################
852-
853-import os
854-import shutil
855-
856-from tempfile import mkdtemp
857-from unittest import TestCase
858-
859-from openlp.plugins.remotes.deploy import deploy_zipfile
860-
861-
862-TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources'))
863-
864-
865-class TestRemoteDeploy(TestCase):
866- """
867- Test the Remote plugin deploy functions
868- """
869-
870- def setUp(self):
871- """
872- Setup for tests
873- """
874- self.app_root = mkdtemp()
875-
876- def tearDown(self):
877- """
878- Clean up after tests
879- """
880- shutil.rmtree(self.app_root)
881-
882- def test_deploy_zipfile(self):
883- """
884- Remote Deploy tests - test the dummy zip file is processed correctly
885- """
886- # GIVEN: A new downloaded zip file
887- zip_file = os.path.join(TEST_PATH, 'remotes', 'site.zip')
888- app_root = os.path.join(self.app_root, 'site.zip')
889- shutil.copyfile(zip_file, app_root)
890- # WHEN: I process the zipfile
891- deploy_zipfile(self.app_root, 'site.zip')
892-
893- # THEN test if www directory has been created
894- self.assertTrue(os.path.isdir(os.path.join(self.app_root, 'www')), 'We should have a www directory')
895
896=== modified file 'tests/interfaces/openlp_core_lib/test_pluginmanager.py'
897--- tests/interfaces/openlp_core_lib/test_pluginmanager.py 2017-08-26 15:06:11 +0000
898+++ tests/interfaces/openlp_core_lib/test_pluginmanager.py 2017-09-29 19:03:48 +0000
899@@ -94,4 +94,3 @@
900 self.assertIn('custom', plugin_names, 'There should be a "custom" plugin')
901 self.assertIn('songusage', plugin_names, 'There should be a "songusage" plugin')
902 self.assertIn('alerts', plugin_names, 'There should be a "alerts" plugin')
903- self.assertIn('remotes', plugin_names, 'There should be a "remotes" plugin')