diff options
| author | Alexis M <alexis@notmyidea.org> | 2019-10-11 20:20:13 +0200 |
|---|---|---|
| committer | Alexis Metaireau <alexis@notmyidea.org> | 2019-10-14 21:20:38 +0200 |
| commit | f260a2c9e7b2f34d49ef4c2e50ce83a2361cf343 (patch) | |
| tree | dedf02275cb089fb2d954a668de6f8eff794036a /ihatemoney/manage.py | |
| parent | f2a0b9f3f0e24617f698ce74943cdabdea01431e (diff) | |
| download | ihatemoney-mirror-f260a2c9e7b2f34d49ef4c2e50ce83a2361cf343.zip ihatemoney-mirror-f260a2c9e7b2f34d49ef4c2e50ce83a2361cf343.tar.gz ihatemoney-mirror-f260a2c9e7b2f34d49ef4c2e50ce83a2361cf343.tar.bz2 | |
Use black to refomat the files.
Diffstat (limited to 'ihatemoney/manage.py')
| -rwxr-xr-x | ihatemoney/manage.py | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/ihatemoney/manage.py b/ihatemoney/manage.py index 8e73bc9..6343ee7 100755 --- a/ihatemoney/manage.py +++ b/ihatemoney/manage.py @@ -19,42 +19,51 @@ class GeneratePasswordHash(Command): """Get password from user and hash it without printing it in clear text.""" def run(self): - password = getpass.getpass(prompt='Password: ') + password = getpass.getpass(prompt="Password: ") print(generate_password_hash(password)) class GenerateConfig(Command): def get_options(self): return [ - Option('config_file', choices=[ - 'ihatemoney.cfg', - 'apache-vhost.conf', - 'gunicorn.conf.py', - 'supervisord.conf', - 'nginx.conf', - ]), + Option( + "config_file", + choices=[ + "ihatemoney.cfg", + "apache-vhost.conf", + "gunicorn.conf.py", + "supervisord.conf", + "nginx.conf", + ], + ) ] @staticmethod def gen_secret_key(): - return ''.join([ - random.SystemRandom().choice( - 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') - for i in range(50)]) + return "".join( + [ + random.SystemRandom().choice( + "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)" + ) + for i in range(50) + ] + ) def run(self, config_file): - env = create_jinja_env('conf-templates', strict_rendering=True) - template = env.get_template('%s.j2' % config_file) + env = create_jinja_env("conf-templates", strict_rendering=True) + template = env.get_template("%s.j2" % config_file) bin_path = os.path.dirname(sys.executable) pkg_path = os.path.abspath(os.path.dirname(__file__)) - print(template.render( + print( + template.render( pkg_path=pkg_path, bin_path=bin_path, sys_prefix=sys.prefix, secret_key=self.gen_secret_key(), - )) + ) + ) class DeleteProject(Command): @@ -65,14 +74,14 @@ class DeleteProject(Command): def main(): - QUIET_COMMANDS = ('generate_password_hash', 'generate-config') + QUIET_COMMANDS = ("generate_password_hash", "generate-config") exception = None backup_stderr = sys.stderr # Hack to divert stderr for commands generating content to stdout # to avoid confusing the user if len(sys.argv) > 1 and sys.argv[1] in QUIET_COMMANDS: - sys.stderr = open(os.devnull, 'w') + sys.stderr = open(os.devnull, "w") try: app = create_app() @@ -87,12 +96,12 @@ def main(): raise exception manager = Manager(app) - manager.add_command('db', MigrateCommand) - manager.add_command('generate_password_hash', GeneratePasswordHash) - manager.add_command('generate-config', GenerateConfig) - manager.add_command('delete-project', DeleteProject) + manager.add_command("db", MigrateCommand) + manager.add_command("generate_password_hash", GeneratePasswordHash) + manager.add_command("generate-config", GenerateConfig) + manager.add_command("delete-project", DeleteProject) manager.run() -if __name__ == '__main__': +if __name__ == "__main__": main() |
