From fc147deb89a23c79935df7e41b4412facc931c6a Mon Sep 17 00:00:00 2001 From: Anon Date: Sat, 8 Oct 2022 17:38:11 -0700 Subject: [PATCH] Added support for keyfiles --- src/create_app.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/create_app.py b/src/create_app.py index 17ce757..ea2d7f8 100755 --- a/src/create_app.py +++ b/src/create_app.py @@ -115,11 +115,8 @@ def credentials_ini_fmt(k, v): def credentials_ini(label, setting): r = "[{}]\n".format(label) - dictitems = getattr(type(setting), "items", None) - if dictitems and callable(dictitems): - r += "\n".join([credentials_ini_fmt(k, v) for k, v in setting.items()]) - else: - r += credentials_ini_fmt(label, str(setting)) + for k, v in setting.items(): + r.append("{}={}\n".format(k, v)) return r @@ -133,6 +130,7 @@ def main(): epilog="", add_help=True) parser.add_argument("-c", "--config", help="Use time localization settings from a pyhton config file (omit the .py extension)", default=None) + parser.add_argument("-k", "--keyfile", help="Keyfile used for decryption", default=None) parser.add_argument("--plain", help="Output credentials in plain ini format", action="store_true") parser.add_argument("--minimal", help="Only print OAuth credentials, ignoring encryption settings", action="store_true") arguments = parser.parse_args() @@ -182,11 +180,15 @@ def main(): ans = _input("Do you want to encrypt your credentials? (y/n)", default("encrypt")) if ans.upper() in ("Y", "YES"): encrypt = True - salt, settings_server = encryption.settings_server_encrypt_cfg(settings_server) + salt, settings_server = encryption.settings_server_encrypt(settings_server, arguments.keyfile) settings_encrypt = OrderedDict([ ("encrypt", encrypt), ("salt", salt), + ("keyfile", arguments.keyfile) + ]) + settings_reminder = OrderedDict([ + ("settings_reminder", reminder) ]) # Credential formatting functions @@ -196,7 +198,7 @@ def main(): print("Copy to your config file!!!") print(formatted_credentials("settings_server", settings_server)) if not arguments.minimal: - print("\n{}\n".format(formatted_credentials("settings_reminder", reminder))) + print("\n{}\n".format(formatted_credentials("settings_reminder", settings_reminder))) print(formatted_credentials("settings_encrypt", settings_encrypt)) print("Success :)")