You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
647B

  1. import subprocess
  2. def system(cmd):
  3. print(cmd)
  4. result = subprocess.run(cmd, shell=True)
  5. if result.returncode != 0:
  6. raise Exception(f"Command failed with error {result.returncode}: {cmd}")
  7. def system_retry(cmd):
  8. while True:
  9. try:
  10. system(cmd)
  11. break
  12. except Exception as error:
  13. print(error)
  14. print("Enter to retry")
  15. input()
  16. def run(cmd):
  17. print(cmd)
  18. result = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE)
  19. if result.returncode != 0:
  20. raise Exception(f"Command failed with error {result.returncode}: {cmd}")
  21. return result.stdout.decode('utf-8')
  22. def find(list, f):
  23. return next((x for x in list if f(x)), None)