MCPcopy Create free account
hub / github.com/NetSys/bess / parse_args

Function parse_args

bin/dpdk-devbind.py:628–668  ·  view source on GitHub ↗

Parses the command-line arguments given by the user and takes the appropriate action for each

()

Source from the content-addressed store, hash-verified

626 show_device_status(mempool_devices, "Mempool")
627
628def parse_args():
629 '''Parses the command-line arguments given by the user and takes the
630 appropriate action for each'''
631 global b_flag
632 global status_flag
633 global status_dev
634 global force_flag
635 global args
636 if len(sys.argv) <= 1:
637 usage()
638 sys.exit(0)
639
640 try:
641 opts, args = getopt.getopt(sys.argv[1:], "b:us",
642 ["help", "usage", "status", "status-dev=",
643 "force", "bind=", "unbind", ])
644 except getopt.GetoptError as error:
645 print(str(error))
646 print("Run '%s --usage' for further information" % sys.argv[0])
647 sys.exit(1)
648
649 for opt, arg in opts:
650 if opt == "--help" or opt == "--usage":
651 usage()
652 sys.exit(0)
653 if opt == "--status-dev":
654 status_flag = True
655 status_dev = arg
656 if opt == "--status" or opt == "-s":
657 status_flag = True
658 status_dev = "all"
659 if opt == "--force":
660 force_flag = True
661 if opt == "-b" or opt == "-u" or opt == "--bind" or opt == "--unbind":
662 if b_flag is not None:
663 print("Error - Only one bind or unbind may be specified\n")
664 sys.exit(1)
665 if opt == "-u" or opt == "--unbind":
666 b_flag = "none"
667 else:
668 b_flag = arg
669
670
671def do_arg_actions():

Callers 1

mainFunction · 0.85

Calls 1

usageFunction · 0.85

Tested by

no test coverage detected