def parse_args(self):
(options, args) = OptionParser.parse_args(self)
try:
options.proto_num = socket.getprotobyname(options.protocol)
except socket.error:
exit("Unsupported protocol " + options.protocol)
for f in ('bind_address','listen_address','connect_address'):
setattr(options,f,addrparse(getattr(options,f,None)))
for f in ('starttime','stoptime'):
val=getattr(options,f,None)
try:
setattr(options,f,float(val))
continue
except ValueError:
pass
try:
ts=datetime.datetime.now()
t=datetime.datetime.strptime(val,'%H:%M:%S')
ts=ts.replace(hour=t.hour,minute=t.minute,second=t.second)
setattr(options,f,float(ts.strftime("%Y%m%d%H%M%S")))
except ValueError:
exit("Invalid time %s" % val)
return options, args
评论列表
文章目录