Commits

Docta Jay  committed acc5cf7

Changes

  • Participants
  • Parent commits 6e81d24

Comments (0)

Files changed (1)

File djaboto/management/commands/checkmix.py

 from django.core.management.base import BaseCommand
 import djaboto
 from subprocess import check_call
+from getpass import getuser
+from socket import gethostname
 
 class Command(BaseCommand):
     help = ("Check the status of your soupmix.")
     ###TODO: Add segment to generate, as well as source, the local database environment variables.
     DIR_BIN_OLD = os.path.join(DIR_PROJECT, args.site_name, 'bin')
     print DIR_BIN_OLD
-    DIR_BIN_NEW = os.path.join(DIR_PROJECT, 'bin')
-    print DIR_BIN_NEW
-    check_call(['mv', DIR_BIN_OLD, DIR_BIN_NEW])
-    check_call(['source', 'grape_data'])
+    DIR_BIN_NEW = os.path.join('/home', getuser(), '.soupmix', args.site_name)
+    if not os.path.exists(DIR_BIN_NEW):
+        print DIR_BIN_NEW
+        check_call(['mkdir', '-p', DIR_BIN_NEW])
+        check_call(['mv', '%s/grape_data' % DIR_BIN_OLD, DIR_BIN_NEW])
+        check_call(['mv', '%s/nymph_data' % DIR_BIN_OLD, DIR_BIN_NEW])
+    localhost_datafile = os.path.join(DIR_BIN_NEW, '%s_data' % gethostname())
+    if os.path.exists(localhost_datafile):
+        print localhost_datafile
+        print os.path.exists(localhost_datafile)
+        check_call(['source', localhost_datafile])
+    else:
+        raise Exception("Create a local database config file for the site at %s/%s_data" % (DIR_BIN_NEW, gethostname()))
 
     print '...running syncdb via manage.py'
     check_call(['./manage.py','syncdb'])