From 414001bd1edb5df431df96b79824aa36db4a4601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 13 Jan 2021 17:45:56 +0100 Subject: [PATCH] trivial: apply black --- nginx/snippets/build-publik-snippets.py | 14 +++++++++++-- publik-cluster-link | 28 +++++++++++++------------ publik-create-databases | 15 ++++++++----- publik-create-users | 22 +++++++++++-------- publik-emailconf | 2 +- 5 files changed, 51 insertions(+), 30 deletions(-) diff --git a/nginx/snippets/build-publik-snippets.py b/nginx/snippets/build-publik-snippets.py index e4c0d95..57de2c1 100755 --- a/nginx/snippets/build-publik-snippets.py +++ b/nginx/snippets/build-publik-snippets.py @@ -5,8 +5,18 @@ from jinja2 import Environment, FileSystemLoader, __version__, StrictUndefined assert version.parse(__version__) < version.parse('2.11') TEMPLATE = 'publik-application.conf.j2' -MODULES = ('authentic2-multitenant', 'bijoe', 'chrono', 'combo', 'corbo', - 'fargo', 'hobo', 'mandayejs', 'passerelle', 'welco') +MODULES = ( + 'authentic2-multitenant', + 'bijoe', + 'chrono', + 'combo', + 'corbo', + 'fargo', + 'hobo', + 'mandayejs', + 'passerelle', + 'welco', +) for module in MODULES: loader = FileSystemLoader('.') diff --git a/publik-cluster-link b/publik-cluster-link index 1212509..e7bab48 100755 --- a/publik-cluster-link +++ b/publik-cluster-link @@ -6,17 +6,19 @@ import shutil import os -briques = ['authentic2-multitenant', - 'bijoe', - 'chrono', - 'combo', - 'corbo', - 'fargo', - 'hobo', - 'mandayejs', - 'passerelle', - 'wcs', - 'welco'] +briques = [ + 'authentic2-multitenant', + 'bijoe', + 'chrono', + 'combo', + 'corbo', + 'fargo', + 'hobo', + 'mandayejs', + 'passerelle', + 'wcs', + 'welco', +] def link(application, basepath): @@ -65,7 +67,7 @@ if __name__ == '__main__': basepath = args.basepath if not os.path.isdir(basepath): - raise(Exception('path not found: %s' % basepath)) + raise (Exception('path not found: %s' % basepath)) if application == 'all': for app in briques: @@ -74,4 +76,4 @@ if __name__ == '__main__': if application in briques: link(application, basepath) else: - raise(Exception('application unknown: %s' % application)) + raise (Exception('application unknown: %s' % application)) diff --git a/publik-create-databases b/publik-create-databases index 09884ea..b77d95a 100755 --- a/publik-create-databases +++ b/publik-create-databases @@ -41,9 +41,11 @@ def write_setting(brique, host, port, password): if not os.path.isdir(settings_d): os.system('mkdir -p %s' % settings_d) with open(settings, "w") as fh: - fh.write("DATABASES['default']['HOST'] = '{host}'\n" - "DATABASES['default']['PORT'] = {port}\n" - "DATABASES['default']['PASSWORD'] = '{password}'".format(host=host, port=port, password=password)) + fh.write( + "DATABASES['default']['HOST'] = '{host}'\n" + "DATABASES['default']['PORT'] = {port}\n" + "DATABASES['default']['PASSWORD'] = '{password}'".format(host=host, port=port, password=password) + ) def main(args): @@ -57,8 +59,11 @@ def main(args): if args.password: password = "".join(random.choice(string.ascii_letters + string.digits) for _ in range(16)) run("ALTER USER \"%s\" with password '%s';" % (user, password), fake=args.fake) - run("CREATE DATABASE {} WITH OWNER = \"{}\" TEMPLATE = template0 " - "LC_COLLATE = 'fr_FR.UTF-8' LC_CTYPE = 'fr_FR.UTF-8';".format(database, user), fake=args.fake) + run( + "CREATE DATABASE {} WITH OWNER = \"{}\" TEMPLATE = template0 " + "LC_COLLATE = 'fr_FR.UTF-8' LC_CTYPE = 'fr_FR.UTF-8';".format(database, user), + fake=args.fake, + ) if extensions: for e in extensions: run("CREATE EXTENSION %s;" % e, database=database, fake=args.fake) diff --git a/publik-create-users b/publik-create-users index 4069695..b69bf0e 100755 --- a/publik-create-users +++ b/publik-create-users @@ -6,8 +6,7 @@ import subprocess userlist = { 'hobo': {'uid': '2100'}, - 'authentic-multitenant': {'uid': '2101', - 'home': '/var/lib/authentic2-multitenant'}, + 'authentic-multitenant': {'uid': '2101', 'home': '/var/lib/authentic2-multitenant'}, 'wcs': {'uid': '2102'}, 'passerelle': {'uid': '2104'}, 'combo': {'uid': '2105'}, @@ -16,8 +15,9 @@ userlist = { 'chrono': {'uid': '2108'}, 'corbo': {'uid': '2109'}, 'bijoe': {'uid': '2110'}, - 'mandayejs': {'uid': '2111'} - } + 'mandayejs': {'uid': '2111'}, +} + def run(cmd, check=True): # when dropping jessie and python3.4 support better use: @@ -28,10 +28,11 @@ def run(cmd, check=True): return (0, output) except subprocess.CalledProcessError: if check: - raise(Exception('Command failed: "{}"'.format(cmd))) + raise (Exception('Command failed: "{}"'.format(cmd))) else: return (1, None) + for user, data in userlist.items(): uid = data.get('uid') home = data.get('home', '/var/lib/%s' % user) @@ -39,15 +40,18 @@ for user, data in userlist.items(): if rc == 0: current_uid = ou.decode().split(':')[2] if current_uid != uid: - raise(Exception('{} uid does not match'.format(user))) + raise (Exception('{} uid does not match'.format(user))) else: run('addgroup --system --gid {} {}'.format(uid, user)) - rc, ou = run('getent passwd {}'.format(user), check=False) if rc == 0: uid = ou.decode().split(':')[2] if uid != uid: - raise(Exception('{} uid does not match'.format(user))) + raise (Exception('{} uid does not match'.format(user))) else: - run('adduser --disabled-password --system --uid {uid} --gecos "{user} daemon" --ingroup {user} --no-create-home --home {home} {user}'.format(user=user, uid=uid, home=home)) + run( + 'adduser --disabled-password --system --uid {uid} --gecos "{user} daemon" --ingroup {user} --no-create-home --home {home} {user}'.format( + user=user, uid=uid, home=home + ) + ) diff --git a/publik-emailconf b/publik-emailconf index faf7d15..31df353 100755 --- a/publik-emailconf +++ b/publik-emailconf @@ -25,7 +25,7 @@ for brique in briques: if not os.path.isdir('/etc/%s' % brique): continue - settings_d ='/etc/%s/settings.d' % brique + settings_d = '/etc/%s/settings.d' % brique if not os.path.isdir(settings_d): os.mkdir(settings_d)