[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/server/ add a
--non-interactive switch so people who build instances
programmatically
Benji York
benji at zope.com
Fri Oct 28 17:04:27 EDT 2005
Log message for revision 39700:
add a --non-interactive switch so people who build instances programmatically
won't get burned by unpredicted prompting
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-10-28 21:00:42 UTC (rev 39699)
+++ Zope3/trunk/src/zope/app/server/mkzopeinstance.py 2005-10-28 21:04:27 UTC (rev 39700)
@@ -61,10 +61,18 @@
def read_input_line(self, prompt):
# The tests replace this to make sure the right things happen.
+ if not self.options.interactive:
+ print >>sys.stderr, ('Error: Tried to ask for user input in'
+ ' non-interactive mode.')
+ sys.exit(1)
return raw_input(prompt)
def read_password(self, prompt):
# The tests replace this to make sure the right things happen.
+ if not self.options.interactive:
+ print >>sys.stderr, ('Error: Tried to ask for user input in'
+ ' non-interactive mode.')
+ sys.exit(1)
import getpass
try:
return getpass.getpass(prompt)
@@ -101,10 +109,13 @@
if not options.username:
options.username = self.get_username()
+
(options.password_manager,
password_manager) = self.get_password_manager()
+
if not options.password:
options.password = self.get_password()
+
options.password = password_manager.encodePassword(options.password)
# now create the instance!
@@ -156,6 +167,9 @@
return password
def get_password_manager(self):
+ if not self.options.password_manager and not self.options.interactive:
+ self.options.password_manager = password.managers[0][0]
+
if self.options.password_manager:
for name, manager in password.managers:
if name == self.options.password_manager:
@@ -280,6 +294,8 @@
" to be used for encode the password"))
p.add_option("-u", "--user", dest="username", metavar="USER:PASSWORD",
help="set the user name and password of the initial user")
+ p.add_option("--non-interactive", dest="interactive", action="store_false",
+ default=True, help="do no interactive prompting")
options, args = p.parse_args(argv[1:])
if options.skeleton is None:
options.add_package_includes = from_checkout
Modified: Zope3/trunk/src/zope/app/server/tests/test_mkzopeinstance.py
===================================================================
--- Zope3/trunk/src/zope/app/server/tests/test_mkzopeinstance.py 2005-10-28 21:00:42 UTC (rev 39699)
+++ Zope3/trunk/src/zope/app/server/tests/test_mkzopeinstance.py 2005-10-28 21:04:27 UTC (rev 39700)
@@ -165,6 +165,7 @@
def createOptions(self):
options = Options()
options.skeleton = self.skeleton
+ options.interactive = True
return options
def test_get_skeltarget(self):
More information about the Zope3-Checkins
mailing list