From ec6dc78f043a818c1afbf38bec87e04cb831eb2a Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Wed, 1 May 2019 22:06:47 +0200 Subject: [PATCH] added secret key config --- infomentor/config.py | 20 ++++++++++++++++++++ infomentor/informer.py | 5 +++-- infomentor/model.py | 5 ++++- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 infomentor/config.py diff --git a/infomentor/config.py b/infomentor/config.py new file mode 100644 index 0000000..0ae0d7f --- /dev/null +++ b/infomentor/config.py @@ -0,0 +1,20 @@ +import configparser +import os + +_config = None + +def load(): + global _config + if _config is None: + _config = configparser.ConfigParser() + if not os.path.isfile('infomentor.ini'): + _config.add_section('pushover') + _config.add_section('general') + _config['pushover']['apikey'] = '' + _config['general']['secretkey'] = '' + with open('infomentor.ini', 'w+') as f: + _config.write(f) + _config.read('infomentor.ini') + return _config + + diff --git a/infomentor/informer.py b/infomentor/informer.py index 60c5852..6dbbe8d 100755 --- a/infomentor/informer.py +++ b/infomentor/informer.py @@ -1,4 +1,4 @@ -from infomentor import model, db, icloudcalendar +from infomentor import model, db, icloudcalendar, config import logging import uuid import os @@ -8,7 +8,8 @@ import datetime import math import pushover from icalendar import Event, vDate, Calendar -pushover.init('***REMOVED***') +cfg = config.load() +pushover.init(cfg['pushover']['apikey'] ) class Informer(object): '''The Logic part of the infomentor notifier. diff --git a/infomentor/model.py b/infomentor/model.py index 7714d9d..770faad 100755 --- a/infomentor/model.py +++ b/infomentor/model.py @@ -5,10 +5,13 @@ from Crypto.Cipher import AES import base64 import enum import hashlib +from infomentor import config + +cfg = config.load() ModelBase = declarative_base() -_PASSWORD_SECRET_KEY = '***REMOVED***' +_PASSWORD_SECRET_KEY = cfg['general']['secretkey'] BS = 16 def pad(s): diff = BS - len(s) % BS