Default to mediagoblin_local.ini if available in ./bin/gmg commands
This commit is contained in:
parent
42652ad1d5
commit
9d0a613be9
@ -15,6 +15,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import os
|
||||||
|
|
||||||
from mediagoblin.tools.common import import_component
|
from mediagoblin.tools.common import import_component
|
||||||
|
|
||||||
@ -59,8 +60,11 @@ def main_cli():
|
|||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='GNU MediaGoblin utilities.')
|
description='GNU MediaGoblin utilities.')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-cf', '--conf_file', default='mediagoblin.ini',
|
'-cf', '--conf_file', default=None,
|
||||||
help="Config file used to set up environment")
|
help=(
|
||||||
|
"Config file used to set up environment. "
|
||||||
|
"Default to mediagoblin_local.ini if readable, "
|
||||||
|
"otherwise mediagoblin.ini"))
|
||||||
|
|
||||||
subparsers = parser.add_subparsers(help='sub-command help')
|
subparsers = parser.add_subparsers(help='sub-command help')
|
||||||
for command_name, command_struct in SUBCOMMAND_MAP.iteritems():
|
for command_name, command_struct in SUBCOMMAND_MAP.iteritems():
|
||||||
@ -78,6 +82,13 @@ def main_cli():
|
|||||||
subparser.set_defaults(func=exec_func)
|
subparser.set_defaults(func=exec_func)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
if args.conf_file is None:
|
||||||
|
if os.path.exists('mediagoblin_local.ini') \
|
||||||
|
and os.access('mediagoblin_local.ini', os.R_OK):
|
||||||
|
args.conf_file = 'mediagoblin_local.ini'
|
||||||
|
else:
|
||||||
|
args.conf_file = 'mediagoblin.ini'
|
||||||
|
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user