From 938ddf742b01039b19145d5fe17b83e9b790e87a Mon Sep 17 00:00:00 2001 From: Enrico Pozzobon Date: Thu, 11 Jul 2019 22:27:46 +0200 Subject: [PATCH] middleware stub for uno --- templates/uno/test | 24 ++++++++++++++++++++++++ test.py | 3 +++ 2 files changed, 27 insertions(+) create mode 100755 templates/uno/test diff --git a/templates/uno/test b/templates/uno/test new file mode 100755 index 0000000..09c90ac --- /dev/null +++ b/templates/uno/test @@ -0,0 +1,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)) diff --git a/test.py b/test.py index bf2756b..295ed86 100755 --- a/test.py +++ b/test.py @@ -23,6 +23,9 @@ def main(argv): def read(l): data = p.stdout.read(l) + if len(data) == 0: + print("Unexpected end of stream", file=sys.stderr) + sys.exit(1) if len(data) != l: raise Exception("could not read %d bytes of data (got %d)" % (l, len(data))) return data -- libgit2 0.26.0