added secret key config

This commit is contained in:
2019-05-01 22:06:47 +02:00
parent 6c8b44bcc0
commit ec6dc78f04
3 changed files with 27 additions and 3 deletions

20
infomentor/config.py Normal file
View File

@@ -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

View File

@@ -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.

View File

@@ -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