From 5b2ac0f97b7f655c47e33eb00e308ac9ea862abb Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 26 Sep 2017 18:49:41 +0100 Subject: [PATCH] more moves --- openlp/plugins/remotes/deploy.py | 69 ------------------- openlp/plugins/remotes/remoteplugin.py | 6 +- .../openlp_plugins/remotes/test_deploy.py | 4 +- 3 files changed, 4 insertions(+), 75 deletions(-) delete mode 100644 openlp/plugins/remotes/deploy.py diff --git a/openlp/plugins/remotes/deploy.py b/openlp/plugins/remotes/deploy.py deleted file mode 100644 index 44c628837..000000000 --- a/openlp/plugins/remotes/deploy.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2017 OpenLP Developers # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### -""" -Download and "install" the remote web client -""" -import os -from zipfile import ZipFile - -from openlp.core.common import AppLocation, Registry -from openlp.core.common.httputils import url_get_file, get_web_page, get_url_file_size - - -def deploy_zipfile(app_root, zip_name): - """ - Process the downloaded zip file and add to the correct directory - - :param zip_name: the zip file to be processed - :param app_root: the directory where the zip get expanded to - - :return: None - """ - zip_file = os.path.join(app_root, zip_name) - web_zip = ZipFile(zip_file) - web_zip.extractall(app_root) - - -def download_sha256(): - """ - Download the config file to extract the sha256 and version number - """ - user_agent = 'OpenLP/' + Registry().get('application').applicationVersion() - try: - web_config = get_web_page('https://get.openlp.org/webclient/download.cfg', headers={'User-Agent': user_agent}) - except ConnectionError: - return False - file_bits = web_config.split() - return file_bits[0], file_bits[2] - - -def download_and_check(callback=None): - """ - Download the web site and deploy it. - """ - sha256, version = download_sha256() - file_size = get_url_file_size('https://get.openlp.org/webclient/site.zip') - callback.setRange(0, file_size) - if url_get_file(callback, '{host}{name}'.format(host='https://get.openlp.org/webclient/', name='site.zip'), - AppLocation.get_section_data_path('remotes') / 'site.zip', - sha256=sha256): - deploy_zipfile(str(AppLocation.get_section_data_path('remotes')), 'site.zip') diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 4974e451b..c223eb99e 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -20,16 +20,16 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +import logging import time + from PyQt5 import QtCore, QtWidgets -import logging - +from openlp.core.api.deploy import download_and_check, download_sha256 from openlp.core.api.endpoint.remote import remote_endpoint from openlp.core.api.http import register_endpoint from openlp.core.common import AppLocation, Registry, Settings, OpenLPMixin, UiStrings, check_directory_exists from openlp.core.lib import Plugin, StringContent, translate, build_icon -from openlp.plugins.remotes.deploy import download_and_check, download_sha256 log = logging.getLogger(__name__) __default_settings__ = { diff --git a/tests/functional/openlp_plugins/remotes/test_deploy.py b/tests/functional/openlp_plugins/remotes/test_deploy.py index 1909b94fd..14447a97e 100644 --- a/tests/functional/openlp_plugins/remotes/test_deploy.py +++ b/tests/functional/openlp_plugins/remotes/test_deploy.py @@ -22,12 +22,10 @@ import os import shutil - from tempfile import mkdtemp from unittest import TestCase -from openlp.plugins.remotes.deploy import deploy_zipfile - +from openlp.core.api.deploy import deploy_zipfile TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources'))