mirror of
https://github.com/sileht/bird-lg.git
synced 2024-11-24 15:54: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:
commit
5138d655c8
6
lg.py
6
lg.py
|
@ -31,6 +31,7 @@ from urllib2 import urlopen
|
||||||
from urllib import quote, unquote
|
from urllib import quote, unquote
|
||||||
import json
|
import json
|
||||||
import random
|
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 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
|
#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
|
import pydot
|
||||||
from flask import Flask, render_template, jsonify, redirect, session, request, abort, Response, Markup
|
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 = Flask(__name__)
|
||||||
app.config.from_pyfile('lg.cfg')
|
app.config.from_pyfile(args.config_file)
|
||||||
app.secret_key = app.config["SESSION_KEY"]
|
app.secret_key = app.config["SESSION_KEY"]
|
||||||
app.debug = app.config["DEBUG"]
|
app.debug = app.config["DEBUG"]
|
||||||
|
|
||||||
|
|
|
@ -26,14 +26,19 @@ from logging.handlers import TimedRotatingFileHandler
|
||||||
from logging import FileHandler
|
from logging import FileHandler
|
||||||
import subprocess
|
import subprocess
|
||||||
from urllib import unquote
|
from urllib import unquote
|
||||||
|
import argparse
|
||||||
|
|
||||||
from bird import BirdSocket
|
from bird import BirdSocket
|
||||||
|
|
||||||
from flask import Flask, request, abort
|
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 = Flask(__name__)
|
||||||
app.debug = app.config["DEBUG"]
|
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")
|
file_handler = TimedRotatingFileHandler(filename=app.config["LOG_FILE"], when="midnight")
|
||||||
app.logger.setLevel(getattr(logging, app.config["LOG_LEVEL"].upper()))
|
app.logger.setLevel(getattr(logging, app.config["LOG_LEVEL"].upper()))
|
||||||
|
|
Loading…
Reference in a new issue