gex now uses OptionParser module for command line arguments. Regards Harshavardhana
? gex-option-parser-1.diff ? gex-option-parser.diff ? extensions/core/Gluster/GArgs.pyc ? extensions/core/Gluster/GConf.pyc ? extensions/core/Gluster/GPackage.pyc ? extensions/core/Gluster/GRegistry.pyc ? extensions/core/Gluster/__init__.pyc ? extensions/core/Gluster/gmap.pyc ? extensions/core/Gluster/GFrontEnd/UI.pyc ? extensions/core/Gluster/GFrontEnd/__init__.pyc ? extensions/core/Gluster/GFrontEnd/dialog.pyc ? extensions/core/Gluster/GTmp/Dir.pyc ? extensions/core/Gluster/GTmp/__init__.pyc ? stage2/skel-master/etc/rc.d/rc.halt ? stage2/skel-slave/etc/rc.d/rc.halt ? stage3/e2fsprogs.mk ? stage3/jfsutils.mk ? stage3/reiserfsprogs.mk ? stage3/xfsprogs.mk Index: extensions/core/bin/gex =================================================================== RCS file: /cvsroot/gluster/gluster-alpha1/extensions/core/bin/gex,v retrieving revision 1.3 diff -p -u -r1.3 gex --- extensions/core/bin/gex 21 Feb 2006 12:48:13 -0000 1.3 +++ extensions/core/bin/gex 22 Feb 2006 07:00:18 -0000 @@ -1,12 +1,14 @@ #!/usr/bin/python -from Gluster import GPackage, GArgs; from Gluster.GTmp import Dir; from Gluster.GFrontEnd import dialog; import os, tarfile, sys; +from optparse import OptionParser; dlg = dialog.Dialog (); +arg_given = False + def file_to_dict (filename): _dict = {}; for line in open (filename).readlines (): @@ -24,6 +26,8 @@ def file_to_dict (filename): return _dict; def GpkgInstall (option, opt_str, value, parser): + global arg_given + arg_given = True if not os.access (value, os.R_OK): print value + ": cant read"; return @@ -58,6 +62,8 @@ def GpkgInstall (option, opt_str, value, return ; def GpkgDetails (option, opt_str, value, parser): + global arg_given + arg_given = True contents = file_to_dict (value); if 'package-name' in contents.keys (): print "Name : " + contents['package-name']; @@ -68,42 +74,27 @@ def GpkgDetails (option, opt_str, value, return ; def GpkgListApps (option, opt_str, value, parser): + global arg_given + arg_given = True _arr = []; os.system ("grep -Hi '^ *application-register *:' /stage3/*.gex | cut -f1,3- -d:") return -_args = [ - { 'keys' : [ '--install' ], - 'dest' : 'GEXFILE', - 'callback' : GpkgInstall, - 'help' : 'Install a gex', - 'type' : 'string', - 'default' : None, - 'nargs' : 1 - }, - { 'keys' : [ '--details' ], - 'dest' : 'PKG', - 'callback' : GpkgDetails, - 'help' : 'Details of PKG', - 'type' : 'string', - 'default' : None, - 'nargs' : 1 - }, - { 'keys' : [ '--list-apps' ], - 'dest' : 'LOADPKG', - 'callback' : GpkgListApps, - 'help' : 'Load a gex', - 'type' : 'string', - 'default' : None, - 'nargs' : 0 - } - ]; - - def main (): - gargp = GArgs.GArgp (); - gargp.AddOpt (_args); - gargp.Process (); + parser = OptionParser () + parser.add_option ( "-i", "--install", action="callback", + callback=GpkgInstall, type="string", + help="installs the GEXFILE", metavar="GEXFILE", + nargs=1 ) + parser.add_option ( "-d", "--details", action="callback", + callback=GpkgDetails, type="string", + help="print details about GEXFILE", metavar="GEXFILE", + nargs=1 ) + parser.add_option ( "-l", "--list-apps", action="callback", + callback=GpkgListApps, help="list all applications", + nargs=0 ) + (options, args) = parser.parse_args () + if not arg_given: + parser.print_help () return - main ();