aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@gmail.com>2009-02-21 17:27:58 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2009-02-21 17:27:58 +0530
commit702271518b4fe93bc043e883615250c1be4a668c (patch)
tree673ee614641f02f2cfbcff331a4ec556e0722462
parentFix incorrect path for python site-packages (diff)
downloadautotua-702271518b4fe93bc043e883615250c1be4a668c.tar.gz
autotua-702271518b4fe93bc043e883615250c1be4a668c.tar.bz2
autotua-702271518b4fe93bc043e883615250c1be4a668c.zip
Fix things broken by previous changes to setup-master.py
* Paths appended were wrong * Use osp.join instead of +/ - I don't know what I was thinking when I did that
-rwxr-xr-xmaster/setup-master.py45
1 files changed, 25 insertions, 20 deletions
diff --git a/master/setup-master.py b/master/setup-master.py
index 78e73e7..0da1288 100755
--- a/master/setup-master.py
+++ b/master/setup-master.py
@@ -9,6 +9,7 @@
# FIXME: This is so fucking ugly.
import sys, os, shutil
+import os.path as osp
try:
from django.core import management
except ImportError:
@@ -55,25 +56,25 @@ def install_master():
management.call_command('startproject', DESTDIR)
if SYMLINKS:
- os.symlink(srcdir+'/master', DESTDIR+'/master')
+ os.symlink(osp.join(srcdir, 'master'), osp.join(DESTDIR, 'master'))
for file in ['urls.py']:
- dest_file = DESTDIR+'/'+file
- if os.path.isfile(dest_file):
+ dest_file = osp.join(DESTDIR, file)
+ if osp.isfile(dest_file):
os.remove(dest_file)
- os.symlink(srcdir+'/custom/'+file, dest_file)
+ os.symlink(osp.join(srcdir, 'custom', file), dest_file)
else:
- shutil.copytree(srcdir+'/master', DESTDIR+'/master')
+ shutil.copytree(osp.join(srcdir, 'master'), osp.join(DESTDIR, 'master'))
for file in ['urls.py']:
- shutil.copy(srcdir+'/custom/'+file, DESTDIR)
- settings = open(DESTDIR+'/settings.py', 'a')
- master_settings = open(srcdir+'/custom/merge_settings.py')
+ shutil.copy(osp.join(srcdir, 'custom', file), DESTDIR)
+ settings = open(osp.join(DESTDIR, 'settings.py'), 'a')
+ master_settings = open(osp.join(srcdir, 'custom', 'merge_settings.py'))
settings.write('\n'+master_settings.read())
settings.close()
master_settings.close()
# Install icons
- icondir = os.path.abspath(srcdir+'/icons')
- installdir = os.path.abspath(DESTDIR)
+ icondir = osp.abspath(osp.join(srcdir, 'icons'))
+ installdir = osp.abspath(DESTDIR)
subprocess.check_call('cd %s; make DESTDIR=%s install' % (icondir, installdir), shell=True)
def syncdb_master():
@@ -118,7 +119,7 @@ def syncdb_master():
def setup_gpg(data, gpghome):
from autotua import crypt
from master import const
- if not os.path.isdir(gpghome):
+ if not osp.isdir(gpghome):
os.mkdir(gpghome, 0700)
print 'Creating a "sample" gpg key (expires in 1 month)'
crypt.Crypto(gpghome).init_gpghome(**data)
@@ -139,7 +140,11 @@ def setup_sample_slave():
slave.save()
def setup_sample_job():
+ from autotua import sync
from sample_data import sample_job
+ # Setup the jobtage tree in /var/tmp/autotua/jobtage
+ sync.Syncer().sync()
+ # Get on with the job at hand... ;)
job = Job()
for i in ['name', 'jobtagerev', 'atoms']:
setattr(job, i, sample_job[i])
@@ -155,19 +160,19 @@ def setup_sample_job():
def setup_dirs(dir):
"""This must be called before doing anything else."""
# cd to setup-master.py location
- os.chdir(os.path.dirname(sys.argv[0]))
+ os.chdir(osp.dirname(sys.argv[0]))
# Store the current directory
# We cd and store to work around relative invocations
global srcdir
srcdir = os.getcwd()
- if not os.path.isdir(dir):
+ if not osp.isdir(dir):
os.makedirs(dir)
os.chdir(dir)
sys.path.append(os.getcwd())
# Add cwd+/custom
- sys.path.append(srcdir+'/custom')
+ sys.path.append(osp.join(srcdir, 'custom'))
### Start Work ###
if len(sys.argv) < 3:
@@ -180,18 +185,18 @@ if management.get_version() < '0.99':
if sys.argv[1] == 'install':
if sys.argv[2] == '--final':
- where = os.path.dirname(sys.argv[3].rstrip('/'))
- DESTDIR = os.path.basename(sys.argv[3].rstrip('/'))
+ where = osp.dirname(sys.argv[3].rstrip('/'))
+ DESTDIR = osp.basename(sys.argv[3].rstrip('/'))
elif sys.argv[1] == 'install':
- where = os.path.dirname(sys.argv[2].rstrip('/'))
+ where = osp.dirname(sys.argv[2].rstrip('/'))
setup_dirs(where)
install_master()
print """Setup done.
Now you need to edit the database settings in %(dest)s/settings.py
-and run `./setup-master.py syncdb %(dest)s`""" % { 'dest': os.path.join(where, DESTDIR) }
+and run `./setup-master.py syncdb %(dest)s`""" % { 'dest': osp.join(where, DESTDIR) }
elif sys.argv[1] == 'syncdb':
# Setup the relevant directories
- where = os.path.dirname(sys.argv[2].rstrip('/'))
+ where = sys.argv[2].rstrip('/')
setup_dirs(where)
# Import stuff
import settings
@@ -204,7 +209,7 @@ elif sys.argv[1] == 'syncdb':
syncdb_master()
setup_gpg(sample_master_gpg_data, const.GPGHOME)
setup_sample_slave() # Should be done before job; inits User if DNE
- setup_gpg(sample_slave_gpg_data, const.MASTER_DIR+'/sample_slave_gpghome')
+ setup_gpg(sample_slave_gpg_data, osp.join(const.MASTER_DIR, 'sample_slave_gpghome'))
setup_sample_job()
print "All done! Now you can start the master with `python manage.py runserver`"
else: