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.

21 lines
496B

  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 run(cmd):
  8. print(cmd)
  9. result = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE)
  10. if result.returncode != 0:
  11. raise Exception(f"Command failed with error {result.returncode}: {cmd}")
  12. return result.stdout.decode('utf-8')
  13. def find(list, f):
  14. return next((x for x in list if f(x)), None)