From 8cd1c84e97b999f7afba07b7a9d6b5b0091a7457 Mon Sep 17 00:00:00 2001 From: hubobel Date: Fri, 25 Feb 2022 16:33:33 +0100 Subject: [PATCH] =?UTF-8?q?Vorlage=20f=C3=BCr=20Integration=20in=20anderen?= =?UTF-8?q?=20Code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zugangsdaten.py | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/Zugangsdaten.py b/Zugangsdaten.py index cca0c65..1999865 100644 --- a/Zugangsdaten.py +++ b/Zugangsdaten.py @@ -1,20 +1,34 @@ import json import os import sys -conf = os.path.basename(sys.argv[0]) -conf = conf.replace(".py", ".conf") -if os.path.isfile(conf) is False: - print(conf + ' scheint es nicht zu geben.') - print('Ich lege eine neue Datei '+ conf + ' an.') - passw={"mail_pass": "","mail_user": "", - "mail_host": "", - "mail_folder": "", - "Chat_ID": "","TOKEN": "" - } - print(str(conf)+ ' bitte entsprechend befüllen.') - with open(conf, 'w') as fp: +appname = os.path.basename(sys.argv[0]) +appname = appname.replace(".py", ".conf") +absFilePath = os.path.abspath(__file__) +absFilePath = absFilePath.replace(".py", ".conf") + + +if os.path.isfile(absFilePath) is False: + print(appname + ' scheint es nicht zu geben.') + print('Ich lege eine neue Datei ' + appname + ' an.') + passw={'mail': + { + "mail_pass": "", + "mail_user": "", + "mail_host": "", + "mail_folder": "" + }, + 'Telegram': + { + "Chat_ID": "322673713", + "TOKEN": "680737840:AAEaa7Vxl_kZz_LWS1_S-lH6Eda7HXqu6Y4" + } + } + + + print(str(appname) + ' bitte entsprechend befüllen.') + with open(absFilePath, 'w') as fp: json.dump(passw, fp, sort_keys=True, indent=4) quit() else: - with open(conf) as file: - passw = json.load(file) \ No newline at end of file + with open(absFilePath) as file: + passw = json.load(file)