diff --git a/docs/source/conf.py b/docs/source/conf.py index 382d8feb..c20542de 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,6 +12,7 @@ # 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 cf6259a7..6b19cacc 100644 --- a/examples/fdroid_clean_repos.py +++ b/examples/fdroid_clean_repos.py @@ -6,7 +6,6 @@ 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 8fa81ffe..6e920a78 100644 --- a/examples/fdroid_export_keystore_to_nitrokey.py +++ b/examples/fdroid_export_keystore_to_nitrokey.py @@ -4,6 +4,7 @@ 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 435874a5..f2a16980 100644 --- a/examples/fdroid_exportkeystore.py +++ b/examples/fdroid_exportkeystore.py @@ -4,6 +4,7 @@ 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 f3c51767..cb5a895c 100644 --- a/examples/fdroid_extract_repo_pubkey.py +++ b/examples/fdroid_extract_repo_pubkey.py @@ -4,6 +4,7 @@ # 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 e4a105e2..aba6f7fa 100644 --- a/examples/fdroid_fetchsrclibs.py +++ b/examples/fdroid_fetchsrclibs.py @@ -8,6 +8,7 @@ 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 9b458103..d17a6186 100644 --- a/examples/fdroid_nitrokeyimport.py +++ b/examples/fdroid_nitrokeyimport.py @@ -1,6 +1,7 @@ #!/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 9e4c197f..c4376bd6 100644 --- a/fdroidserver/__init__.py +++ b/fdroidserver/__init__.py @@ -3,7 +3,6 @@ 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__), '..')), @@ -24,39 +23,52 @@ 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 (verify_apk_signature, - genkeystore as generate_keystore) # NOQA: E402 +from fdroidserver.common import genkeystore as generate_keystore # NOQA: E402 +from fdroidserver.common import verify_apk_signature + 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, - 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, +) +from fdroidserver.index import 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_serverwebroots, - update_serverwebroot) # NOQA: E402 +from fdroidserver.deploy import ( + update_awsbucket, + update_servergitmirrors, + update_serverwebroot, # NOQA: E402 + update_serverwebroots, +) + update_awsbucket # NOQA: B101 update_servergitmirrors # NOQA: B101 update_serverwebroots # NOQA: B101 diff --git a/fdroidserver/__main__.py b/fdroidserver/__main__.py index 14813fa1..71c39b2c 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 re -import sys +import importlib.metadata +import logging import os import pkgutil -import logging -import importlib.metadata - -import git -import fdroidserver.common -import fdroidserver.metadata -from fdroidserver import _ +import re +import sys from argparse import ArgumentError from collections import OrderedDict +import git + +import fdroidserver.common +import fdroidserver.metadata +from fdroidserver import _ COMMANDS = OrderedDict([ ("build", _("Build a package from source")), diff --git a/fdroidserver/apksigcopier.py b/fdroidserver/apksigcopier.py index 2ab0b8c4..f36de2eb 100644 --- a/fdroidserver/apksigcopier.py +++ b/fdroidserver/apksigcopier.py @@ -68,9 +68,18 @@ 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 df889396..7ca3ddbf 100755 --- a/fdroidserver/btlog.py +++ b/fdroidserver/btlog.py @@ -28,22 +28,21 @@ # the F-Droid client. import collections -import defusedxml.minidom -import git import glob -import os import json import logging -import requests +import os import shutil import tempfile import zipfile from argparse import ArgumentParser from typing import Optional -from . import _ -from . import common -from . import deploy +import defusedxml.minidom +import git +import requests + +from . import _, common, deploy from .exception import FDroidException diff --git a/fdroidserver/build.py b/fdroidserver/build.py index a187765b..2e716c10 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -18,31 +18,27 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import os -import shutil +import argparse import glob -import subprocess +import logging +import os import posixpath import re +import shutil +import subprocess import tarfile -import threading -import traceback -import time -import requests import tempfile -import argparse -import logging +import threading +import time +import traceback from gettext import ngettext from pathlib import Path -from . import _ -from . import common -from . import net -from . import metadata -from . import scanner -from . import vmtools +import requests + +from . import _, common, metadata, net, scanner, vmtools from .common import FDroidPopen -from .exception import FDroidException, BuildException, VCSException +from .exception import BuildException, FDroidException, VCSException try: import paramiko diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index 9ed93298..cff7bcd7 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -19,28 +19,30 @@ # along with this program. If not, see . import configparser -import git +import copy +import logging import os import re -import urllib.request -import urllib.error -import time import subprocess import sys -from argparse import ArgumentParser +import time import traceback -import logging -import copy +import urllib.error import urllib.parse +import urllib.request +from argparse import ArgumentParser from pathlib import Path from typing import Optional -from . import _ -from . import common -from . import metadata -from . import net -from .exception import VCSException, NoSubmodulesException, FDroidException, MetaDataException +import git +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 ad4df2ba..ec0079af 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -52,54 +52,58 @@ 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 time -import operator -import logging -import hashlib -import socket -import base64 -import zipfile +import sys import tempfile -import json -from pathlib import Path - -import defusedxml.ElementTree as XMLElementTree - +import time +import zipfile 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 yaml, config_dump -from fdroidserver.exception import FDroidException, VCSException, NoSubmodulesException, \ - BuildException, VerificationException, MetaDataException -from .asynchronousfilereader import AsynchronousFileReader -from .looseversion import LooseVersion +from fdroidserver._yaml import config_dump, yaml +from fdroidserver.exception import ( + BuildException, + FDroidException, + MetaDataException, + NoSubmodulesException, + VCSException, + VerificationException, +) from . import apksigcopier, common - +from .asynchronousfilereader import AsynchronousFileReader +from .looseversion import LooseVersion # The path to this fdroidserver distribution FDROID_PATH = os.path.realpath(os.path.join(os.path.dirname(__file__), '..')) @@ -2904,9 +2908,9 @@ def is_debuggable_or_testOnly(apkfile): return False try: # these were moved in androguard 4.0 - from androguard.core.axml import AXMLParser, format_value, START_TAG + from androguard.core.axml import START_TAG, AXMLParser, format_value except ImportError: - from androguard.core.bytecodes.axml import AXMLParser, format_value, START_TAG + from androguard.core.bytecodes.axml import START_TAG, AXMLParser, format_value _androguard_logging_level() with ZipFile(apkfile) as apk: @@ -2978,9 +2982,23 @@ def get_apk_id_androguard(apkfile): try: # these were moved in androguard 4.0 - from androguard.core.axml import AXMLParser, format_value, START_TAG, END_TAG, TEXT, END_DOCUMENT + from androguard.core.axml import ( + END_DOCUMENT, + END_TAG, + START_TAG, + TEXT, + AXMLParser, + format_value, + ) except ImportError: - from androguard.core.bytecodes.axml import AXMLParser, format_value, START_TAG, END_TAG, TEXT, END_DOCUMENT + from androguard.core.bytecodes.axml import ( + END_DOCUMENT, + END_TAG, + START_TAG, + TEXT, + AXMLParser, + format_value, + ) _androguard_logging_level() appid = None diff --git a/fdroidserver/deploy.py b/fdroidserver/deploy.py index cc7d6c52..b4f98f34 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 typing import Dict, List -from git import Repo -import yaml from argparse import ArgumentParser -import logging -import pathlib -import shutil +from typing import Dict, List + import git +import yaml +from git import Repo + import fdroidserver.github -from . import _ -from . import common -from . import index +from . import _, common, 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,10 @@ 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 . import net from lxml.html import fromstring + from . import net + apkfilename = os.path.basename(path) r = requests.post( 'https://androidobservatory.org/', diff --git a/fdroidserver/github.py b/fdroidserver/github.py index 0a6844d9..34a3ee53 100644 --- a/fdroidserver/github.py +++ b/fdroidserver/github.py @@ -18,8 +18,8 @@ import json import pathlib -import urllib.request import urllib.parse +import urllib.request class GithubApi: diff --git a/fdroidserver/gpgsign.py b/fdroidserver/gpgsign.py index 4ba6ebd5..4341cb36 100644 --- a/fdroidserver/gpgsign.py +++ b/fdroidserver/gpgsign.py @@ -16,14 +16,13 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import os import glob -from argparse import ArgumentParser import logging +import os import time +from argparse import ArgumentParser -from . import _ -from . import common +from . import _, common from .common import FDroidPopen from .exception import FDroidException diff --git a/fdroidserver/index.py b/fdroidserver/index.py index 86394d7c..3482f15c 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -30,6 +30,7 @@ these installed on the signing server. """ +import calendar import collections import hashlib import json @@ -41,20 +42,27 @@ 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 a5575fea..39b18c1a 100644 --- a/fdroidserver/init.py +++ b/fdroidserver/init.py @@ -19,16 +19,15 @@ # 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 _ -from . import common +from . import _, common from .exception import FDroidException config = {} diff --git a/fdroidserver/install.py b/fdroidserver/install.py index 74754520..8c1dc948 100644 --- a/fdroidserver/install.py +++ b/fdroidserver/install.py @@ -17,24 +17,21 @@ # 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 -from . import _ -from . import common, github, index, net -from .exception import FDroidException +import defusedxml.ElementTree as XMLElementTree +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 cb5ead84..f384cb62 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -24,9 +24,10 @@ import urllib.parse from argparse import ArgumentParser from pathlib import Path -from . import _, common, metadata, rewritemeta from fdroidserver._yaml import yaml +from . import _, common, metadata, rewritemeta + config = None diff --git a/fdroidserver/metadata.py b/fdroidserver/metadata.py index 47fbdca7..0d9195be 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 . -from pathlib import Path -import math -import platform -import os -import re import logging -import ruamel.yaml +import math +import os +import platform +import re from collections import OrderedDict +from pathlib import Path -from . import common -from . import _ -from .exception import MetaDataException +import ruamel.yaml + +from . import _, common from ._yaml import yaml +from .exception import MetaDataException srclibs = None warnings_action = None diff --git a/fdroidserver/mirror.py b/fdroidserver/mirror.py index 80f8394f..b06df3b1 100644 --- a/fdroidserver/mirror.py +++ b/fdroidserver/mirror.py @@ -7,13 +7,10 @@ import posixpath import socket import subprocess import sys -from argparse import ArgumentParser import urllib.parse +from argparse import ArgumentParser -from . import _ -from . import common -from . import index -from . import update +from . import _, common, index, update def _run_wget(path, urls, verbose=False): @@ -133,6 +130,7 @@ 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 1ec7d096..fe097fd5 100644 --- a/fdroidserver/net.py +++ b/fdroidserver/net.py @@ -21,10 +21,11 @@ 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 3d57c452..372390ea 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 -from . import _ -from . import common +import git +import paramiko +import yaml + +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 4c0bd791..42945166 100644 --- a/fdroidserver/publish.py +++ b/fdroidserver/publish.py @@ -28,23 +28,21 @@ mostly reports success by moving an APK from unsigned/ to repo/ """ -import sys +import glob +import hashlib +import json +import logging import os import re import shutil -import glob -import hashlib -from argparse import ArgumentParser -from collections import OrderedDict -import logging -from gettext import ngettext -import json +import sys import time import zipfile +from argparse import ArgumentParser +from collections import OrderedDict +from gettext import ngettext -from . import _ -from . import common -from . import metadata +from . import _, common, metadata from .common import FDroidPopen from .exception import BuildException, FDroidException diff --git a/fdroidserver/readmeta.py b/fdroidserver/readmeta.py index b8049a9f..b3ef7c3b 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 -from . import metadata + +from . import common, metadata def main(): diff --git a/fdroidserver/rewritemeta.py b/fdroidserver/rewritemeta.py index 9f3316b4..4bbe810d 100644 --- a/fdroidserver/rewritemeta.py +++ b/fdroidserver/rewritemeta.py @@ -17,16 +17,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from argparse import ArgumentParser -import logging import io -import tempfile +import logging import shutil +import tempfile +from argparse import ArgumentParser from pathlib import Path -from . import _ -from . import common -from . import metadata +from . import _, common, metadata config = None diff --git a/fdroidserver/signatures.py b/fdroidserver/signatures.py index 486e5d18..00c9d264 100644 --- a/fdroidserver/signatures.py +++ b/fdroidserver/signatures.py @@ -15,15 +15,13 @@ # 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 -import re -import os -import sys -import logging - -from . import _ -from . import common +from . import _, common from .exception import FDroidException diff --git a/fdroidserver/signindex.py b/fdroidserver/signindex.py index 4ca2d569..47cd5ec2 100644 --- a/fdroidserver/signindex.py +++ b/fdroidserver/signindex.py @@ -17,15 +17,13 @@ # 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 _ -from . import common -from . import metadata +from . import _, common, metadata from .exception import FDroidException config = None diff --git a/fdroidserver/tail.py b/fdroidserver/tail.py index 8107f10d..2bea3504 100644 --- a/fdroidserver/tail.py +++ b/fdroidserver/tail.py @@ -28,8 +28,8 @@ Example import os import sys -import time import threading +import time class Tail(object): diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 71d32952..6af82ab2 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -20,26 +20,27 @@ # along with this program. If not, see . import argparse +import copy import filecmp -import sys -import os -import shutil import glob -import logging -import re -import socket -import warnings -import zipfile import hashlib import json +import logging +import os +import re +import shutil +import socket +import sys import time -import yaml -import copy +import warnings +import zipfile +from argparse import ArgumentParser +from datetime import datetime, timezone +from pathlib import Path + import asn1crypto.cms import defusedxml.ElementTree as ElementTree -from datetime import datetime, timezone -from argparse import ArgumentParser -from pathlib import Path +import yaml try: from yaml import CSafeLoader as SafeLoader @@ -49,14 +50,13 @@ except ImportError: import collections from binascii import hexlify -from . import _ -from . import common -from . import metadata -from .common import DEFAULT_LOCALE -from .exception import BuildException, FDroidException, VerificationException +from PIL import Image, PngImagePlugin + import fdroidserver.index -from PIL import Image, PngImagePlugin +from . import _, common, metadata +from .common import DEFAULT_LOCALE +from .exception import BuildException, FDroidException, VerificationException if hasattr(Image, 'DecompressionBombWarning'): warnings.simplefilter('error', Image.DecompressionBombWarning) diff --git a/fdroidserver/verify.py b/fdroidserver/verify.py index 46963bb4..897463ae 100644 --- a/fdroidserver/verify.py +++ b/fdroidserver/verify.py @@ -16,18 +16,17 @@ # 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 requests +import os +import sys from argparse import ArgumentParser from collections import OrderedDict -from . import _ -from . import common -from . import net +import requests + +from . import _, common, net from .exception import FDroidException config = None @@ -58,8 +57,8 @@ def _add_diffoscope_info(d): ] d['diffoscope']['External-Tools-Required'] = external_tools - from diffoscope.tools import OS_NAMES, get_current_os from diffoscope.external_tools import EXTERNAL_TOOLS + from diffoscope.tools import OS_NAMES, get_current_os 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 0251e179..2ba92ad6 100644 --- a/fdroidserver/vmtools.py +++ b/fdroidserver/vmtools.py @@ -16,16 +16,16 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from os.path import isdir, isfile, basename, abspath, expanduser -import os import json +import logging +import os import shutil import subprocess import textwrap -import logging -from .common import FDroidException - import threading +from os.path import abspath, basename, expanduser, isdir, isfile + +from .common import FDroidException lock = threading.Lock() diff --git a/locale/pick-complete-translations.py b/locale/pick-complete-translations.py index 8c4d377b..be11426c 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 f9763ebc..ffc72059 100755 --- a/tests/dump_internal_metadata_format.py +++ b/tests/dump_internal_metadata_format.py @@ -25,7 +25,6 @@ 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 0f0c745b..2f01c9ff 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 logging -import textwrap import tempfile -import inspect +import textwrap 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 f0f52e4b..240d70b2 100755 --- a/tests/get-country-region-data.py +++ b/tests/get-country-region-data.py @@ -5,11 +5,12 @@ import collections import os import re -import requests -import requests_cache import sys import tempfile +import requests +import requests_cache + def main(): # we want all the data diff --git a/tests/gradle-release-checksums.py b/tests/gradle-release-checksums.py index 8bdd15a0..53ceb1a5 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 7fc0f3ea..a01bf0bf 100755 --- a/tests/key-tricks.py +++ b/tests/key-tricks.py @@ -1,9 +1,10 @@ #!/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 d4022126..69a1ff59 100755 --- a/tests/openssl-version-check-test.py +++ b/tests/openssl-version-check-test.py @@ -6,6 +6,7 @@ # 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 59f515a7..3e34900b 100644 --- a/tests/shared_test_code.py +++ b/tests/shared_test_code.py @@ -20,10 +20,8 @@ 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 6cb9a53b..ba18caa6 100755 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -8,8 +8,8 @@ from unittest import mock import fdroidserver from fdroidserver import common, signindex -from .shared_test_code import GP_FINGERPRINT, mkdtemp +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 f7558c8c..578837ed 100755 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -6,15 +6,16 @@ import sys import tempfile import textwrap import unittest -import yaml from pathlib import Path from unittest import mock -from .shared_test_code import TmpCwd, mkdtemp +import yaml 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 4cc76db3..107caf29 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 unittest import mock from pathlib import Path +from unittest import mock + +import git import fdroidserver import fdroidserver.checkupdates - basedir = Path(__file__).parent diff --git a/tests/test_common.py b/tests/test_common.py index 57cbb416..de08a5d7 100755 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -1,40 +1,44 @@ #!/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 zipfile import BadZipFile, ZipFile -from unittest import mock from pathlib import Path +from unittest import mock +from zipfile import BadZipFile, ZipFile +import git +import ruamel.yaml import fdroidserver -import fdroidserver.signindex import fdroidserver.common import fdroidserver.metadata -from .shared_test_code import TmpCwd, mkdtemp, mkdir_testfiles +import fdroidserver.signindex +from fdroidserver._yaml import config_dump, yaml, yaml_dumper from fdroidserver.common import ANTIFEATURES_CONFIG_NAME, CATEGORIES_CONFIG_NAME -from fdroidserver._yaml import yaml, yaml_dumper, config_dump -from fdroidserver.exception import FDroidException, VCSException,\ - MetaDataException, VerificationException +from fdroidserver.exception import ( + FDroidException, + MetaDataException, + VCSException, + VerificationException, +) from fdroidserver.looseversion import LooseVersion +from .shared_test_code import TmpCwd, mkdir_testfiles, mkdtemp basedir = Path(__file__).parent @@ -2415,9 +2419,10 @@ 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 sdkmanager import importlib.metadata + import sdkmanager + sdkmanager_version = LooseVersion(importlib.metadata.version('sdkmanager')) if sdkmanager_version < LooseVersion('0.6.4'): raise unittest.SkipTest('needs fdroid sdkmanager >= 0.6.4') diff --git a/tests/test_deploy.py b/tests/test_deploy.py index b821725c..60d157c3 100755 --- a/tests/test_deploy.py +++ b/tests/test_deploy.py @@ -11,7 +11,8 @@ from unittest import mock import git import fdroidserver -from .shared_test_code import TmpCwd, mkdtemp, VerboseFalseOptions + +from .shared_test_code import TmpCwd, VerboseFalseOptions, mkdtemp basedir = Path(__file__).parent diff --git a/tests/test_exception.py b/tests/test_exception.py index accc6653..01a6cd46 100755 --- a/tests/test_exception.py +++ b/tests/test_exception.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import unittest + import fdroidserver diff --git a/tests/test_github.py b/tests/test_github.py index 39514c5d..f30ce0bb 100755 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -3,9 +3,10 @@ import unittest import unittest.mock -from .shared_test_code import mock_urlopen import fdroidserver +from .shared_test_code import mock_urlopen + class GithubApiTest(unittest.TestCase): def test__init(self): diff --git a/tests/test_gpgsign.py b/tests/test_gpgsign.py index f73b217e..84634874 100755 --- a/tests/test_gpgsign.py +++ b/tests/test_gpgsign.py @@ -5,11 +5,11 @@ import os import shutil import tempfile import unittest - -from fdroidserver import common, gpgsign from pathlib import Path from unittest.mock import MagicMock, patch +from fdroidserver import common, gpgsign + basedir = Path(__file__).parent diff --git a/tests/test_import_subcommand.py b/tests/test_import_subcommand.py index 05e2c379..530e10fb 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 b4973d79..c8ff5cbe 100755 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -3,21 +3,22 @@ import copy import datetime import glob -import os -import unittest -from pathlib import Path -import yaml -import zipfile -from unittest.mock import patch -import requests -import tempfile 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 fdroidserver from fdroidserver import common, index, publish, signindex, update -from .shared_test_code import GP_FINGERPRINT, TmpCwd, mkdtemp +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 179f06c7..a038493b 100755 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -8,6 +8,7 @@ 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 b4e404d5..aa239d4d 100755 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -3,7 +3,6 @@ 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 76a7e82b..6d757b1e 100755 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -18,6 +18,7 @@ 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 f0bf6b4d..4b5d7dfe 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 50fda3e2..68984088 100755 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -2,12 +2,13 @@ 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 8c3f7591..f9e2ba75 100755 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -4,22 +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.exception import MetaDataException -from fdroidserver.common import DEFAULT_LOCALE from fdroidserver._yaml import yaml -from .shared_test_code import TmpCwd, mkdtemp +from fdroidserver.common import DEFAULT_LOCALE +from fdroidserver.exception import MetaDataException +from .shared_test_code import TmpCwd, mkdtemp basedir = Path(__file__).parent diff --git a/tests/test_net.py b/tests/test_net.py index 581edcfb..beacd9af 100755 --- a/tests/test_net.py +++ b/tests/test_net.py @@ -2,16 +2,17 @@ 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 681df96d..fb1614b7 100755 --- a/tests/test_nightly.py +++ b/tests/test_nightly.py @@ -2,19 +2,18 @@ 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 -from fdroidserver import common, exception, index, nightly +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 = ( diff --git a/tests/test_publish.py b/tests/test_publish.py index cb47bff5..82c670d7 100755 --- a/tests/test_publish.py +++ b/tests/test_publish.py @@ -15,17 +15,15 @@ import os import pathlib import shutil import sys -import unittest import tempfile +import unittest from unittest import mock -from fdroidserver import publish -from fdroidserver import common -from fdroidserver import metadata -from fdroidserver import signatures +from fdroidserver import common, metadata, publish, signatures from fdroidserver._yaml import yaml from fdroidserver.exception import FDroidException -from .shared_test_code import mkdtemp, VerboseFalseOptions + +from .shared_test_code import VerboseFalseOptions, mkdtemp basedir = pathlib.Path(__file__).parent diff --git a/tests/test_rewritemeta.py b/tests/test_rewritemeta.py index 5ad1b94d..4528f219 100755 --- a/tests/test_rewritemeta.py +++ b/tests/test_rewritemeta.py @@ -1,13 +1,14 @@ #!/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 d982ed4f..849476e6 100755 --- a/tests/test_scanner.py +++ b/tests/test_scanner.py @@ -26,6 +26,7 @@ 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 603ddf2c..4f7bd105 100755 --- a/tests/test_signatures.py +++ b/tests/test_signatures.py @@ -6,9 +6,10 @@ import sys import unittest from tempfile import TemporaryDirectory -from .shared_test_code import TmpCwd from fdroidserver import common, signatures +from .shared_test_code import TmpCwd + basedir = os.path.dirname(__file__) diff --git a/tests/test_signindex.py b/tests/test_signindex.py index 149afb24..21d54585 100755 --- a/tests/test_signindex.py +++ b/tests/test_signindex.py @@ -6,11 +6,11 @@ import shutil import subprocess import tempfile import unittest - -from fdroidserver import apksigcopier, common, exception, signindex, update from pathlib import Path from unittest.mock import patch +from fdroidserver import apksigcopier, common, exception, signindex, update + class Options: allow_disabled_algorithms = False diff --git a/tests/test_update.py b/tests/test_update.py index 468cd813..10f9cc8b 100755 --- a/tests/test_update.py +++ b/tests/test_update.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 import copy -import git import glob import hashlib import json @@ -12,16 +11,18 @@ 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 @@ -44,15 +45,16 @@ 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 +from .shared_test_code import TmpCwd, mkdtemp DONATION_FIELDS = ('Donate', 'Liberapay', 'OpenCollective') diff --git a/tests/test_vcs.py b/tests/test_vcs.py index 2b640a9e..a007feae 100755 --- a/tests/test_vcs.py +++ b/tests/test_vcs.py @@ -7,7 +7,8 @@ from git import Repo import fdroidserver.common import fdroidserver.metadata -from .shared_test_code import mkdtemp, VerboseFalseOptions + +from .shared_test_code import VerboseFalseOptions, mkdtemp class VCSTest(unittest.TestCase): diff --git a/tests/test_verify.py b/tests/test_verify.py index f9da9092..e5a2f7c4 100755 --- a/tests/test_verify.py +++ b/tests/test_verify.py @@ -6,13 +6,11 @@ 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": {