Dirty fix to parse arguments both from the command line and uWSGI environment
This commit is contained in:
parent
c39524e09b
commit
be47a7ca5d
|
@ -3,7 +3,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def get_args():
|
def get_args(args):
|
||||||
parser = argparse.ArgumentParser(description='''Serve a Markdown folder as a web blog.
|
parser = argparse.ArgumentParser(description='''Serve a Markdown folder as a web blog.
|
||||||
|
|
||||||
The folder should have the following structure:
|
The folder should have the following structure:
|
||||||
|
@ -29,12 +29,12 @@ The folder should have the following structure:
|
||||||
parser.add_argument('--debug', dest='debug', required=False, action='store_true', default=False,
|
parser.add_argument('--debug', dest='debug', required=False, action='store_true', default=False,
|
||||||
help='Enable debug mode (default: False)')
|
help='Enable debug mode (default: False)')
|
||||||
|
|
||||||
return parser.parse_known_args(sys.argv[1:])
|
return parser.parse_known_args(args)
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
from .config import init_config
|
from .config import init_config
|
||||||
opts, _ = get_args()
|
opts, _ = get_args(sys.argv[1:])
|
||||||
config_file = os.path.join(opts.dir, 'config.yaml')
|
config_file = os.path.join(opts.dir, 'config.yaml')
|
||||||
init_config(config_file=config_file, content_dir=opts.dir)
|
init_config(config_file=config_file, content_dir=opts.dir)
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from .cli import get_args
|
from .cli import get_args
|
||||||
from .config import init_config
|
from .config import init_config
|
||||||
|
|
||||||
opts, _ = get_args()
|
arg_delim_idx = [
|
||||||
|
i for i, arg in enumerate(sys.argv) if arg == 'madblog.uwsgi'
|
||||||
|
][0]
|
||||||
|
|
||||||
|
opts, _ = get_args(sys.argv[arg_delim_idx+1:])
|
||||||
config_file = os.path.join(opts.dir, 'config.yaml')
|
config_file = os.path.join(opts.dir, 'config.yaml')
|
||||||
init_config(config_file=config_file, content_dir=opts.dir)
|
init_config(config_file=config_file, content_dir=opts.dir)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue