[Zodb-checkins] CVS: Zope/lib/python/ZEO - mkzeoinst.py:1.13
Fred L. Drake, Jr.
fred@zope.com
Mon, 17 Mar 2003 15:54:30 -0500
Update of /cvs-repository/Zope/lib/python/ZEO
In directory cvs.zope.org:/tmp/cvs-serv28423
Modified Files:
mkzeoinst.py
Log Message:
Be more careful about handling options and generating a usage message.
=== Zope/lib/python/ZEO/mkzeoinst.py 1.12 => 1.13 ===
--- Zope/lib/python/ZEO/mkzeoinst.py:1.12 Wed Jan 29 17:19:09 2003
+++ Zope/lib/python/ZEO/mkzeoinst.py Mon Mar 17 15:54:29 2003
@@ -9,12 +9,12 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
+# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""mkzeoinst.py -- create a ZEO instance.
+"""%(program)s -- create a ZEO instance.
-Usage: mkzeoinst.py home [port]
+Usage: %(program)s home [port]
Given an "instance home directory" <home> and some configuration
options (all of which have default values), create the following:
@@ -108,18 +108,24 @@
def main():
try:
- opts, args = getopt.getopt(sys.argv[1:], "")
+ opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
except getopt.error, msg:
print msg
sys.exit(2)
+ program = os.path.basename(sys.argv[0])
+ if opts:
+ # There's only the help options, so just dump some help:
+ msg = __doc__ % {"program": program}
+ print msg
+ sys.exit()
if len(args) not in [1, 2]:
- print "Usage: mkzeoinst.py home [port]"
+ print "Usage: %s home [port]" % program
sys.exit(2)
- home = sys.argv[1]
+ home = args[0]
if not os.path.isabs(home):
home = os.path.abspath(home)
- if sys.argv[2:]:
- port = int(sys.argv[2])
+ if args[1:]:
+ port = int(args[1])
else:
port = 9999
checkport(port)