Updated module structure for uwsgi

This commit is contained in:
Edgar P. Burkhart 2022-01-28 13:35:24 +01:00
parent 006145dbf6
commit d55ab8c5b2
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
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.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,
)

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),
)