instance_settings = InstanceSettings(instance_name)
 instance = instance_settings.selected_instance
 pkgs_to_install = InstalledPackages(packages)
 
 # Warn if quick
 if flags.quick:
     print "WARNING: Running update in Quick Mode"
     
 # Create temp directory to work in
 tmpdir_handle, target = instance_compile_path(instance.name)
 if os.path.exists(target):
     print "Cleaning out previous %s" % (target)
     try:
         DeleteTree(target).execute()
     except InstallError, e:
         abort(str(e))
 try:
     os.mkdir(target)
 except Exception, e:
     failed_to("create " + target, e)
     
 print ""
 print "Compiling %s to %s" % (instance_name, target)
         
 # Set command debugging
 InstallActionBase.DEBUG_FILE = open('install.debug', 'wt')
         
 # Install Drupal Base
 pkg, ver = pkgs_to_install.package_ver('drupal', pkgs_to_install.drupal_ver)
 try:
     DownloadPackage(pkg, ver).execute()
def failed_to(trying, e):
    abort("Failed to %s: %s" % (trying, str(e)))
def check_at_repo_root():
    path = 'SBC_DB_FOLDER'
    if not os.path.exists(path):
        path = os.path.abspath(path)
        abort("missing %s\nMust be run from repository root" % (path))