Compare commits

...

2 commits

2 changed files with 39 additions and 45 deletions

37
saturn/__init__.py Normal file
View file

@ -0,0 +1,37 @@
import argparse
import configparser
import logging
import locale
from pathlib import Path
from datetime import date
import caldav
from .server import create_app
from .calendar import get_davclient
parser = argparse.ArgumentParser(description='Web-based CalDav client')
parser.add_argument('-c', '--config', type=Path, default='config.ini',
help='Configuration file path')
args = parser.parse_args()
config = configparser.RawConfigParser()
config.read(args.config)
locale.setlocale(locale.LC_ALL, config.get('locale', 'locale', fallback=None))
logging.basicConfig(level=config.get('logging', 'level', fallback='WARN'))
log = logging.getLogger('saturn')
log.info('Starting saturn')
davclient = get_davclient(config['caldav'])
app = create_app(
bytes(config.get('server', 'secret_key'), 'utf-8'),
config.get('server', 'password'),
davclient,
)

View file

@ -1,47 +1,4 @@
import argparse from . import app
import configparser
import logging
import locale
## dev imports
from pprint import pp
import sys
from pathlib import Path
from datetime import date
import caldav
from .server import create_app
from .calendar import get_davclient
parser = argparse.ArgumentParser(description='Web-based CalDav client')
parser.add_argument('-c', '--config', type=Path, default='config.ini',
help='Configuration file path')
args = parser.parse_args()
config = configparser.ConfigParser()
config.read(args.config)
locale.setlocale(locale.LC_ALL, config.get('locale', 'locale', fallback=None))
logging.basicConfig(level=config.get('logging', 'level', fallback='WARN'))
log = logging.getLogger('saturn')
log.info('Starting saturn')
davclient = get_davclient(config['caldav'])
app = create_app(
bytes(config.get('server', 'secret_key'), 'utf-8'),
config.get('server', 'password'),
davclient,
)
if __name__ == '__main__': if __name__ == '__main__':
app.run( app.run()
host=config.get('server', 'host', fallback=None),
port=config.get('server', 'port', fallback=None),
debug=config.get('server', 'debug', fallback=None),
)