mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 06:52:39 +03:00
code formatting: black --skip-string-normalization --line-length 100
This commit is contained in:
parent
7f458f8f8c
commit
08cde5c2e6
5 changed files with 21 additions and 20 deletions
|
@ -49,9 +49,9 @@ from .exception import FDroidException
|
||||||
options = None
|
options = None
|
||||||
|
|
||||||
|
|
||||||
def make_binary_transparency_log(repodirs, btrepo='binary_transparency',
|
def make_binary_transparency_log(
|
||||||
url=None,
|
repodirs, btrepo='binary_transparency', url=None, commit_title='fdroid update'
|
||||||
commit_title='fdroid update'):
|
):
|
||||||
'''Log the indexes in a standalone git repo to serve as a "binary
|
'''Log the indexes in a standalone git repo to serve as a "binary
|
||||||
transparency" log.
|
transparency" log.
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ For more info on this idea:
|
||||||
output = json.load(fp, object_pairs_hook=collections.OrderedDict)
|
output = json.load(fp, object_pairs_hook=collections.OrderedDict)
|
||||||
with open(dest, 'w') as fp:
|
with open(dest, 'w') as fp:
|
||||||
json.dump(output, fp, indent=2)
|
json.dump(output, fp, indent=2)
|
||||||
gitrepo.index.add([repof, ])
|
gitrepo.index.add([repof])
|
||||||
for f in ('index.jar', 'index-v1.jar'):
|
for f in ('index.jar', 'index-v1.jar'):
|
||||||
repof = os.path.join(repodir, f)
|
repof = os.path.join(repodir, f)
|
||||||
if not os.path.exists(repof):
|
if not os.path.exists(repof):
|
||||||
|
@ -116,7 +116,7 @@ For more info on this idea:
|
||||||
jarout.writestr(info, jarin.read(info.filename))
|
jarout.writestr(info, jarin.read(info.filename))
|
||||||
jarout.close()
|
jarout.close()
|
||||||
jarin.close()
|
jarin.close()
|
||||||
gitrepo.index.add([repof, ])
|
gitrepo.index.add([repof])
|
||||||
|
|
||||||
output_files = []
|
output_files = []
|
||||||
for root, dirs, files in os.walk(repodir):
|
for root, dirs, files in os.walk(repodir):
|
||||||
|
@ -137,10 +137,10 @@ For more info on this idea:
|
||||||
fslogfile = os.path.join(cpdir, 'filesystemlog.json')
|
fslogfile = os.path.join(cpdir, 'filesystemlog.json')
|
||||||
with open(fslogfile, 'w') as fp:
|
with open(fslogfile, 'w') as fp:
|
||||||
json.dump(output, fp, indent=2)
|
json.dump(output, fp, indent=2)
|
||||||
gitrepo.index.add([os.path.join(repodir, 'filesystemlog.json'), ])
|
gitrepo.index.add([os.path.join(repodir, 'filesystemlog.json')])
|
||||||
|
|
||||||
for f in glob.glob(os.path.join(cpdir, '*.HTTP-headers.json')):
|
for f in glob.glob(os.path.join(cpdir, '*.HTTP-headers.json')):
|
||||||
gitrepo.index.add([os.path.join(repodir, os.path.basename(f)), ])
|
gitrepo.index.add([os.path.join(repodir, os.path.basename(f))])
|
||||||
|
|
||||||
gitrepo.index.commit(commit_title)
|
gitrepo.index.commit(commit_title)
|
||||||
|
|
||||||
|
@ -168,7 +168,8 @@ def main():
|
||||||
|
|
||||||
if not os.path.exists(options.git_repo):
|
if not os.path.exists(options.git_repo):
|
||||||
raise FDroidException(
|
raise FDroidException(
|
||||||
'"%s" does not exist! Create it, or use --git-repo' % options.git_repo)
|
'"%s" does not exist! Create it, or use --git-repo' % options.git_repo
|
||||||
|
)
|
||||||
|
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
|
|
||||||
|
@ -186,9 +187,7 @@ def main():
|
||||||
dlurl = options.url + '/' + repodir + '/' + f
|
dlurl = options.url + '/' + repodir + '/' + f
|
||||||
http_headers_file = os.path.join(gitrepodir, f + '.HTTP-headers.json')
|
http_headers_file = os.path.join(gitrepodir, f + '.HTTP-headers.json')
|
||||||
|
|
||||||
headers = {
|
headers = {'User-Agent': 'F-Droid 0.102.3'}
|
||||||
'User-Agent': 'F-Droid 0.102.3'
|
|
||||||
}
|
|
||||||
etag = None
|
etag = None
|
||||||
if os.path.exists(http_headers_file):
|
if os.path.exists(http_headers_file):
|
||||||
with open(http_headers_file) as fp:
|
with open(http_headers_file) as fp:
|
||||||
|
@ -196,7 +195,9 @@ def main():
|
||||||
|
|
||||||
r = session.head(dlurl, headers=headers, allow_redirects=False)
|
r = session.head(dlurl, headers=headers, allow_redirects=False)
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
logging.debug('HTTP Response (' + str(r.status_code) + '), did not download ' + dlurl)
|
logging.debug(
|
||||||
|
'HTTP Response (' + str(r.status_code) + '), did not download ' + dlurl
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
if etag and etag == r.headers.get('ETag'):
|
if etag and etag == r.headers.get('ETag'):
|
||||||
logging.debug('ETag matches, did not download ' + dlurl)
|
logging.debug('ETag matches, did not download ' + dlurl)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class FDroidException(Exception):
|
class FDroidException(Exception):
|
||||||
|
|
||||||
def __init__(self, value=None, detail=None):
|
def __init__(self, value=None, detail=None):
|
||||||
self.value = value
|
self.value = value
|
||||||
self.detail = detail
|
self.detail = detail
|
||||||
|
@ -22,12 +21,14 @@ class FDroidException(Exception):
|
||||||
else:
|
else:
|
||||||
ret = str(self.value)
|
ret = str(self.value)
|
||||||
if self.detail:
|
if self.detail:
|
||||||
ret += "\n==== detail begin ====\n%s\n==== detail end ====" % ''.join(self.detail).strip()
|
ret += (
|
||||||
|
"\n==== detail begin ====\n%s\n==== detail end ===="
|
||||||
|
% ''.join(self.detail).strip()
|
||||||
|
)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
class MetaDataException(Exception):
|
class MetaDataException(Exception):
|
||||||
|
|
||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,7 @@ def main():
|
||||||
sigpath = os.path.join(output_dir, sigfilename)
|
sigpath = os.path.join(output_dir, sigfilename)
|
||||||
|
|
||||||
if not os.path.exists(sigpath):
|
if not os.path.exists(sigpath):
|
||||||
gpgargs = ['gpg', '-a',
|
gpgargs = ['gpg', '-a', '--output', sigpath, '--detach-sig']
|
||||||
'--output', sigpath,
|
|
||||||
'--detach-sig']
|
|
||||||
if 'gpghome' in config:
|
if 'gpghome' in config:
|
||||||
gpgargs.extend(['--homedir', config['gpghome']])
|
gpgargs.extend(['--homedir', config['gpghome']])
|
||||||
if 'gpgkey' in config:
|
if 'gpgkey' in config:
|
||||||
|
|
|
@ -99,7 +99,8 @@ def main():
|
||||||
|
|
||||||
if 'jarsigner' not in config:
|
if 'jarsigner' not in config:
|
||||||
raise FDroidException(
|
raise FDroidException(
|
||||||
_('Java jarsigner not found! Install in standard location or set java_paths!'))
|
_('Java jarsigner not found! Install in standard location or set java_paths!')
|
||||||
|
)
|
||||||
|
|
||||||
repodirs = ['repo']
|
repodirs = ['repo']
|
||||||
if config['archive_older'] != 0:
|
if config['archive_older'] != 0:
|
||||||
|
|
|
@ -33,6 +33,7 @@ import threading
|
||||||
|
|
||||||
class Tail(object):
|
class Tail(object):
|
||||||
''' Represents a tail command. '''
|
''' Represents a tail command. '''
|
||||||
|
|
||||||
def __init__(self, tailed_file):
|
def __init__(self, tailed_file):
|
||||||
''' Initiate a Tail instance.
|
''' Initiate a Tail instance.
|
||||||
Check for file validity, assigns callback function to standard out.
|
Check for file validity, assigns callback function to standard out.
|
||||||
|
@ -95,7 +96,6 @@ class Tail(object):
|
||||||
|
|
||||||
|
|
||||||
class TailError(Exception):
|
class TailError(Exception):
|
||||||
|
|
||||||
def __init__(self, msg):
|
def __init__(self, msg):
|
||||||
self.message = msg
|
self.message = msg
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue