forked from openlp/openlp
more moves
This commit is contained in:
parent
9fc7f1b39b
commit
5b2ac0f97b
@ -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')
|
|
@ -20,16 +20,16 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets
|
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.endpoint.remote import remote_endpoint
|
||||||
from openlp.core.api.http import register_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.common import AppLocation, Registry, Settings, OpenLPMixin, UiStrings, check_directory_exists
|
||||||
from openlp.core.lib import Plugin, StringContent, translate, build_icon
|
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__)
|
log = logging.getLogger(__name__)
|
||||||
__default_settings__ = {
|
__default_settings__ = {
|
||||||
|
@ -22,12 +22,10 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from unittest import TestCase
|
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'))
|
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user