def initializeInstanceHome(tests_framework_home, real_instance_home, instance_home): assert (os.path.isabs(tests_framework_home) and os.path.isabs(real_instance_home) and os.path.isabs(instance_home)) os.path.exists(instance_home) or os.mkdir(instance_home) if not WIN: # Try to use relative symlinks if tests_framework_home.startswith(os.path.join(real_instance_home, 'Products', '')): tests_framework_home = tests_framework_home[len(real_instance_home)+1:] if real_instance_home == os.path.dirname(instance_home): real_instance_home = 'real_instance' d = os.path.join(instance_home, real_instance_home) os.path.exists(d) or os.symlink('..', d) old_pwd = os.getcwd() try: os.chdir(instance_home) for d in ('bin', 'etc', 'tests', 'var', 'log'): if not os.path.exists(d): os.mkdir(d) for d in ('Products', 'bt5', 'svn', 'lib', 'import'): if not os.path.exists(d): src = os.path.join(real_instance_home, d) if os.path.islink(d): os.remove(d) if WIN: if d in ('Products', 'bt5', 'svn'): os.mkdir(d) else: shutil.copytree(src, d) else: os.symlink(src, d) d = 'custom_zodb.py' if not os.path.exists(d): src = os.path.join(tests_framework_home, d) if os.path.islink(d): os.remove(d) if WIN: shutil.copy(src, d) else: os.symlink(src, d) finally: os.chdir(old_pwd) kw = { "PYTHON": sys.executable, "INSTANCE_HOME": instance_home, "SOFTWARE_HOME": software_home, } from Zope2.utilities import copyzopeskel kw['ZOPE_SCRIPTS'] = os.environ['ZOPE_SCRIPTS'] skelsrc = os.path.abspath(os.path.join(tests_framework_home, 'skel')) copyzopeskel.copyskel(skelsrc, instance_home, None, None, **kw)
def initializeInstanceHome(tests_framework_home, real_instance_home, instance_home): assert (os.path.isabs(tests_framework_home) and os.path.isabs(real_instance_home) and os.path.isabs(instance_home)) if not os.path.exists(instance_home): os.mkdir(instance_home) if not WIN: # Try to use relative symlinks if tests_framework_home.startswith(os.path.join(real_instance_home, 'Products', '')): tests_framework_home = tests_framework_home[len(real_instance_home)+1:] if real_instance_home == os.path.dirname(instance_home): real_instance_home = 'real_instance' os.symlink('..', os.path.join(instance_home, real_instance_home)) old_pwd = os.getcwd() try: os.chdir(instance_home) for d in ('bin', 'etc', 'tests', 'var', 'log'): if not os.path.exists(d): os.mkdir(d) for d in ('Products', 'bt5', 'svn', 'lib', 'import'): if not os.path.exists(d): src = os.path.join(real_instance_home, d) if os.path.islink(d): os.remove(d) if WIN: if d in ('Products', 'bt5', 'svn'): os.mkdir(d) else: shutil.copytree(src, d) else: os.symlink(src, d) d = 'custom_zodb.py' if not os.path.exists(d): src = os.path.join(tests_framework_home, d) if os.path.islink(d): os.remove(d) if WIN: shutil.copy(src, d) else: os.symlink(src, d) finally: os.chdir(old_pwd) kw = { "PYTHON": sys.executable, "INSTANCE_HOME": instance_home, "SOFTWARE_HOME": software_home, } try: # attempt to import copyzopeskel from its new home on Zope 2.12 from Zope2.utilities import copyzopeskel # and use the 2.12 version of our skeleton skeldir = 'skel2.12' kw['ZOPE_SCRIPTS'] = os.environ['ZOPE_SCRIPTS'] except ImportError: # add some paths where we can find copyzopeskel sys.path.append(os.path.join(zope_home, "bin")) sys.path.append(os.path.join(zope_home, "utilities")) import copyzopeskel kw['ZOPE_HOME'] = zope_home skeldir = 'skel' skelsrc = os.path.abspath(os.path.join(tests_framework_home, skeldir)) copyzopeskel.copyskel(skelsrc, instance_home, None, None, **kw)