summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Macken <lmacken@redhat.com>2011-11-29 21:22:37 (GMT)
committerLuke Macken <lmacken@redhat.com>2011-11-29 21:22:37 (GMT)
commit99bcdb238e75b5cd7696829f6d996ff7c3028f44 (patch)
treef30114c0be0ed776fbcf126c9619c5c118805ac9
parentad5224236a2203153b187d01970df307e7487edc (diff)
downloadfedoracommunity-99bcdb238e75b5cd7696829f6d996ff7c3028f44.zip
fedoracommunity-99bcdb238e75b5cd7696829f6d996ff7c3028f44.tar.gz
fedoracommunity-99bcdb238e75b5cd7696829f6d996ff7c3028f44.tar.xz
Try to automatically generate the moksha ctl.cfg if we can
-rw-r--r--fedoracommunity/ctl/config.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/fedoracommunity/ctl/config.py b/fedoracommunity/ctl/config.py
index 41a27c3..d70ca5c 100644
--- a/fedoracommunity/ctl/config.py
+++ b/fedoracommunity/ctl/config.py
@@ -2,6 +2,7 @@
import os
import sys
+import textwrap
import ConfigParser
EXAMPLE_CTL_CONF = """
@@ -27,9 +28,25 @@ def load_config(fname="~/.moksha/ctl.conf"):
fname = os.path.expanduser(fname)
if not os.path.exists(fname):
- print "No such file '%s'" % fname
- print EXAMPLE_CTL_CONF
- sys.exit(1)
+ # If moksha is already checked out alongside of us, then automatically
+ # generate the config.
+ mokshadir = os.path.abspath(os.path.join('..', 'moksha'))
+ if os.path.isdir(mokshadir):
+ mokshacfgdir = os.path.dirname(fname)
+ if not os.path.isdir(mokshacfgdir):
+ os.makedirs(mokshacfgdir)
+ cfg = file(fname, 'w')
+ cfg.write(textwrap.dedent("""\
+ [fcomm]
+ venv = fcomm
+ fcomm-src-dir = %s
+ moksha-src-dir = %s
+ """ % (os.getcwd(), mokshadir)))
+ cfg.close()
+ else:
+ print "No such file '%s'" % fname
+ print EXAMPLE_CTL_CONF
+ sys.exit(1)
with open(fname) as f:
config.readfp(f)