Mercurial > p > roundup > code
comparison roundup/init.py @ 51:3a7e5515c1bd
ok, so now "./roundup-admin init" will ask questions...
...in an attempt to get a workable instance_home set up :)
_and_ anydbm has had its first test :)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 23 Jul 2001 08:45:28 +0000 |
| parents | c7c14960f413 |
| children | 5e71aaa87e5b |
comparison
equal
deleted
inserted
replaced
| 50:674bd8e1b36e | 51:3a7e5515c1bd |
|---|---|
| 1 # $Id: init.py,v 1.2 2001-07-22 12:09:32 richard Exp $ | 1 # $Id: init.py,v 1.3 2001-07-23 08:45:28 richard Exp $ |
| 2 | 2 |
| 3 import os, shutil, sys | 3 import os, shutil, sys |
| 4 | 4 |
| 5 def copytree(src, dst, symlinks=0): | 5 def copytree(src, dst, symlinks=0): |
| 6 """Recursively copy a directory tree using copy2(). | 6 """Recursively copy a directory tree using copy2(). |
| 29 elif os.path.isdir(srcname): | 29 elif os.path.isdir(srcname): |
| 30 copytree(srcname, dstname, symlinks) | 30 copytree(srcname, dstname, symlinks) |
| 31 else: | 31 else: |
| 32 shutil.copy2(srcname, dstname) | 32 shutil.copy2(srcname, dstname) |
| 33 | 33 |
| 34 def init(instance, template, adminpw): | 34 def init(instance, template, backend, adminpw): |
| 35 ''' initialise an instance using the named template | 35 ''' initialise an instance using the named template |
| 36 ''' | 36 ''' |
| 37 # first, copy the template dir over | 37 # first, copy the template dir over |
| 38 template_dir = os.path.split(__file__)[0] | 38 template_dir = os.path.split(__file__)[0] |
| 39 template = os.path.join(template_dir, 'templates', template) | 39 template = os.path.join(template_dir, 'templates', template) |
| 40 copytree(template, instance) | 40 copytree(template, instance) |
| 41 | |
| 42 # now select database | |
| 43 db = '''# WARNING: DO NOT EDIT THIS FILE!!! | |
| 44 from roundup.backends.back_%s import Database'''%backend | |
| 45 open(os.path.join(instance, 'select_db.py'), 'w').write(db) | |
| 41 | 46 |
| 42 # now import the instance and call its init | 47 # now import the instance and call its init |
| 43 path, instance = os.path.split(instance) | 48 path, instance = os.path.split(instance) |
| 44 sys.path.insert(0, path) | 49 sys.path.insert(0, path) |
| 45 instance = __import__(instance) | 50 instance = __import__(instance) |
| 46 instance.init(adminpw) | 51 instance.init(adminpw) |
| 47 | 52 |
| 48 # | 53 # |
| 49 # $Log: not supported by cvs2svn $ | 54 # $Log: not supported by cvs2svn $ |
| 55 # Revision 1.2 2001/07/22 12:09:32 richard | |
| 56 # Final commit of Grande Splite | |
| 50 # | 57 # |
| 58 # |
