mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03:00
enable black on fdroidserver/signatures.py
This commit is contained in:
parent
6620bf0208
commit
2273d8203b
2 changed files with 22 additions and 11 deletions
|
|
@ -267,6 +267,7 @@ black:
|
||||||
fdroidserver/net.py
|
fdroidserver/net.py
|
||||||
fdroidserver/readmeta.py
|
fdroidserver/readmeta.py
|
||||||
fdroidserver/rewritemeta.py
|
fdroidserver/rewritemeta.py
|
||||||
|
fdroidserver/signatures.py
|
||||||
fdroidserver/signindex.py
|
fdroidserver/signindex.py
|
||||||
fdroidserver/tail.py
|
fdroidserver/tail.py
|
||||||
fdroidserver/verify.py
|
fdroidserver/verify.py
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ from .exception import FDroidException
|
||||||
|
|
||||||
|
|
||||||
def extract_signature(apkpath):
|
def extract_signature(apkpath):
|
||||||
|
|
||||||
if not os.path.exists(apkpath):
|
if not os.path.exists(apkpath):
|
||||||
raise FDroidException("file APK does not exists '{}'".format(apkpath))
|
raise FDroidException("file APK does not exists '{}'".format(apkpath))
|
||||||
if not common.verify_apk_signature(apkpath):
|
if not common.verify_apk_signature(apkpath):
|
||||||
|
|
@ -46,7 +45,6 @@ def extract_signature(apkpath):
|
||||||
|
|
||||||
|
|
||||||
def extract(options):
|
def extract(options):
|
||||||
|
|
||||||
# Create tmp dir if missing…
|
# Create tmp dir if missing…
|
||||||
tmp_dir = 'tmp'
|
tmp_dir = 'tmp'
|
||||||
if not os.path.exists(tmp_dir):
|
if not os.path.exists(tmp_dir):
|
||||||
|
|
@ -62,26 +60,38 @@ def extract(options):
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(apk):
|
if os.path.isfile(apk):
|
||||||
sigdir = extract_signature(apk)
|
sigdir = extract_signature(apk)
|
||||||
logging.info(_("Fetched signatures for '{apkfilename}' -> '{sigdir}'")
|
logging.info(
|
||||||
.format(apkfilename=apk, sigdir=sigdir))
|
_("Fetched signatures for '{apkfilename}' -> '{sigdir}'").format(
|
||||||
|
apkfilename=apk, sigdir=sigdir
|
||||||
|
)
|
||||||
|
)
|
||||||
elif httpre.match(apk):
|
elif httpre.match(apk):
|
||||||
if apk.startswith('https') or options.no_check_https:
|
if apk.startswith('https') or options.no_check_https:
|
||||||
try:
|
try:
|
||||||
tmp_apk = os.path.join(tmp_dir, 'signed.apk')
|
tmp_apk = os.path.join(tmp_dir, 'signed.apk')
|
||||||
net.download_file(apk, tmp_apk)
|
net.download_file(apk, tmp_apk)
|
||||||
sigdir = extract_signature(tmp_apk)
|
sigdir = extract_signature(tmp_apk)
|
||||||
logging.info(_("Fetched signatures for '{apkfilename}' -> '{sigdir}'")
|
logging.info(
|
||||||
.format(apkfilename=apk, sigdir=sigdir))
|
_(
|
||||||
|
"Fetched signatures for '{apkfilename}' -> '{sigdir}'"
|
||||||
|
).format(apkfilename=apk, sigdir=sigdir)
|
||||||
|
)
|
||||||
finally:
|
finally:
|
||||||
if tmp_apk and os.path.exists(tmp_apk):
|
if tmp_apk and os.path.exists(tmp_apk):
|
||||||
os.remove(tmp_apk)
|
os.remove(tmp_apk)
|
||||||
else:
|
else:
|
||||||
logging.warning(_('refuse downloading via insecure HTTP connection '
|
logging.warning(
|
||||||
'(use HTTPS or specify --no-https-check): {apkfilename}')
|
_(
|
||||||
.format(apkfilename=apk))
|
'refuse downloading via insecure HTTP connection '
|
||||||
|
'(use HTTPS or specify --no-https-check): {apkfilename}'
|
||||||
|
).format(apkfilename=apk)
|
||||||
|
)
|
||||||
except FDroidException as e:
|
except FDroidException as e:
|
||||||
logging.warning(_("Failed fetching signatures for '{apkfilename}': {error}")
|
logging.warning(
|
||||||
.format(apkfilename=apk, error=e))
|
_("Failed fetching signatures for '{apkfilename}': {error}").format(
|
||||||
|
apkfilename=apk, error=e
|
||||||
|
)
|
||||||
|
)
|
||||||
if e.detail:
|
if e.detail:
|
||||||
logging.debug(e.detail)
|
logging.debug(e.detail)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue