gossip Less, directly on the code
??
?#!/usr/bin/env python
#
#
?
Import JSON
import getopt, sys
def usage ():
Print sys.argv[0] + ' -I IRT- s status '
Print sys.argv[0] + '-I irt-n seg-t stime '
Print sys.argv[0] + '-H # Get help info '
def parse_cmd_line_param ():
Try:
opts, args = Getopt.getopt (sys.argv[1:], "hi:s:n:t", ["Help", "irt=", "status=", "Seg= "," Stime= "])
except Getopt. Getopterror, err:
# Print Help information and exit;
usage ()
Sys.exit (2)
IRT= None
status = None
seg =0
stime = 0
for OP, value in opts:
if op = = '-I ' or op = = '--irt':
irtmp = value
elif op = = '-S ' or op = = '--status ':
status = Value
elif op = = '-n ' or op = = '--seg ':
Segnum = value
elif op = = '-T ' or op = = '--stime ':
stime = value
elif op = = '-h ':
usage ()
sys.exit ()
print "cmd:irt=%s, status=%s, seg=%d, stime=%d "% (IRT, status, Int (seg), int (stime))
def main ():
Parse_cmd_line_param ()
if __name__ = = "__main__":
Main ()
Python command-line argument parsing instance