mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-02-02 09:55:52 +00:00
py-i2phosts-maint: add config file support
This commit is contained in:
parent
c505b2ce68
commit
2a16ddb3d3
@ -13,6 +13,7 @@ DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/web'
|
|||||||
sys.path.insert(1, DJANGO_PROJECT_PATH)
|
sys.path.insert(1, DJANGO_PROJECT_PATH)
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
|
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
|
||||||
from web.postkey.models import i2phost
|
from web.postkey.models import i2phost
|
||||||
|
import configobj
|
||||||
|
|
||||||
# parse command line options
|
# parse command line options
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@ -20,6 +21,8 @@ parser = argparse.ArgumentParser(
|
|||||||
epilog='Report bugs to http://zzz.i2p/topics/733')
|
epilog='Report bugs to http://zzz.i2p/topics/733')
|
||||||
parser.add_argument('-d', '--debug', action='store_true',
|
parser.add_argument('-d', '--debug', action='store_true',
|
||||||
help='enable debug messages')
|
help='enable debug messages')
|
||||||
|
parser.add_argument('-c', '--config', default='/etc/py-i2phosts/maintainer.conf', dest='config_file',
|
||||||
|
help='config file to use')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# configure logger
|
# configure logger
|
||||||
@ -28,6 +31,12 @@ handler = logging.StreamHandler()
|
|||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
if args.debug:
|
if args.debug:
|
||||||
log.setLevel(logging.DEBUG)
|
log.setLevel(logging.DEBUG)
|
||||||
|
# read config
|
||||||
|
config = configobj.ConfigObj(args.config_file)
|
||||||
|
if 'include' in config:
|
||||||
|
config_included = configobj.ConfigObj(config['include'])
|
||||||
|
config.merge(config_included)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.setLevel(logging.INFO)
|
log.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user