[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/server/ make sure
mkzopeinstance can deal with directories already existing
Fred L. Drake, Jr.
fdrake at gmail.com
Thu Sep 8 15:32:24 EDT 2005
Log message for revision 38410:
make sure mkzopeinstance can deal with directories already existing
Changed:
U Zope3/trunk/src/zope/app/server/mkzopeinstance.py
U Zope3/trunk/src/zope/app/server/tests/test_mkzopeinstance.py
-=-
Modified: Zope3/trunk/src/zope/app/server/mkzopeinstance.py
===================================================================
--- Zope3/trunk/src/zope/app/server/mkzopeinstance.py 2005-09-08 19:29:19 UTC (rev 38409)
+++ Zope3/trunk/src/zope/app/server/mkzopeinstance.py 2005-09-08 19:32:24 UTC (rev 38410)
@@ -186,7 +186,8 @@
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
if os.path.isdir(srcname):
- os.mkdir(dstname)
+ if not os.path.exists(dstname):
+ os.mkdir(dstname)
self.copytree(srcname, dstname)
else:
self.copyfile(srcname, dstname)
Modified: Zope3/trunk/src/zope/app/server/tests/test_mkzopeinstance.py
===================================================================
--- Zope3/trunk/src/zope/app/server/tests/test_mkzopeinstance.py 2005-09-08 19:29:19 UTC (rev 38409)
+++ Zope3/trunk/src/zope/app/server/tests/test_mkzopeinstance.py 2005-09-08 19:32:24 UTC (rev 38410)
@@ -259,7 +259,32 @@
self.failUnless(self.stdout.getvalue())
self.failUnless(app.all_input_consumed())
+ def test_can_rewrite_existing_instance(self):
+ # Fill out the skeleton a little so we test more cases:
+ os.mkdir(os.path.join(self.skeleton, "etc"))
+ f = open(os.path.join(self.skeleton, "etc", "README.txt"), "w")
+ f.write("Configuration goes here.\n")
+ f.close()
+ # Create an instance home:
+ options = self.createOptions()
+ options.destination = self.instance
+ app = ControlledInputApplication(options, [])
+ rc = app.process()
+ self.assertEqual(rc, 0)
+ self.failUnless(app.all_input_consumed())
+ self.failUnless(os.path.exists(os.path.join(self.instance, "etc")))
+
+ # Make sure we can do it again:
+ options = self.createOptions()
+ options.destination = self.instance
+ app = ControlledInputApplication(options, [])
+ rc = app.process()
+ self.assertEqual(rc, 0)
+ self.failUnless(app.all_input_consumed())
+ self.failUnless(os.path.exists(os.path.join(self.instance, "etc")))
+
+
class ControlledInputApplication(mkzopeinstance.Application):
def __init__(self, options, input_lines):
More information about the Zope3-Checkins
mailing list