1
0
Fork 0
mirror of https://github.com/sileht/bird-lg.git synced 2024-12-22 04:24:42 +01:00

specify config file as cli argument

This commit is contained in:
Peter Hansen 2019-12-28 11:32:00 +01:00
parent fa1c071682
commit 71226a4ed3
2 changed files with 11 additions and 2 deletions

6
lg.py
View file

@ -31,6 +31,7 @@ from urllib2 import urlopen
from urllib import quote, unquote
import json
import random
import argparse
from toolbox import mask_is_valid, ipv6_is_valid, ipv4_is_valid, resolve, save_cache_pickle, load_cache_pickle, unescape
#from xml.sax.saxutils import escape
@ -38,9 +39,12 @@ from toolbox import mask_is_valid, ipv6_is_valid, ipv4_is_valid, resolve, save_c
import pydot
from flask import Flask, render_template, jsonify, redirect, session, request, abort, Response, Markup
parser = argparse.ArgumentParser()
parser.add_argument('-c', dest='config_file', help='path to config file', default='lg.cfg')
args = parser.parse_args()
app = Flask(__name__)
app.config.from_pyfile('lg.cfg')
app.config.from_pyfile(args.config_file)
app.secret_key = app.config["SESSION_KEY"]
app.debug = app.config["DEBUG"]

View file

@ -26,14 +26,19 @@ from logging.handlers import TimedRotatingFileHandler
from logging import FileHandler
import subprocess
from urllib import unquote
import argparse
from bird import BirdSocket
from flask import Flask, request, abort
parser = argparse.ArgumentParser()
parser.add_argument('-c', dest='config_file', help='path to config file', default='lgproxy.cfg')
args = parser.parse_args()
app = Flask(__name__)
app.debug = app.config["DEBUG"]
app.config.from_pyfile('lgproxy.cfg')
app.config.from_pyfile(args.config_file)
file_handler = TimedRotatingFileHandler(filename=app.config["LOG_FILE"], when="midnight")
app.logger.setLevel(getattr(logging, app.config["LOG_LEVEL"].upper()))