mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-01-10 14:58:05 +00:00
py-i2phosts-injector: use config options in django setup
This commit is contained in:
parent
596981b854
commit
a3a4d1ef51
@ -3,17 +3,9 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
from django.core.exceptions import ValidationError
|
|
||||||
import configobj
|
import configobj
|
||||||
|
|
||||||
# django setup
|
from django.core.exceptions import ValidationError
|
||||||
DJANGO_SETTINGS_MODULE = 'settings'
|
|
||||||
DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/web'
|
|
||||||
sys.path.insert(1, DJANGO_PROJECT_PATH)
|
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
|
|
||||||
from web.postkey.models import i2phost
|
|
||||||
from web.lib.validation import validate_hostname
|
|
||||||
from web.lib.validation import validate_b64hash
|
|
||||||
|
|
||||||
# parse command line options
|
# parse command line options
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@ -39,6 +31,18 @@ if 'include' in config:
|
|||||||
config_included = configobj.ConfigObj(config['include'])
|
config_included = configobj.ConfigObj(config['include'])
|
||||||
config.merge(config_included)
|
config.merge(config_included)
|
||||||
|
|
||||||
|
# django setup
|
||||||
|
DJANGO_SETTINGS_MODULE = 'settings'
|
||||||
|
if 'DJANGO_PROJECT_PATH' in config:
|
||||||
|
DJANGO_PROJECT_PATH = config['DJANGO_PROJECT_PATH']
|
||||||
|
else:
|
||||||
|
DJANGO_PROJECT_PATH = os.path.dirname(sys.argv[0]) + '/web'
|
||||||
|
sys.path.insert(1, DJANGO_PROJECT_PATH)
|
||||||
|
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
|
||||||
|
from web.postkey.models import i2phost
|
||||||
|
from web.lib.validation import validate_hostname
|
||||||
|
from web.lib.validation import validate_b64hash
|
||||||
|
|
||||||
# determine approve hosts or not
|
# determine approve hosts or not
|
||||||
if args.approve:
|
if args.approve:
|
||||||
approved = True
|
approved = True
|
||||||
|
Loading…
Reference in New Issue
Block a user