Created
January 27, 2019 14:08
-
-
Save N-McA/62d19683d87a1b2d67e76a1ffebf2661 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import subprocess | |
import shlex | |
import os | |
from pathlib import Path | |
def chdir_to_script_location(): | |
abspath = os.path.abspath(__file__) | |
dname = os.path.dirname(abspath) | |
os.chdir(dname) | |
def run(cmd, ignore_fail=False): | |
check = not ignore_fail | |
return subprocess.run( | |
shlex.split(cmd), check=check, stdout=subprocess.PIPE | |
).stdout.decode("UTF-8") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment