view roundup/init.py @ 54:b68bcb176d1a

disabled the reloading until it can be done properly
author Richard Jones <richard@users.sourceforge.net>
date Mon, 23 Jul 2001 10:31:45 +0000
parents 3a7e5515c1bd
children 5e71aaa87e5b
line wrap: on
line source

# $Id: init.py,v 1.3 2001-07-23 08:45:28 richard Exp $

import os, shutil, sys

def copytree(src, dst, symlinks=0):
    """Recursively copy a directory tree using copy2().

    The destination directory os allowed to exist.

    If the optional symlinks flag is true, symbolic links in the
    source tree result in symbolic links in the destination tree; if
    it is false, the contents of the files pointed to by symbolic
    links are copied.

    XXX copied from shutil.py in std lib

    """
    names = os.listdir(src)
    try:
        os.mkdir(dst)
    except OSError, error:
        if error.errno != 17: raise
    for name in names:
        srcname = os.path.join(src, name)
        dstname = os.path.join(dst, name)
        if symlinks and os.path.islink(srcname):
            linkto = os.readlink(srcname)
            os.symlink(linkto, dstname)
        elif os.path.isdir(srcname):
            copytree(srcname, dstname, symlinks)
        else:
            shutil.copy2(srcname, dstname)

def init(instance, template, backend, adminpw):
    ''' initialise an instance using the named template
    '''
    # first, copy the template dir over
    template_dir = os.path.split(__file__)[0]
    template = os.path.join(template_dir, 'templates', template)
    copytree(template, instance)

    # now select database
    db = '''# WARNING: DO NOT EDIT THIS FILE!!!
from roundup.backends.back_%s import Database'''%backend
    open(os.path.join(instance, 'select_db.py'), 'w').write(db)

    # now import the instance and call its init
    path, instance = os.path.split(instance)
    sys.path.insert(0, path)
    instance = __import__(instance)
    instance.init(adminpw)

#
# $Log: not supported by cvs2svn $
# Revision 1.2  2001/07/22 12:09:32  richard
# Final commit of Grande Splite
#
#

Roundup Issue Tracker: http://roundup-tracker.org/