diff --git a/pyupdater/cli/__init__.py b/pyupdater/cli/__init__.py index 65eb88e4..3ffd3626 100755 --- a/pyupdater/cli/__init__.py +++ b/pyupdater/cli/__init__.py @@ -82,12 +82,12 @@ def _real_main(args, namespace_test_helper=None): # pragma: no cover # Used for tests args = namespace_test_helper - _dispatch_command(args, pyi_args) + dispatch_command(args, pyi_args) # Dispatch the passed in command to its respective function in # pyupdater.cli.commands -def _dispatch_command(args, pyi_args=None, test=False): +def dispatch_command(args, pyi_args=None, test=False): # Turns collect-debug-info into collect_debug_info cmd_str = "_cmd_" + args.command.replace('-', '_') try: diff --git a/pyupdater/cli/commands.py b/pyupdater/cli/commands.py index f0d11478..38553e38 100644 --- a/pyupdater/cli/commands.py +++ b/pyupdater/cli/commands.py @@ -281,7 +281,7 @@ def _cmd_pkg(*args): # ToDo: Remove in v3.0 # I wanted to make the commands uniform to enable the usage of -# _dispatch_command in pyupdater.cli +# dispatch_command in pyupdater.cli def upload_debug_info(*args): _cmd_collect_debug_info(*args) # End ToDo @@ -398,6 +398,7 @@ def _cmd_upload(*args): # pragma: no cover return # Something happened with the upload plugin except UploaderPluginError as err: + log.debug(err) log.error('Invalid upload plugin') log.error('Use "pyupdater plugins" to get a ' 'list of installed plugins') diff --git a/pyupdater/client/__init__.py b/pyupdater/client/__init__.py index 7c58dcf1..e96106e1 100644 --- a/pyupdater/client/__init__.py +++ b/pyupdater/client/__init__.py @@ -42,7 +42,7 @@ from pyupdater import settings, __version__ from pyupdater.client.downloader import FileDownloader as _FD -from pyupdater.client.updates import AppUpdate, _get_highest_version, LibUpdate +from pyupdater.client.updates import AppUpdate, get_highest_version, LibUpdate from pyupdater.utils.config import Config as _Config @@ -252,10 +252,10 @@ def _update_check(self, name, version, channel, strict): app = True log.debug('Checking for %s updates...', name) - latest = _get_highest_version(name, self.platform, channel, - self.easy_data, strict) + latest = get_highest_version(name, self.platform, channel, + self.easy_data, strict) if latest is None: - # If None is returned _get_highest_version could + # If None is returned get_highest_version could # not find the supplied name in the version file log.debug('Could not find the latest version') return None @@ -380,6 +380,7 @@ def _get_manifest_from_disk(self): try: decompressed_data = _gzip_decompress(data) except Exception as err: + log.debug(err) return None return decompressed_data diff --git a/pyupdater/client/updates.py b/pyupdater/client/updates.py index 87b3be48..21c09f37 100644 --- a/pyupdater/client/updates.py +++ b/pyupdater/client/updates.py @@ -47,7 +47,7 @@ log = logging.getLogger(__name__) -def _get_highest_version(name, plat, channel, easy_data, strict): +def get_highest_version(name, plat, channel, easy_data, strict): """Parses version file and returns the highest version number. Args: @@ -120,7 +120,7 @@ def _get_highest_version(name, plat, channel, easy_data, strict): return version -def _gen_user_friendly_version(internal_version): +def gen_user_friendly_version(internal_version): channel = {0: 'Alpha', 1: 'Beta'} v = list(map(int, internal_version.split('.'))) @@ -294,9 +294,9 @@ def _init_app(self, data): self.max_download_retries = data.get('max_download_retries') # The latest version available - self.latest = _get_highest_version(self.name, self.platform, - self.channel, self.easy_data, - self.strict) + self.latest = get_highest_version(self.name, self.platform, + self.channel, self.easy_data, + self.strict) # The name of the current versions update archive. # Will be used to check if the current archive is available for a @@ -321,7 +321,7 @@ def version(self): ######Returns (str): User friendly version string """ if self._version == "": - self._version = _gen_user_friendly_version(self.latest) + self._version = gen_user_friendly_version(self.latest) return self._version def is_downloaded(self): diff --git a/pyupdater/key_handler/keys.py b/pyupdater/key_handler/keys.py index f7e84176..34805a5b 100644 --- a/pyupdater/key_handler/keys.py +++ b/pyupdater/key_handler/keys.py @@ -165,7 +165,8 @@ def _look_for_keypack(): return False return True - def _load_keypack(self): + @staticmethod + def _load_keypack(): json_data = None try: with io.open(settings.KEYPACK_FILENAME, 'r', @@ -184,7 +185,7 @@ def start(self): found = KeyImporter._look_for_keypack() if found is False: return False - keypack = self._load_keypack() + keypack = KeyImporter._load_keypack() if keypack is None: return False self.db.save(settings.CONFIG_DB_KEY_KEYPACK, keypack) diff --git a/pyupdater/package_handler/__init__.py b/pyupdater/package_handler/__init__.py index 6fb04fa9..476e12a2 100644 --- a/pyupdater/package_handler/__init__.py +++ b/pyupdater/package_handler/__init__.py @@ -457,7 +457,7 @@ def _check_make_patch(self, json_data, name, platform): if bsdiff4 is None: log.warning('Bsdiff is missing. Cannot create patches') return None - src_file_path = None + if os.path.exists(self.files_dir): with ChDir(self.files_dir): files = os.listdir(os.getcwd()) diff --git a/pyupdater/uploader.py b/pyupdater/uploader.py index 015ff17f..e668ec33 100644 --- a/pyupdater/uploader.py +++ b/pyupdater/uploader.py @@ -47,7 +47,7 @@ class Uploader(object): Args: - obj (instance): config object + config (instance): config object """ def __init__(self, config=None): # Specifies whether to keep a file after uploading @@ -173,6 +173,7 @@ def _retry_upload(self, failed_uploads): return failed_uploads +# noinspection PyProtectedMember class AbstractBaseUploaderMeta(type): def __call__(cls, *args, **kwargs): diff --git a/pyupdater/utils/__init__.py b/pyupdater/utils/__init__.py index 67526291..51f625aa 100644 --- a/pyupdater/utils/__init__.py +++ b/pyupdater/utils/__init__.py @@ -32,7 +32,6 @@ import subprocess import sys import tarfile -import time import zipfile try: from UserDict import DictMixin diff --git a/pyupdater/utils/config.py b/pyupdater/utils/config.py index 8659aac0..979819ec 100644 --- a/pyupdater/utils/config.py +++ b/pyupdater/utils/config.py @@ -107,11 +107,11 @@ def save_config(self, obj): log.info('Saving Config') self.db.save(self.config_key, obj) log.info('Config saved') - self._write_config_py(obj) + self.write_config_py(obj) log.info('Wrote client config') # Writes client config to client_config.py - def _write_config_py(self, obj): + def write_config_py(self, obj): keypack_data = self.db.load(settings.CONFIG_DB_KEY_KEYPACK) if keypack_data is None: log.debug('*** Keypack data is None ***') diff --git a/tests/data/update_repo_restart/app_restart_01.py b/tests/data/update_repo_restart/app_restart_01.py index 44ab6491..aa7bb407 100644 --- a/tests/data/update_repo_restart/app_restart_01.py +++ b/tests/data/update_repo_restart/app_restart_01.py @@ -1,4 +1,5 @@ from __future__ import print_function +import os import sys from pyupdater.client import Client diff --git a/tests/test_cli.py b/tests/test_cli.py index db60e3de..5eee3c28 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -29,7 +29,7 @@ import pytest -from pyupdater.cli import commands, _dispatch_command +from pyupdater.cli import commands, dispatch_command from pyupdater.cli.options import (add_build_parser, add_clean_parser, add_keys_parser, add_make_spec_parser, add_package_parser, add_upload_parser, @@ -66,44 +66,44 @@ def __getattribute__(self, name): class TestCommandDispatch(object): def test_build(self): - assert _dispatch_command(NamespaceHelper(command='build'), - test=True) is True + assert dispatch_command(NamespaceHelper(command='build'), + test=True) is True def test_clean(self): - assert _dispatch_command(NamespaceHelper(command='clean'), - test=True) is True + assert dispatch_command(NamespaceHelper(command='clean'), + test=True) is True def test_settings(self): - assert _dispatch_command(NamespaceHelper(command='settings'), - test=True) is True + assert dispatch_command(NamespaceHelper(command='settings'), + test=True) is True def test_init(self): - assert _dispatch_command(NamespaceHelper(command='init'), - test=True) is True + assert dispatch_command(NamespaceHelper(command='init'), + test=True) is True def test_keys(self): - assert _dispatch_command(NamespaceHelper(command='keys'), - test=True) is True + assert dispatch_command(NamespaceHelper(command='keys'), + test=True) is True def test_make_spec(self): - assert _dispatch_command(NamespaceHelper(command='make-spec'), - test=True) is True + assert dispatch_command(NamespaceHelper(command='make-spec'), + test=True) is True def test_pkg(self): - assert _dispatch_command(NamespaceHelper(command='pkg'), - test=True) is True + assert dispatch_command(NamespaceHelper(command='pkg'), + test=True) is True def test_collect_debug_info(self): - assert _dispatch_command(NamespaceHelper(command='collect-debug-info'), - test=True) is True + assert dispatch_command(NamespaceHelper(command='collect-debug-info'), + test=True) is True def test_upload(self): - assert _dispatch_command(NamespaceHelper(command='upload'), - test=True) is True + assert dispatch_command(NamespaceHelper(command='upload'), + test=True) is True def test_version(self): - assert _dispatch_command(NamespaceHelper(command='version'), - test=True) is True + assert dispatch_command(NamespaceHelper(command='version'), + test=True) is True @pytest.mark.usefixtures('cleandir') diff --git a/tests/test_client.py b/tests/test_client.py index c350b30f..26834798 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -36,8 +36,8 @@ import six from pyupdater.client import Client -from pyupdater.client.updates import (_gen_user_friendly_version, - _get_highest_version) +from pyupdater.client.updates import (gen_user_friendly_version, + get_highest_version) from tconfig import TConfig @@ -220,10 +220,10 @@ def test_extract_no_file(self, client): class TestGenVersion(object): def test1(self): - assert _gen_user_friendly_version('1.0.0.2.0') == '1.0' - assert _gen_user_friendly_version('1.2.2.2.0') == '1.2.2' - assert _gen_user_friendly_version('2.0.5.0.3') == '2.0.5 Alpha 3' - assert _gen_user_friendly_version('2.2.1.1.0') == '2.2.1 Beta' + assert gen_user_friendly_version('1.0.0.2.0') == '1.0' + assert gen_user_friendly_version('1.2.2.2.0') == '1.2.2' + assert gen_user_friendly_version('2.0.5.0.3') == '2.0.5 Alpha 3' + assert gen_user_friendly_version('2.2.1.1.0') == '2.2.1 Beta' class TestChannelStrict(object): @@ -246,12 +246,12 @@ class TestChannelStrict(object): def test1(self): data = EasyAccessDict(self.version_data) - assert _get_highest_version('Acme', 'mac', 'alpha', - data, strict=True) == '4.4.2.0.5' - assert _get_highest_version('Acme', 'mac', 'beta', - data, strict=True) == '4.4.1.1.0' - assert _get_highest_version('Acme', 'mac', 'stable', - data, strict=True) == '4.4.3.2.0' + assert get_highest_version('Acme', 'mac', 'alpha', + data, strict=True) == '4.4.2.0.5' + assert get_highest_version('Acme', 'mac', 'beta', + data, strict=True) == '4.4.1.1.0' + assert get_highest_version('Acme', 'mac', 'stable', + data, strict=True) == '4.4.3.2.0' class TestChannelLessStrict(object): @@ -274,8 +274,8 @@ class TestChannelLessStrict(object): def test1(self): data = EasyAccessDict(self.version_data) - assert _get_highest_version('Acme', 'mac', 'alpha', - data, strict=False) == '4.4.3.2.0' + assert get_highest_version('Acme', 'mac', 'alpha', + data, strict=False) == '4.4.3.2.0' class TestMissingStable(object): @@ -295,5 +295,5 @@ class TestMissingStable(object): def test1(self): data = EasyAccessDict(self.version_data) - assert _get_highest_version('Acme', 'mac', 'stable', - data, strict=True) is None + assert get_highest_version('Acme', 'mac', 'stable', + data, strict=True) is None diff --git a/tests/test_config.py b/tests/test_config.py index bc4f1186..c32381c9 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -82,5 +82,5 @@ def test_write_config(cleandir): prod_config = ProdConfig() config.from_object(prod_config) cm = ConfigManager() - cm._write_config_py(config) + cm.write_config_py(config) assert 'client_config.py' in os.listdir(os.getcwd())