aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/gmg_commands
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2014-10-10 19:35:09 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2014-10-10 19:35:09 -0500
commit4c03d45f6acfa4d367699718c521e7f62160f8e6 (patch)
tree6f68c4a2dd40f41c7c67f59059baebd6dbd8015b /mediagoblin/gmg_commands
parent0d063605ec533236bcf7fb07540dac77b14fa43f (diff)
downloadmediagoblin-4c03d45f6acfa4d367699718c521e7f62160f8e6.tar.lz
mediagoblin-4c03d45f6acfa4d367699718c521e7f62160f8e6.tar.xz
mediagoblin-4c03d45f6acfa4d367699718c521e7f62160f8e6.zip
Make a mediagoblin.ini file for the user if needed.
This is to prevent our docs from confusing people in this transitionary time period...
Diffstat (limited to 'mediagoblin/gmg_commands')
-rw-r--r--mediagoblin/gmg_commands/__init__.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/mediagoblin/gmg_commands/__init__.py b/mediagoblin/gmg_commands/__init__.py
index 22fef91c..d8d982b1 100644
--- a/mediagoblin/gmg_commands/__init__.py
+++ b/mediagoblin/gmg_commands/__init__.py
@@ -16,11 +16,16 @@
import argparse
import os
+import shutil
import six
from mediagoblin.tools.common import import_component
+import logging
+_log = logging.getLogger(__name__)
+logging.basicConfig()
+
SUBCOMMAND_MAP = {
'shell': {
@@ -127,6 +132,27 @@ def main_cli():
else:
args.conf_file = 'mediagoblin.ini'
+ # This is a hopefully TEMPORARY hack for adding a mediagoblin.ini
+ # if none exists, to make up for a deficiency as we are migrating
+ # our docs to the new "no mediagoblin.ini by default" workflow.
+ # Normally, the docs should provide instructions for this, but
+ # since 0.7.1 docs say "install from master!" and yet we removed
+ # mediagoblin.ini, we need to cover our bases...
+
+ parent_directory = os.path.split(os.path.abspath(args.conf_file))[0]
+ if os.path.split(args.conf_file)[1] == 'mediagoblin.ini' \
+ and not os.path.exists(args.conf_file) \
+ and os.path.exists(
+ os.path.join(
+ parent_directory, 'mediagoblin.example.ini')):
+ # Do the copy-over of the mediagoblin config for the user
+ _log.warning(
+ "No mediagoblin.ini found and no other path given, "
+ "so making one for you.")
+ shutil.copy(
+ os.path.join(parent_directory, "mediagoblin.example.ini"),
+ os.path.join(parent_directory, "mediagoblin.ini"))
+
args.func(args)