test 508 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/env python3

import os
import sys
import subprocess


def flash():
    pipe = subprocess.PIPE
    p = subprocess.Popen(['platformio', 'run', '-e', 'uno', '--target', 'upload'],
            stdout=sys.stderr, stdin=pipe)
    stdout, stderr = p.communicate("") 

def main(argv):
    print(argv[0], file=sys.stderr)
    script_dir = os.path.split(argv[0])[0]
    if len(script_dir) > 0:
        os.chdir(script_dir)
    flash()
    return 0;


if __name__ == "__main__":
    sys.exit(main(sys.argv))