#!python
import os
#
from starcluster.clustersetup import ClusterSetup
from starcluster.logger import log
#
import tabular_predDB.settings as S

run_as_user = lambda user, command_str: \
    node.ssh.execute('sudo -u %s %s' % user, command_str)

class tabular_predDBSetup(ClusterSetup):
     def __init__(self):
         # TODO: Could be generalized to "install a python package plugin"
         pass

     def run(self, nodes, master, user, user_shell, volumes):
          # NOTE: nodes includes master
          boto_full_file = os.path.join(S.path.remote_home_dir, '.boto')
          clone_tuple = (S.git.repo, S.path.remote_code_dir)
          checkout_tuple = (S.path.remote_code_dir, S.git.branch)
          #
          for node in nodes:
               log.info("Copying up boto file on %s" % node.alias)
               node.ssh.put(S.s3.ec2_credentials_file, S.path.remote_home_dir)
               node.ssh.execute('chmod -R ugo+rwx %s' % boto_full_file)
               node.ssh.put(os.path.expanduser('~/.ssh/id_rsa'), os.path.join(S.path.remote_home_dir, '.ssh'))
          for node in nodes:
               log.info("Installing tabular_predDB (part 1) on %s" % node.alias)
               #
               # node.ssh.execute('rm -rf %s' % clone_tuple[-1])
               # node.ssh.execute('git clone %s %s' % clone_tuple)
               node.ssh.execute('cd %s && git checkout %s' % checkout_tuple)
               node.ssh.execute('chmod -R ugo+rwx %s' % clone_tuple[-1])
          for node in nodes:
               log.info("Installing tabular_predDB (part 2) on %s" % node.alias)
               node.ssh.execute('apt-get install -y libfreetype6-dev')
               node.ssh.execute('apt-get install -y libpng12-dev')
               node.ssh.execute('pip install virtualenv')
               node.ssh.execute('pip install virtualenvwrapper')
               command_str = 'cd %s && bash -i %s' % (S.path.remote_code_dir, S.path.virtualenv_setup_script)
               run_as_user(user, command_str)
               command_str = 'cd %s && bash -i %s' % (S.path.remote_code_dir, S.path.install_boost_script)
               node.ssh.execute(command_str)

@@ -158,16 +158,22 @@
 = lambda
+ node,
  user, c
@@ -225,16 +225,17 @@
 s %25s' %25 
+(
 user, co
@@ -244,16 +244,17 @@
 and_str)
+)
 %0A%0Aclass 
@@ -705,16 +705,150 @@
 branch)%0A
+          local_ssh_key = os.path.expanduser('~/.ssh/id_rsa')%0A          remote_ssh_key = os.path.join(S.path.remote_home_dir, '.ssh')%0A
         
@@ -1130,89 +1130,95 @@
 put(
-os.path.expanduser('~/.ssh/id_rsa'), os.path.join(S.path.remote_home_dir, '
+local_ssh_key, remote_ssh_key)%0A               node.ssh.put(local_ssh_key, '/root/
 .ssh
+/
 '
-)
 )%0A  
@@ -1348,34 +1348,32 @@
 #%0A              
- #
  node.ssh.execut
@@ -1419,18 +1419,16 @@
         
- #
  node.ss
@@ -1612,32 +1612,106 @@
 lone_tuple%5B-1%5D)%0A
+               node.ssh.execute('chown -R sgeadmin %25s' %25 clone_tuple%5B-1%5D)%0A
           for no
@@ -2084,46 +2084,65 @@
     
-command_str = 'cd %25s && bash -i %25s' %25 
+# install boost%0A               script_full = os.path.join
 (S.p
@@ -2173,24 +2173,21 @@
 ath.
-virtualenv_setup
+install_boost
 _scr
@@ -2210,92 +2210,162 @@
     
-run_as_user(user, command_str)%0A               command_str = 'cd %25s && bash -i %25s' %25 
+command_str = 'bash %25s %3Eout2 2%3Eerr2' %25 script_full%0A               node.ssh.execute(command_str)%0A               #%0A               script_full = os.path.join
 (S.p
@@ -2388,37 +2388,40 @@
 dir, S.path.
-install_boost
+virtualenv_setup
 _script)%0A   
@@ -2432,33 +2432,109 @@
         
-node.ssh.execute(
+command_str = 'bash -i %25s %3Eout1 2%3Eerr1' %25 script_full%0A               run_as_user(node, user, 
 command_

fix up plugin logic