diff --git a/docs/source/conf.py b/docs/source/conf.py index c20542de..382d8feb 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,7 +12,6 @@ # import os import sys - sys.path.insert(0, os.path.abspath('../../fdroidserver')) # -- Project information ----------------------------------------------------- diff --git a/examples/fdroid_clean_repos.py b/examples/fdroid_clean_repos.py index 6b19cacc..cf6259a7 100644 --- a/examples/fdroid_clean_repos.py +++ b/examples/fdroid_clean_repos.py @@ -6,6 +6,7 @@ import argparse import logging from fdroidserver import _, common, metadata + from fdroidserver.exception import VCSException fdroid_summary = 'reset app VCSs to the latest version' diff --git a/examples/fdroid_export_keystore_to_nitrokey.py b/examples/fdroid_export_keystore_to_nitrokey.py index 6e920a78..8fa81ffe 100644 --- a/examples/fdroid_export_keystore_to_nitrokey.py +++ b/examples/fdroid_export_keystore_to_nitrokey.py @@ -4,7 +4,6 @@ import os from argparse import ArgumentParser - from fdroidserver import common from fdroidserver.common import FDroidPopen from fdroidserver.exception import BuildException diff --git a/examples/fdroid_exportkeystore.py b/examples/fdroid_exportkeystore.py index f2a16980..435874a5 100644 --- a/examples/fdroid_exportkeystore.py +++ b/examples/fdroid_exportkeystore.py @@ -4,7 +4,6 @@ import os from argparse import ArgumentParser - from fdroidserver import common from fdroidserver.common import FDroidPopen from fdroidserver.exception import BuildException diff --git a/examples/fdroid_extract_repo_pubkey.py b/examples/fdroid_extract_repo_pubkey.py index cb5a895c..f3c51767 100644 --- a/examples/fdroid_extract_repo_pubkey.py +++ b/examples/fdroid_extract_repo_pubkey.py @@ -4,7 +4,6 @@ # from argparse import ArgumentParser - from fdroidserver import common, index fdroid_summary = 'export the keystore in standard PEM format' diff --git a/examples/fdroid_fetchsrclibs.py b/examples/fdroid_fetchsrclibs.py index aba6f7fa..e4a105e2 100644 --- a/examples/fdroid_fetchsrclibs.py +++ b/examples/fdroid_fetchsrclibs.py @@ -8,7 +8,6 @@ import argparse import os import pprint - from fdroidserver import _, common, metadata fdroid_summary = 'prepare the srclibs for `fdroid build --on-server`' diff --git a/examples/fdroid_nitrokeyimport.py b/examples/fdroid_nitrokeyimport.py index d17a6186..9b458103 100644 --- a/examples/fdroid_nitrokeyimport.py +++ b/examples/fdroid_nitrokeyimport.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 from argparse import ArgumentParser - from fdroidserver import common from fdroidserver.common import FDroidPopen from fdroidserver.exception import BuildException diff --git a/fdroidserver/__init__.py b/fdroidserver/__init__.py index c4376bd6..9e4c197f 100644 --- a/fdroidserver/__init__.py +++ b/fdroidserver/__init__.py @@ -3,6 +3,7 @@ import glob import os import sys + # support running straight from git and standard installs rootpaths = [ os.path.realpath(os.path.join(os.path.dirname(__file__), '..')), @@ -23,52 +24,39 @@ gettext.textdomain('fdroidserver') _ = gettext.gettext -from fdroidserver.exception import ( - FDroidException, - MetaDataException, - VerificationException, # NOQA: E402 -) - +from fdroidserver.exception import (FDroidException, + MetaDataException, + VerificationException) # NOQA: E402 FDroidException # NOQA: B101 MetaDataException # NOQA: B101 VerificationException # NOQA: B101 -from fdroidserver.common import genkeystore as generate_keystore # NOQA: E402 -from fdroidserver.common import verify_apk_signature - +from fdroidserver.common import (verify_apk_signature, + genkeystore as generate_keystore) # NOQA: E402 verify_apk_signature # NOQA: B101 generate_keystore # NOQA: B101 -from fdroidserver.index import ( - download_repo_index, - download_repo_index_v1, - download_repo_index_v2, - get_mirror_service_urls, -) -from fdroidserver.index import make as make_index # NOQA: E402 - +from fdroidserver.index import (download_repo_index, + download_repo_index_v1, + download_repo_index_v2, + get_mirror_service_urls, + make as make_index) # NOQA: E402 download_repo_index # NOQA: B101 download_repo_index_v1 # NOQA: B101 download_repo_index_v2 # NOQA: B101 get_mirror_service_urls # NOQA: B101 make_index # NOQA: B101 -from fdroidserver.update import ( - process_apk, - process_apks, - scan_apk, - scan_repo_files, # NOQA: E402 -) - +from fdroidserver.update import (process_apk, + process_apks, + scan_apk, + scan_repo_files) # NOQA: E402 process_apk # NOQA: B101 process_apks # NOQA: B101 scan_apk # NOQA: B101 scan_repo_files # NOQA: B101 -from fdroidserver.deploy import ( - update_awsbucket, - update_servergitmirrors, - update_serverwebroot, # NOQA: E402 - update_serverwebroots, -) - +from fdroidserver.deploy import (update_awsbucket, + update_servergitmirrors, + update_serverwebroots, + update_serverwebroot) # NOQA: E402 update_awsbucket # NOQA: B101 update_servergitmirrors # NOQA: B101 update_serverwebroots # NOQA: B101 diff --git a/fdroidserver/__main__.py b/fdroidserver/__main__.py index 71c39b2c..14813fa1 100755 --- a/fdroidserver/__main__.py +++ b/fdroidserver/__main__.py @@ -18,20 +18,20 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import importlib.metadata -import logging -import os -import pkgutil import re import sys -from argparse import ArgumentError -from collections import OrderedDict +import os +import pkgutil +import logging +import importlib.metadata import git - import fdroidserver.common import fdroidserver.metadata from fdroidserver import _ +from argparse import ArgumentError +from collections import OrderedDict + COMMANDS = OrderedDict([ ("build", _("Build a package from source")), diff --git a/fdroidserver/apksigcopier.py b/fdroidserver/apksigcopier.py index f36de2eb..2ab0b8c4 100644 --- a/fdroidserver/apksigcopier.py +++ b/fdroidserver/apksigcopier.py @@ -68,18 +68,9 @@ import struct import sys import zipfile import zlib + from collections import namedtuple -from typing import ( - Any, - BinaryIO, - Callable, - Dict, - Iterable, - Iterator, - Optional, - Tuple, - Union, -) +from typing import Any, BinaryIO, Callable, Dict, Iterable, Iterator, Optional, Tuple, Union __version__ = "1.1.1" NAME = "apksigcopier" diff --git a/fdroidserver/btlog.py b/fdroidserver/btlog.py index 7ca3ddbf..df889396 100755 --- a/fdroidserver/btlog.py +++ b/fdroidserver/btlog.py @@ -28,21 +28,22 @@ # the F-Droid client. import collections +import defusedxml.minidom +import git import glob +import os import json import logging -import os +import requests import shutil import tempfile import zipfile from argparse import ArgumentParser from typing import Optional -import defusedxml.minidom -import git -import requests - -from . import _, common, deploy +from . import _ +from . import common +from . import deploy from .exception import FDroidException diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 2e716c10..a187765b 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -18,27 +18,31 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import argparse -import glob -import logging import os +import shutil +import glob +import subprocess import posixpath import re -import shutil -import subprocess import tarfile -import tempfile import threading -import time import traceback +import time +import requests +import tempfile +import argparse +import logging from gettext import ngettext from pathlib import Path -import requests - -from . import _, common, metadata, net, scanner, vmtools +from . import _ +from . import common +from . import net +from . import metadata +from . import scanner +from . import vmtools from .common import FDroidPopen -from .exception import BuildException, FDroidException, VCSException +from .exception import FDroidException, BuildException, VCSException try: import paramiko diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index cff7bcd7..9ed93298 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -19,30 +19,28 @@ # along with this program. If not, see . import configparser -import copy -import logging +import git import os import re +import urllib.request +import urllib.error +import time import subprocess import sys -import time -import traceback -import urllib.error -import urllib.parse -import urllib.request from argparse import ArgumentParser +import traceback +import logging +import copy +import urllib.parse from pathlib import Path from typing import Optional -import git +from . import _ +from . import common +from . import metadata +from . import net +from .exception import VCSException, NoSubmodulesException, FDroidException, MetaDataException -from . import _, common, metadata, net -from .exception import ( - FDroidException, - MetaDataException, - NoSubmodulesException, - VCSException, -) # https://gitlab.com/fdroid/checkupdates-runner/-/blob/1861899262a62a4ed08fa24e5449c0368dfb7617/.gitlab-ci.yml#L36 BOT_EMAIL = 'fdroidci@bubu1.eu' diff --git a/fdroidserver/common.py b/fdroidserver/common.py index ec0079af..ad4df2ba 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -52,59 +52,55 @@ environment variable to include. """ -import ast -import base64 import copy import difflib +from typing import List import filecmp +import git import glob -import gzip -import hashlib import io import itertools -import json -import logging -import operator import os +import sys import re +import ast +import gzip import shutil -import socket import stat import subprocess -import sys -import tempfile import time +import operator +import logging +import hashlib +import socket +import base64 import zipfile +import tempfile +import json +from pathlib import Path + +import defusedxml.ElementTree as XMLElementTree + from argparse import BooleanOptionalAction +from asn1crypto import cms from base64 import urlsafe_b64encode from binascii import hexlify from datetime import datetime, timedelta, timezone -from pathlib import Path from queue import Queue -from typing import List from urllib.parse import urlparse, urlsplit, urlunparse from zipfile import ZipFile -import defusedxml.ElementTree as XMLElementTree -import git -from asn1crypto import cms - import fdroidserver.metadata from fdroidserver import _ -from fdroidserver._yaml import config_dump, yaml -from fdroidserver.exception import ( - BuildException, - FDroidException, - MetaDataException, - NoSubmodulesException, - VCSException, - VerificationException, -) - -from . import apksigcopier, common +from fdroidserver._yaml import yaml, config_dump +from fdroidserver.exception import FDroidException, VCSException, NoSubmodulesException, \ + BuildException, VerificationException, MetaDataException from .asynchronousfilereader import AsynchronousFileReader from .looseversion import LooseVersion +from . import apksigcopier, common + + # The path to this fdroidserver distribution FDROID_PATH = os.path.realpath(os.path.join(os.path.dirname(__file__), '..')) @@ -2908,9 +2904,9 @@ def is_debuggable_or_testOnly(apkfile): return False try: # these were moved in androguard 4.0 - from androguard.core.axml import START_TAG, AXMLParser, format_value + from androguard.core.axml import AXMLParser, format_value, START_TAG except ImportError: - from androguard.core.bytecodes.axml import START_TAG, AXMLParser, format_value + from androguard.core.bytecodes.axml import AXMLParser, format_value, START_TAG _androguard_logging_level() with ZipFile(apkfile) as apk: @@ -2982,23 +2978,9 @@ def get_apk_id_androguard(apkfile): try: # these were moved in androguard 4.0 - from androguard.core.axml import ( - END_DOCUMENT, - END_TAG, - START_TAG, - TEXT, - AXMLParser, - format_value, - ) + from androguard.core.axml import AXMLParser, format_value, START_TAG, END_TAG, TEXT, END_DOCUMENT except ImportError: - from androguard.core.bytecodes.axml import ( - END_DOCUMENT, - END_TAG, - START_TAG, - TEXT, - AXMLParser, - format_value, - ) + from androguard.core.bytecodes.axml import AXMLParser, format_value, START_TAG, END_TAG, TEXT, END_DOCUMENT _androguard_logging_level() appid = None diff --git a/fdroidserver/deploy.py b/fdroidserver/deploy.py index b4f98f34..cc7d6c52 100644 --- a/fdroidserver/deploy.py +++ b/fdroidserver/deploy.py @@ -16,28 +16,28 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import sys import glob import hashlib import json -import logging import os -import pathlib import re -import shutil import subprocess -import sys import time import urllib -from argparse import ArgumentParser from typing import Dict, List - -import git -import yaml from git import Repo - +import yaml +from argparse import ArgumentParser +import logging +import pathlib +import shutil +import git import fdroidserver.github -from . import _, common, index +from . import _ +from . import common +from . import index from .exception import FDroidException config = None @@ -349,8 +349,8 @@ def update_awsbucket_libcloud(repo_section, is_index_only=False): import libcloud.security libcloud.security.VERIFY_SSL_CERT = True + from libcloud.storage.types import Provider, ContainerDoesNotExistError from libcloud.storage.providers import get_driver - from libcloud.storage.types import ContainerDoesNotExistError, Provider if not config.get('awsaccesskeyid') or not config.get('awssecretkey'): raise FDroidException( @@ -854,9 +854,8 @@ def upload_to_android_observatory(repo_section): def upload_apk_to_android_observatory(path): # depend on requests and lxml only if users enable AO import requests - from lxml.html import fromstring - from . import net + from lxml.html import fromstring apkfilename = os.path.basename(path) r = requests.post( diff --git a/fdroidserver/github.py b/fdroidserver/github.py index 34a3ee53..0a6844d9 100644 --- a/fdroidserver/github.py +++ b/fdroidserver/github.py @@ -18,8 +18,8 @@ import json import pathlib -import urllib.parse import urllib.request +import urllib.parse class GithubApi: diff --git a/fdroidserver/gpgsign.py b/fdroidserver/gpgsign.py index 4341cb36..4ba6ebd5 100644 --- a/fdroidserver/gpgsign.py +++ b/fdroidserver/gpgsign.py @@ -16,13 +16,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import glob -import logging import os -import time +import glob from argparse import ArgumentParser +import logging +import time -from . import _, common +from . import _ +from . import common from .common import FDroidPopen from .exception import FDroidException diff --git a/fdroidserver/index.py b/fdroidserver/index.py index 3482f15c..86394d7c 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -30,7 +30,6 @@ these installed on the signing server. """ -import calendar import collections import hashlib import json @@ -42,27 +41,20 @@ import sys import tempfile import urllib.parse import zipfile +import calendar from binascii import hexlify, unhexlify from datetime import datetime, timezone from pathlib import Path from xml.dom.minidom import Document +from . import _ +from . import common +from . import metadata +from . import signindex +from fdroidserver.common import ANTIFEATURES_CONFIG_NAME, CATEGORIES_CONFIG_NAME, CONFIG_CONFIG_NAME, MIRRORS_CONFIG_NAME, RELEASECHANNELS_CONFIG_NAME, DEFAULT_LOCALE, FDroidPopen, FDroidPopenBytes, load_publish_signer_fingerprints from fdroidserver._yaml import yaml -from fdroidserver.common import ( - ANTIFEATURES_CONFIG_NAME, - CATEGORIES_CONFIG_NAME, - CONFIG_CONFIG_NAME, - DEFAULT_LOCALE, - MIRRORS_CONFIG_NAME, - RELEASECHANNELS_CONFIG_NAME, - FDroidPopen, - FDroidPopenBytes, - load_publish_signer_fingerprints, -) from fdroidserver.exception import FDroidException, VerificationException -from . import _, common, metadata, signindex - def make(apps, apks, repodir, archive): """Generate the repo index files. diff --git a/fdroidserver/init.py b/fdroidserver/init.py index 39b18c1a..a5575fea 100644 --- a/fdroidserver/init.py +++ b/fdroidserver/init.py @@ -19,15 +19,16 @@ # along with this program. If not, see . import glob -import logging import os import re import shutil import socket import sys from argparse import ArgumentParser +import logging -from . import _, common +from . import _ +from . import common from .exception import FDroidException config = {} diff --git a/fdroidserver/install.py b/fdroidserver/install.py index 8c1dc948..74754520 100644 --- a/fdroidserver/install.py +++ b/fdroidserver/install.py @@ -17,22 +17,25 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import sys +import os import glob import locale import logging -import os -import sys import termios import tty + +import defusedxml.ElementTree as XMLElementTree + from argparse import ArgumentParser, BooleanOptionalAction from pathlib import Path from urllib.parse import urlencode, urlparse, urlunparse -import defusedxml.ElementTree as XMLElementTree - -from . import _, common, github, index, net +from . import _ +from . import common, github, index, net from .exception import FDroidException + DEFAULT_IPFS_GATEWAYS = ("https://gateway.ipfs.io/ipfs/",) MAVEN_CENTRAL_MIRRORS = [ { diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py index f384cb62..cb5ead84 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -24,9 +24,8 @@ import urllib.parse from argparse import ArgumentParser from pathlib import Path -from fdroidserver._yaml import yaml - from . import _, common, metadata, rewritemeta +from fdroidserver._yaml import yaml config = None diff --git a/fdroidserver/metadata.py b/fdroidserver/metadata.py index 0d9195be..47fbdca7 100644 --- a/fdroidserver/metadata.py +++ b/fdroidserver/metadata.py @@ -18,19 +18,19 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import logging -import math -import os -import platform -import re -from collections import OrderedDict from pathlib import Path - +import math +import platform +import os +import re +import logging import ruamel.yaml +from collections import OrderedDict -from . import _, common -from ._yaml import yaml +from . import common +from . import _ from .exception import MetaDataException +from ._yaml import yaml srclibs = None warnings_action = None diff --git a/fdroidserver/mirror.py b/fdroidserver/mirror.py index b06df3b1..80f8394f 100644 --- a/fdroidserver/mirror.py +++ b/fdroidserver/mirror.py @@ -7,10 +7,13 @@ import posixpath import socket import subprocess import sys -import urllib.parse from argparse import ArgumentParser +import urllib.parse -from . import _, common, index, update +from . import _ +from . import common +from . import index +from . import update def _run_wget(path, urls, verbose=False): @@ -130,7 +133,6 @@ def main(): import io import json import zipfile - from . import net url = _append_to_url_path(section, 'index-v1.jar') diff --git a/fdroidserver/net.py b/fdroidserver/net.py index fe097fd5..1ec7d096 100644 --- a/fdroidserver/net.py +++ b/fdroidserver/net.py @@ -21,11 +21,10 @@ import copy import logging import os import random +import requests import tempfile import time import urllib - -import requests import urllib3 from requests.adapters import HTTPAdapter, Retry diff --git a/fdroidserver/nightly.py b/fdroidserver/nightly.py index 372390ea..3d57c452 100644 --- a/fdroidserver/nightly.py +++ b/fdroidserver/nightly.py @@ -19,25 +19,25 @@ import base64 import datetime +import git import hashlib import inspect import logging import os +import paramiko import platform import shutil import ssl import subprocess import sys import tempfile +import yaml +from urllib.parse import urlparse from argparse import ArgumentParser from typing import Optional -from urllib.parse import urlparse -import git -import paramiko -import yaml - -from . import _, common +from . import _ +from . import common from .exception import VCSException # hard coded defaults for Android ~/.android/debug.keystore files diff --git a/fdroidserver/publish.py b/fdroidserver/publish.py index 42945166..4c0bd791 100644 --- a/fdroidserver/publish.py +++ b/fdroidserver/publish.py @@ -28,21 +28,23 @@ mostly reports success by moving an APK from unsigned/ to repo/ """ -import glob -import hashlib -import json -import logging +import sys import os import re import shutil -import sys -import time -import zipfile +import glob +import hashlib from argparse import ArgumentParser from collections import OrderedDict +import logging from gettext import ngettext +import json +import time +import zipfile -from . import _, common, metadata +from . import _ +from . import common +from . import metadata from .common import FDroidPopen from .exception import BuildException, FDroidException diff --git a/fdroidserver/readmeta.py b/fdroidserver/readmeta.py index b3ef7c3b..b8049a9f 100644 --- a/fdroidserver/readmeta.py +++ b/fdroidserver/readmeta.py @@ -17,8 +17,8 @@ # along with this program. If not, see . from argparse import ArgumentParser - -from . import common, metadata +from . import common +from . import metadata def main(): diff --git a/fdroidserver/rewritemeta.py b/fdroidserver/rewritemeta.py index 4bbe810d..9f3316b4 100644 --- a/fdroidserver/rewritemeta.py +++ b/fdroidserver/rewritemeta.py @@ -17,14 +17,16 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import io -import logging -import shutil -import tempfile from argparse import ArgumentParser +import logging +import io +import tempfile +import shutil from pathlib import Path -from . import _, common, metadata +from . import _ +from . import common +from . import metadata config = None diff --git a/fdroidserver/signatures.py b/fdroidserver/signatures.py index 00c9d264..486e5d18 100644 --- a/fdroidserver/signatures.py +++ b/fdroidserver/signatures.py @@ -15,13 +15,15 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import logging -import os -import re -import sys from argparse import ArgumentParser -from . import _, common +import re +import os +import sys +import logging + +from . import _ +from . import common from .exception import FDroidException diff --git a/fdroidserver/signindex.py b/fdroidserver/signindex.py index 47cd5ec2..4ca2d569 100644 --- a/fdroidserver/signindex.py +++ b/fdroidserver/signindex.py @@ -17,13 +17,15 @@ # along with this program. If not, see . import json -import logging import os import time import zipfile from argparse import ArgumentParser +import logging -from . import _, common, metadata +from . import _ +from . import common +from . import metadata from .exception import FDroidException config = None diff --git a/fdroidserver/tail.py b/fdroidserver/tail.py index 2bea3504..8107f10d 100644 --- a/fdroidserver/tail.py +++ b/fdroidserver/tail.py @@ -28,8 +28,8 @@ Example import os import sys -import threading import time +import threading class Tail(object): diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 6af82ab2..71d32952 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -20,27 +20,26 @@ # along with this program. If not, see . import argparse -import copy import filecmp -import glob -import hashlib -import json -import logging -import os -import re -import shutil -import socket import sys -import time +import os +import shutil +import glob +import logging +import re +import socket import warnings import zipfile -from argparse import ArgumentParser -from datetime import datetime, timezone -from pathlib import Path - +import hashlib +import json +import time +import yaml +import copy import asn1crypto.cms import defusedxml.ElementTree as ElementTree -import yaml +from datetime import datetime, timezone +from argparse import ArgumentParser +from pathlib import Path try: from yaml import CSafeLoader as SafeLoader @@ -50,13 +49,14 @@ except ImportError: import collections from binascii import hexlify -from PIL import Image, PngImagePlugin - -import fdroidserver.index - -from . import _, common, metadata +from . import _ +from . import common +from . import metadata from .common import DEFAULT_LOCALE from .exception import BuildException, FDroidException, VerificationException +import fdroidserver.index + +from PIL import Image, PngImagePlugin if hasattr(Image, 'DecompressionBombWarning'): warnings.simplefilter('error', Image.DecompressionBombWarning) diff --git a/fdroidserver/verify.py b/fdroidserver/verify.py index 897463ae..46963bb4 100644 --- a/fdroidserver/verify.py +++ b/fdroidserver/verify.py @@ -16,17 +16,18 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import sys +import os import glob import json import logging -import os -import sys +import requests from argparse import ArgumentParser from collections import OrderedDict -import requests - -from . import _, common, net +from . import _ +from . import common +from . import net from .exception import FDroidException config = None @@ -57,8 +58,8 @@ def _add_diffoscope_info(d): ] d['diffoscope']['External-Tools-Required'] = external_tools - from diffoscope.external_tools import EXTERNAL_TOOLS from diffoscope.tools import OS_NAMES, get_current_os + from diffoscope.external_tools import EXTERNAL_TOOLS current_os = get_current_os() os_list = [current_os] if (current_os in OS_NAMES) else iter(OS_NAMES) diff --git a/fdroidserver/vmtools.py b/fdroidserver/vmtools.py index 2ba92ad6..0251e179 100644 --- a/fdroidserver/vmtools.py +++ b/fdroidserver/vmtools.py @@ -16,17 +16,17 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import json -import logging +from os.path import isdir, isfile, basename, abspath, expanduser import os +import json import shutil import subprocess import textwrap -import threading -from os.path import abspath, basename, expanduser, isdir, isfile - +import logging from .common import FDroidException +import threading + lock = threading.Lock() diff --git a/locale/pick-complete-translations.py b/locale/pick-complete-translations.py index be11426c..8c4d377b 100755 --- a/locale/pick-complete-translations.py +++ b/locale/pick-complete-translations.py @@ -2,13 +2,13 @@ # # add completed translations from weblate to MANIFEST.in +import git import json import os import re +import requests import subprocess -import git -import requests projectbasedir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) localedir = os.path.join(projectbasedir, 'locale') diff --git a/tests/dump_internal_metadata_format.py b/tests/dump_internal_metadata_format.py index ffc72059..f9763ebc 100755 --- a/tests/dump_internal_metadata_format.py +++ b/tests/dump_internal_metadata_format.py @@ -25,6 +25,7 @@ import sys from argparse import ArgumentParser import git + import yaml localmodule = os.path.realpath( diff --git a/tests/extra/manual-vmtools-test.py b/tests/extra/manual-vmtools-test.py index 2f01c9ff..0f0c745b 100755 --- a/tests/extra/manual-vmtools-test.py +++ b/tests/extra/manual-vmtools-test.py @@ -4,12 +4,12 @@ # that run in the buildserver setup. It is not really maintained, but # is still here as a kind of reference. -import inspect -import logging import os import sys -import tempfile +import logging import textwrap +import tempfile +import inspect from argparse import ArgumentParser localmodule = os.path.realpath( diff --git a/tests/get-country-region-data.py b/tests/get-country-region-data.py index 240d70b2..f0f52e4b 100755 --- a/tests/get-country-region-data.py +++ b/tests/get-country-region-data.py @@ -5,11 +5,10 @@ import collections import os import re -import sys -import tempfile - import requests import requests_cache +import sys +import tempfile def main(): diff --git a/tests/gradle-release-checksums.py b/tests/gradle-release-checksums.py index 53ceb1a5..8bdd15a0 100755 --- a/tests/gradle-release-checksums.py +++ b/tests/gradle-release-checksums.py @@ -2,13 +2,13 @@ import os import re +import requests import subprocess import sys - -import requests from colorama import Fore, Style from packaging.version import Version + checksums = None versions = dict() diff --git a/tests/key-tricks.py b/tests/key-tricks.py index a01bf0bf..7fc0f3ea 100755 --- a/tests/key-tricks.py +++ b/tests/key-tricks.py @@ -1,10 +1,9 @@ #!/usr/bin/env python3 import os +import fdroidserver import shutil import sys - -import fdroidserver from fdroidserver import common, nightly if os.getenv('CI') is None: diff --git a/tests/openssl-version-check-test.py b/tests/openssl-version-check-test.py index 69a1ff59..d4022126 100755 --- a/tests/openssl-version-check-test.py +++ b/tests/openssl-version-check-test.py @@ -6,7 +6,6 @@ # This is used in update.has_known_vulnerability() import re - import requests # this list was generated using: diff --git a/tests/shared_test_code.py b/tests/shared_test_code.py index 3e34900b..59f515a7 100644 --- a/tests/shared_test_code.py +++ b/tests/shared_test_code.py @@ -20,8 +20,10 @@ import sys import tempfile import unittest import unittest.mock + from pathlib import Path + GP_FINGERPRINT = 'B7C2EEFD8DAC7806AF67DFCD92EB18126BC08312A7F2D6F3862E46013C7A6135' diff --git a/tests/test_api.py b/tests/test_api.py index ba18caa6..6cb9a53b 100755 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -8,9 +8,9 @@ from unittest import mock import fdroidserver from fdroidserver import common, signindex - from .shared_test_code import GP_FINGERPRINT, mkdtemp + basedir = Path(__file__).parent diff --git a/tests/test_build.py b/tests/test_build.py index 578837ed..f7558c8c 100755 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -6,16 +6,15 @@ import sys import tempfile import textwrap import unittest +import yaml from pathlib import Path from unittest import mock -import yaml +from .shared_test_code import TmpCwd, mkdtemp import fdroidserver.build import fdroidserver.common -from .shared_test_code import TmpCwd, mkdtemp - class FakeProcess: output = 'fake output' diff --git a/tests/test_checkupdates.py b/tests/test_checkupdates.py index 107caf29..4cc76db3 100755 --- a/tests/test_checkupdates.py +++ b/tests/test_checkupdates.py @@ -1,19 +1,19 @@ #!/usr/bin/env python3 +import git import os import platform import shutil import tempfile import time import unittest -from pathlib import Path from unittest import mock - -import git +from pathlib import Path import fdroidserver import fdroidserver.checkupdates + basedir = Path(__file__).parent diff --git a/tests/test_common.py b/tests/test_common.py index de08a5d7..57cbb416 100755 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,44 +1,40 @@ #!/usr/bin/env python3 import difflib +import git import glob -import gzip import importlib import json import logging import os import re +import ruamel.yaml import shutil import subprocess import sys import tempfile -import textwrap import time import unittest +import textwrap +import gzip from argparse import ArgumentParser from datetime import datetime, timezone -from pathlib import Path -from unittest import mock from zipfile import BadZipFile, ZipFile +from unittest import mock +from pathlib import Path -import git -import ruamel.yaml import fdroidserver +import fdroidserver.signindex import fdroidserver.common import fdroidserver.metadata -import fdroidserver.signindex -from fdroidserver._yaml import config_dump, yaml, yaml_dumper +from .shared_test_code import TmpCwd, mkdtemp, mkdir_testfiles from fdroidserver.common import ANTIFEATURES_CONFIG_NAME, CATEGORIES_CONFIG_NAME -from fdroidserver.exception import ( - FDroidException, - MetaDataException, - VCSException, - VerificationException, -) +from fdroidserver._yaml import yaml, yaml_dumper, config_dump +from fdroidserver.exception import FDroidException, VCSException,\ + MetaDataException, VerificationException from fdroidserver.looseversion import LooseVersion -from .shared_test_code import TmpCwd, mkdir_testfiles, mkdtemp basedir = Path(__file__).parent @@ -2419,9 +2415,8 @@ class CommonTest(SetUpTearDownMixin, unittest.TestCase): @mock.patch('sdkmanager._generate_package_xml', lambda a, b, c: None) def test_auto_install_ndk_mock_dl(self): """Test NDK installs by actually calling sdkmanager""" - import importlib.metadata - import sdkmanager + import importlib.metadata sdkmanager_version = LooseVersion(importlib.metadata.version('sdkmanager')) if sdkmanager_version < LooseVersion('0.6.4'): diff --git a/tests/test_deploy.py b/tests/test_deploy.py index 60d157c3..b821725c 100755 --- a/tests/test_deploy.py +++ b/tests/test_deploy.py @@ -11,8 +11,7 @@ from unittest import mock import git import fdroidserver - -from .shared_test_code import TmpCwd, VerboseFalseOptions, mkdtemp +from .shared_test_code import TmpCwd, mkdtemp, VerboseFalseOptions basedir = Path(__file__).parent diff --git a/tests/test_exception.py b/tests/test_exception.py index 01a6cd46..accc6653 100755 --- a/tests/test_exception.py +++ b/tests/test_exception.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 import unittest - import fdroidserver diff --git a/tests/test_github.py b/tests/test_github.py index f30ce0bb..39514c5d 100755 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -3,9 +3,8 @@ import unittest import unittest.mock -import fdroidserver - from .shared_test_code import mock_urlopen +import fdroidserver class GithubApiTest(unittest.TestCase): diff --git a/tests/test_gpgsign.py b/tests/test_gpgsign.py index 84634874..f73b217e 100755 --- a/tests/test_gpgsign.py +++ b/tests/test_gpgsign.py @@ -5,10 +5,10 @@ import os import shutil import tempfile import unittest -from pathlib import Path -from unittest.mock import MagicMock, patch from fdroidserver import common, gpgsign +from pathlib import Path +from unittest.mock import MagicMock, patch basedir = Path(__file__).parent diff --git a/tests/test_import_subcommand.py b/tests/test_import_subcommand.py index 530e10fb..05e2c379 100755 --- a/tests/test_import_subcommand.py +++ b/tests/test_import_subcommand.py @@ -13,11 +13,11 @@ import git import requests import yaml +from .shared_test_code import TmpCwd, mkdtemp, VerboseFalseOptions + import fdroidserver import fdroidserver.import_subcommand -from .shared_test_code import TmpCwd, VerboseFalseOptions, mkdtemp - basedir = Path(__file__).parent logging.basicConfig(level=logging.DEBUG) diff --git a/tests/test_index.py b/tests/test_index.py index c8ff5cbe..b4973d79 100755 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -3,23 +3,22 @@ import copy import datetime import glob -import json import os -import shutil -import tempfile import unittest -import zipfile from pathlib import Path -from unittest.mock import patch - -import requests import yaml +import zipfile +from unittest.mock import patch +import requests +import tempfile +import json +import shutil import fdroidserver from fdroidserver import common, index, publish, signindex, update - from .shared_test_code import GP_FINGERPRINT, TmpCwd, mkdtemp + basedir = Path(__file__).parent diff --git a/tests/test_init.py b/tests/test_init.py index a038493b..179f06c7 100755 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -8,7 +8,6 @@ import unittest import fdroidserver.common import fdroidserver.init - from .shared_test_code import mkdtemp basedir = pathlib.Path(__file__).parent diff --git a/tests/test_install.py b/tests/test_install.py index aa239d4d..b4e404d5 100755 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -3,6 +3,7 @@ import os import textwrap import unittest + from pathlib import Path from unittest.mock import Mock, patch diff --git a/tests/test_integration.py b/tests/test_integration.py index 6d757b1e..76a7e82b 100755 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -18,7 +18,6 @@ except ModuleNotFoundError: from androguard.core.apk import get_apkid from fdroidserver._yaml import yaml, yaml_dumper - from .shared_test_code import mkdir_testfiles # TODO: port generic tests that use index.xml to index-v2 (test that diff --git a/tests/test_lint.py b/tests/test_lint.py index 4b5d7dfe..f0bf6b4d 100755 --- a/tests/test_lint.py +++ b/tests/test_lint.py @@ -9,13 +9,13 @@ import unittest from pathlib import Path from unittest import mock +from .shared_test_code import mkdtemp + import fdroidserver.common import fdroidserver.lint import fdroidserver.metadata from fdroidserver._yaml import config_dump -from .shared_test_code import mkdtemp - basedir = Path(__file__).parent diff --git a/tests/test_main.py b/tests/test_main.py index 68984088..50fda3e2 100755 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -2,13 +2,12 @@ import os import pkgutil -import tempfile import textwrap import unittest +import tempfile from unittest import mock import fdroidserver.__main__ - from .shared_test_code import TmpCwd, TmpPyPath diff --git a/tests/test_metadata.py b/tests/test_metadata.py index f9e2ba75..8c3f7591 100755 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -4,24 +4,23 @@ import copy import io import os import random +import ruamel.yaml import shutil +import unittest import tempfile import textwrap -import unittest from collections import OrderedDict from pathlib import Path from unittest import mock -import ruamel.yaml - import fdroidserver from fdroidserver import metadata -from fdroidserver._yaml import yaml -from fdroidserver.common import DEFAULT_LOCALE from fdroidserver.exception import MetaDataException - +from fdroidserver.common import DEFAULT_LOCALE +from fdroidserver._yaml import yaml from .shared_test_code import TmpCwd, mkdtemp + basedir = Path(__file__).parent diff --git a/tests/test_net.py b/tests/test_net.py index beacd9af..581edcfb 100755 --- a/tests/test_net.py +++ b/tests/test_net.py @@ -2,17 +2,16 @@ import os import random +import requests import socket import tempfile import threading import time import unittest -from pathlib import Path from unittest.mock import MagicMock, patch -import requests - from fdroidserver import net +from pathlib import Path class RetryServer: diff --git a/tests/test_nightly.py b/tests/test_nightly.py index fb1614b7..681df96d 100755 --- a/tests/test_nightly.py +++ b/tests/test_nightly.py @@ -2,19 +2,20 @@ import os import platform +import requests import shutil import subprocess import tempfile import time import unittest +import yaml + from pathlib import Path from unittest.mock import patch -import requests -import yaml - from fdroidserver import common, exception, index, nightly + DEBUG_KEYSTORE = '/u3+7QAAAAIAAAABAAAAAQAPYW5kcm9pZGRlYnVna2V5AAABNYhAuskAAAK8MIICuDAOBgorBgEEASoCEQEBBQAEggKkqRnFlhidQmVff83bsAeewXPIsF0jiymzJnvrnUAQtCK0MV9uZonu37Mrj/qKLn56mf6QcvEoKvpCstZxzftgYYpAHWMVLM+hy2Z707QZEHlY7Ukppt8DItj+dXkeqGt7f8KzOb2AQwDbt9lm1fJb+MefLowTaubtvrLMcKIne43CbCu2D8HyN7RPWpEkVetA2Qgr5W4sa3tIUT80afqo9jzwJjKCspuxY9A1M8EIM3/kvyLo2B9r0cuWwRjYZXJ6gmTYI2ARNz0KQnCZUok14NDg+mZTb1B7AzRfb0lfjbA6grbzuAL+WaEpO8/LgGfuOh7QBZBT498TElOaFfQ9toQWA79wAmrQCm4OoFukpPIy2m/l6VjJSmlK5Q+CMOl/Au7OG1sUUCTvPaIr0XKnsiwDJ7a71n9garnPWHkvuWapSRCzCNgaUoGQjB+fTMJFFrwT8P1aLfM6onc3KNrDStoQZuYe5ngCLlNS56bENkVGvJBfdkboxtHZjqDXXON9jWGSOI527J3o2D5sjSVyx3T9XPrsL4TA/nBtdU+c/+M6aoASZR2VymzAKdMrGfj9kE5GXp8vv2vkJj9+OJ4Jm5yeczocc/Idtojjb1yg+sq1yY8kAQxgezpY1rpgi2jF3tSN01c23DNvAaSJLJX2ZuH8sD40ACc80Y1Qp1nUTdpwBZUeaeNruBwx4PHU8GnC71FwtiUpwNs0OoSl0pgDUJ3ODC5bs8B5QmW1wu1eg7I4mMSmCsNGW6VN3sFcu+WEqnmTxPoZombdFZKxsr2oq359Nn4bJ6Uc9PBz/sXsns7Zx1vND/oK/Jv5Y269UVAMeKX/eGpfnxzagW3tqGbOu12C2p9Azo5VxiU2fG/tmk2PjaG5hV/ywReco7I6C1p8OWM2fwAAAAEABVguNTA5AAAB6TCCAeUwggFOoAMCAQICBE89gTUwDQYJKoZIhvcNAQEFBQAwNzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0FuZHJvaWQxFjAUBgNVBAMTDUFuZHJvaWQgRGVidWcwHhcNMTIwMjE2MjIyMDM3WhcNNDIwMjA4MjIyMDM3WjA3MQswCQYDVQQGEwJVUzEQMA4GA1UEChMHQW5kcm9pZDEWMBQGA1UEAxMNQW5kcm9pZCBEZWJ1ZzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA3AKU7S7JXhUjEwxWP1/LPHXieh61SaA/+xbpqsPA+yjGz1sAcGAyuG6bjNAVm56pq7nkjJzicX7Wi83nUBo58DEC/quxOLdy0C4PEOSAeTnTT1RJIwMDvOgiL1GFCErvQ7gCH6zuAID/JRFbN6nIkhDjs2DYnSBl7aJJf8wCLc0CAwEAATANBgkqhkiG9w0BAQUFAAOBgQAoq/TJffA0l+ZGf89xndmHdxrO6qi+TzSlByvLZ4eFfCovTh1iO+Edrd5V1yXGLxyyvdsadMAFZT8SaxMrP5xxhJ0nra0APWYLpA96M//auMhQBWPgqPntwgvEZuEH7f0kdItjBJ39yijbG8xfgwid6XqNUo0TDDkp/wNWKpJ9tJe+2PrGw1NAvrgSydoH2j8DI1Eq' DEBUG_KEYSTORE_KEY_FILE_NAME = ( 'debug_keystore_QW+xRCJDGHXyyFtgCW8QRajj+6uYmsLwGWpCfYqYQ5M_id_rsa' diff --git a/tests/test_publish.py b/tests/test_publish.py index 82c670d7..cb47bff5 100755 --- a/tests/test_publish.py +++ b/tests/test_publish.py @@ -15,15 +15,17 @@ import os import pathlib import shutil import sys -import tempfile import unittest +import tempfile from unittest import mock -from fdroidserver import common, metadata, publish, signatures +from fdroidserver import publish +from fdroidserver import common +from fdroidserver import metadata +from fdroidserver import signatures from fdroidserver._yaml import yaml from fdroidserver.exception import FDroidException - -from .shared_test_code import VerboseFalseOptions, mkdtemp +from .shared_test_code import mkdtemp, VerboseFalseOptions basedir = pathlib.Path(__file__).parent diff --git a/tests/test_rewritemeta.py b/tests/test_rewritemeta.py index 4528f219..5ad1b94d 100755 --- a/tests/test_rewritemeta.py +++ b/tests/test_rewritemeta.py @@ -1,14 +1,13 @@ #!/usr/bin/env python3 import os +import unittest import tempfile import textwrap -import unittest from pathlib import Path from unittest import mock from fdroidserver import metadata, rewritemeta - from .shared_test_code import TmpCwd, mkdtemp basedir = Path(__file__).parent diff --git a/tests/test_scanner.py b/tests/test_scanner.py index 849476e6..d982ed4f 100755 --- a/tests/test_scanner.py +++ b/tests/test_scanner.py @@ -26,7 +26,6 @@ import fdroidserver.common import fdroidserver.exception import fdroidserver.metadata import fdroidserver.scanner - from .shared_test_code import TmpCwd, mkdtemp, mock_open_to_str basedir = pathlib.Path(__file__).parent diff --git a/tests/test_signatures.py b/tests/test_signatures.py index 4f7bd105..603ddf2c 100755 --- a/tests/test_signatures.py +++ b/tests/test_signatures.py @@ -6,9 +6,8 @@ import sys import unittest from tempfile import TemporaryDirectory -from fdroidserver import common, signatures - from .shared_test_code import TmpCwd +from fdroidserver import common, signatures basedir = os.path.dirname(__file__) diff --git a/tests/test_signindex.py b/tests/test_signindex.py index 21d54585..149afb24 100755 --- a/tests/test_signindex.py +++ b/tests/test_signindex.py @@ -6,10 +6,10 @@ import shutil import subprocess import tempfile import unittest -from pathlib import Path -from unittest.mock import patch from fdroidserver import apksigcopier, common, exception, signindex, update +from pathlib import Path +from unittest.mock import patch class Options: diff --git a/tests/test_update.py b/tests/test_update.py index 10f9cc8b..468cd813 100755 --- a/tests/test_update.py +++ b/tests/test_update.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import copy +import git import glob import hashlib import json @@ -11,18 +12,16 @@ import shutil import string import subprocess import sys -import textwrap import time import unittest +import yaml import zipfile +import textwrap from binascii import hexlify from datetime import datetime from pathlib import Path from unittest import mock -import git -import yaml - try: # these were moved in androguard 4.0 from androguard.core.apk import APK @@ -45,16 +44,15 @@ except ImportError: except ImportError: from yaml import Loader as FullLoader -from PIL import PngImagePlugin - import fdroidserver.common import fdroidserver.exception import fdroidserver.metadata import fdroidserver.update from fdroidserver.common import CATEGORIES_CONFIG_NAME from fdroidserver.looseversion import LooseVersion - from .shared_test_code import TmpCwd, mkdtemp +from PIL import PngImagePlugin + DONATION_FIELDS = ('Donate', 'Liberapay', 'OpenCollective') diff --git a/tests/test_vcs.py b/tests/test_vcs.py index a007feae..2b640a9e 100755 --- a/tests/test_vcs.py +++ b/tests/test_vcs.py @@ -7,8 +7,7 @@ from git import Repo import fdroidserver.common import fdroidserver.metadata - -from .shared_test_code import VerboseFalseOptions, mkdtemp +from .shared_test_code import mkdtemp, VerboseFalseOptions class VCSTest(unittest.TestCase): diff --git a/tests/test_verify.py b/tests/test_verify.py index e5a2f7c4..f9da9092 100755 --- a/tests/test_verify.py +++ b/tests/test_verify.py @@ -6,11 +6,13 @@ import shutil import sys import tempfile import unittest + from pathlib import Path from unittest.mock import patch from fdroidserver import verify + TEST_APP_ENTRY = { "1539780240.3885746": { "local": {