start.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:paho.mqtt.testing 作者: eclipse 项目源码 文件源码
def main(argv):
  try:
    opts, args = getopt.gnu_getopt(argv[1:], "hp:o:d:z:", ["help", "publish_on_pubrel=", "overlapping_single=", 
        "dropQoS0=", "port=", "zero_length_clientids="])
  except getopt.GetoptError as err:
    print(err) # will print something like "option -a not recognized"
    usage()
    sys.exit(2)
  publish_on_pubrel = overlapping_single = dropQoS0 = zero_length_clientids = True
  port = 1883
  for o, a in opts:
    if o in ("-h", "--help"):
      usage()
      sys.exit()
    elif o in ("-p", "--publish_on_pubrel"):
      publish_on_pubrel = False if a in ["off", "false", "0"] else True
    elif o in ("-o", "--overlapping_single"):
      overlapping_single = False if a in ["off", "false", "0"] else True
    elif o in ("-d", "--dropQoS0"):
      dropQoS0 = False if a in ["off", "false", "0"] else True
    elif o in ("-z", "--zero_length_clientids"):
      zero_length_clientids = False if a in ["off", "false", "0"] else True
    elif o in ("--port"):
      port = int(a)
    else:
      assert False, "unhandled option"

  run(publish_on_pubrel=publish_on_pubrel, overlapping_single=overlapping_single, dropQoS0=dropQoS0, port=port,
     zero_length_clientids=zero_length_clientids)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号