1
0
Fork 0
mirror of https://github.com/sileht/bird-lg.git synced 2024-11-21 14:34:43 +01:00

Merge pull request #54 from empi89/feature/config-file-as-argument

specify config file as cli argument
This commit is contained in:
zorun 2020-06-14 18:04:12 +02:00 committed by GitHub
commit 5138d655c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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()))