1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-07-04 16:30:12 +02:00

Merge branch 'pylint' into 'master'

pylint: Reenable 10 checks

See merge request fdroid/fdroidserver!1319
This commit is contained in:
Hans-Christoph Steiner 2023-03-20 16:51:40 +00:00
commit 0136872154
10 changed files with 39 additions and 20 deletions

View File

@ -134,7 +134,7 @@ def main():
sys.exit(0)
command = sys.argv[1]
if command not in COMMANDS and command not in available_plugins.keys():
if command not in COMMANDS and command not in available_plugins:
if command in ('-h', '--help'):
print_help(available_plugins=available_plugins)
sys.exit(0)

View File

@ -1007,6 +1007,9 @@ class vcs:
self.refreshed = False
self.srclib = None
def _gettags(self):
raise NotImplementedError
def repotype(self):
return None
@ -1800,7 +1803,7 @@ def parse_androidmanifests(paths, app):
if re.match(r'.*[\'"\s]{flavour}[\'"\s].*\{{.*'.format(flavour=flavour), line):
inside_required_flavour = 2
break
elif re.match(r'.*[\'"\s]{flavour}[\'"\s].*'.format(flavour=flavour), line):
if re.match(r'.*[\'"\s]{flavour}[\'"\s].*'.format(flavour=flavour), line):
inside_required_flavour = 1
break

View File

@ -33,7 +33,6 @@ import shutil
from . import _
from . import common
from . import index
from . import update
from .exception import FDroidException
config = None
@ -524,7 +523,7 @@ def upload_apk_to_android_observatory(path):
apkfilename = os.path.basename(path)
r = requests.post('https://androidobservatory.org/',
data={'q': update.sha256sum(path), 'searchby': 'hash'},
data={'q': common.sha256sum(path), 'searchby': 'hash'},
headers=net.HEADERS, timeout=300)
if r.status_code == 200:
# from now on XPath will be used to retrieve the message in the HTML
@ -624,7 +623,7 @@ def upload_apk_to_virustotal(virustotal_apikey, packageName, apkName, hash,
+ str(response['positives']) + ' times:'
+ '\n\t' + response['permalink'])
break
elif r.status_code == 204:
if r.status_code == 204:
logging.warning(_('virustotal.com is rate limiting, waiting to retry...'))
time.sleep(30) # wait for public API rate limiting

View File

@ -504,8 +504,8 @@ def parse_yaml_srclib(metadatapath):
cause=e)
return thisinfo
for key in data.keys():
if key not in thisinfo.keys():
for key in data:
if key not in thisinfo:
_warn_or_exception(_("Invalid srclib metadata: unknown key "
"'{key}' in '{file}'")
.format(key=key, file=metadatapath))
@ -764,6 +764,8 @@ def parse_metadata(metadatapath):
try:
commit_id = common.get_head_commit_id(git.Repo(build_dir))
logging.debug(_('Including metadata from %s@%s') % (metadata_in_repo, commit_id))
# See https://github.com/PyCQA/pylint/issues/2856 .
# pylint: disable-next=no-member
except git.exc.InvalidGitRepositoryError:
logging.debug(_('Including metadata from {path}').format(metadata_in_repo))
app_in_repo = parse_metadata(metadata_in_repo)

View File

@ -199,6 +199,7 @@ class FDroidBuildVm:
def __init__(self, srvdir):
"""Create new server class."""
self.provider = None
self.srvdir = srvdir
self.srvname = basename(srvdir) + '_default'
self.vgrntfile = os.path.join(srvdir, 'Vagrantfile')

View File

@ -91,7 +91,7 @@ with open('buildserver/Vagrantfile') as fp:
m = re.search(r"""\.vm\.box\s*=\s*["'](.*)["']""", fp.read())
if not m:
logging.error('Cannot find box name in buildserver/Vagrantfile!')
exit(1)
sys.exit(1)
config['basebox'] = m.group(1)
config['basebox_version'] = BASEBOX_VERSION_DEFAULT
config['cachedir'] = os.path.join(os.getenv('HOME'), '.cache', 'fdroidserver')
@ -107,7 +107,7 @@ elif os.path.exists('makebs.config.py'):
if show_config_deprecation:
logging.error('Config is via %s and command line flags.' % configfile)
parser.print_help()
exit(1)
sys.exit(1)
logging.debug("Vagrantfile.yaml parsed -> %s", json.dumps(config, indent=4, sort_keys=True))
@ -264,7 +264,7 @@ def main():
logging.debug('found \'vmx\' or \'svm\' in /proc/cpuinfo -> hwvirtex = \'on\'')
else:
logging.error('hwvirtex = \'on\' and no \'vmx\' or \'svm\' found in /proc/cpuinfo!')
exit(1)
sys.exit(1)
serverdir = os.path.join(os.getcwd(), 'buildserver')
logfilename = os.path.join(serverdir, 'up.log')
@ -312,7 +312,7 @@ def main():
version=config['basebox_version']))
sys.exit(1)
# verify box
if config['basebox_version'] not in BASEBOX_CHECKSUMS.keys():
if config['basebox_version'] not in BASEBOX_CHECKSUMS:
logging.critical("can not verify '{box}', "
"unknown basebox version '{version}'"
.format(box=config['basebox'],

View File

@ -31,6 +31,13 @@ disable_error_code = "no-redef, misc, arg-type"
# avoid hangs.
jobs = 4
# Minimum Python version to use for version dependent checks. Will default to the
# version used to run pylint.
py-version = "3.9"
# Files or directories to be skipped. They should be base names, not paths.
ignore = ["apksigcopier.py"]
[tool.pylint.basic]
# Good variable names which should always be accepted, separated by a comma.
good-names = ["i", "j", "k", "ex", "Run", "f", "fp"]
@ -54,17 +61,13 @@ confidence = ["HIGH", "INFERENCE"]
disable = [
"broad-exception-caught",
"broad-exception-raised",
"consider-iterating-dictionary",
"consider-using-sys-exit",
"invalid-name",
"missing-class-docstring",
"missing-function-docstring",
"missing-module-docstring",
"no-else-break",
"no-else-continue",
"no-else-raise",
"no-else-return",
"no-member",
"subprocess-run-check",
"use-dict-literal",
]

View File

@ -1,4 +1,8 @@
#!/usr/bin/env python3
#
# This script is some of the only documentation of certain processes
# that run in the buildserver setup. It is not really maintained, but
# is still here as a kind of reference.
import os
import sys
@ -17,6 +21,7 @@ if localmodule not in sys.path:
from fdroidserver.vmtools import get_build_vm
# pylint: disable=no-member
def main(args):
if args.provider != None:

View File

@ -6,6 +6,7 @@ import os
import re
import requests
import subprocess
import sys
from colorama import Fore, Style
from distutils.version import LooseVersion
@ -92,7 +93,7 @@ with open('gradlew-fdroid', 'w') as fp:
if os.getenv('CI_PROJECT_NAMESPACE') != 'fdroid':
p = subprocess.run(['git', '--no-pager', 'diff'])
print(p.stdout)
exit(errors)
sys.exit(errors)
# This only runs after commits are pushed to fdroid/fdroidserver
git_repo = git.repo.Repo('.')
@ -103,7 +104,7 @@ if git_repo.is_dirty() and ('gradlew-fdroid' in modified or 'makebuildserver' in
print(Fore.RED
+ 'ERROR: GitLab Token not found in PERSONAL_ACCESS_TOKEN!'
+ Style.RESET_ALL)
exit(1)
sys.exit(1)
branch = git_repo.create_head(os.path.basename(__file__), force=True)
branch.checkout()
@ -116,6 +117,8 @@ if git_repo.is_dirty() and ('gradlew-fdroid' in modified or 'makebuildserver' in
remote_name = 'fdroid-bot'
try:
remote = git_repo.create_remote(remote_name, url)
# See https://github.com/PyCQA/pylint/issues/2856 .
# pylint: disable-next=no-member
except git.exc.GitCommandError:
remote = git.remote.Remote(git_repo, remote_name)
remote.set_url(url)

View File

@ -7,6 +7,7 @@ import os
import re
import requests
import subprocess
import sys
from colorama import Fore, Style
@ -26,7 +27,7 @@ with open('fdroidserver/common.py') as fp:
to_compile = re.search(r'\nNDKS = [^\]]+\]', common_py).group()
if not to_compile:
exit(1)
sys.exit(1)
code = compile(to_compile, '<string>', 'exec')
config = {}
exec(code, None, config) # nosec this is just a CI script
@ -78,7 +79,7 @@ with open('fdroidserver/common.py', 'w') as fp:
if os.getenv('CI_PROJECT_NAMESPACE') != 'fdroid':
p = subprocess.run(['git', '--no-pager', 'diff'])
print(p.stdout)
exit(errors)
sys.exit(errors)
# This only runs after commits are pushed to fdroid/fdroidserver
@ -99,6 +100,8 @@ if git_repo.is_dirty() and 'fdroidserver/common.py' in modified:
remote_name = 'fdroid-bot'
try:
remote = git_repo.create_remote(remote_name, url)
# See https://github.com/PyCQA/pylint/issues/2856 .
# pylint: disable-next=no-member
except git.exc.GitCommandError:
remote = git.remote.Remote(git_repo, remote_name)
remote.set_url(url)
@ -112,7 +115,7 @@ if git_repo.is_dirty() and 'fdroidserver/common.py' in modified:
+ 'ERROR: GitLab Token not found in PERSONAL_ACCESS_TOKEN!'
+ Style.RESET_ALL
)
exit(1)
sys.exit(1)
gl = gitlab.Gitlab(
os.getenv('CI_SERVER_URL'), api_version=4, private_token=private_token
)