set-port-name.py 784 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python
  2. # PYTHON_ARGCOMPLETE_OK
  3. import sys
  4. import jack
  5. import time
  6. import random
  7. import argparse
  8. def run():
  9. client = jack.Client("set port name example");
  10. print("client name: " + client.get_name())
  11. port = random.choice(client.get_ports())
  12. print(port)
  13. # reverse
  14. port.set_short_name(port.get_short_name()[::-1])
  15. print(port)
  16. def _init_argparser():
  17. argparser = argparse.ArgumentParser(description = None)
  18. return argparser
  19. def main(argv):
  20. argparser = _init_argparser()
  21. try:
  22. import argcomplete
  23. argcomplete.autocomplete(argparser)
  24. except ImportError:
  25. pass
  26. args = argparser.parse_args(argv)
  27. run(**vars(args))
  28. return 0
  29. if __name__ == "__main__":
  30. sys.exit(main(sys.argv[1:]))