From 60e199b0bd12e4bb109146f5a5741b24f70c844f Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 24 Oct 2016 22:17:02 -0700 Subject: [PATCH] Fixes format.py on windows (#293) --- styleguide/format.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/styleguide/format.py b/styleguide/format.py index 3f2d485f68..ed55708de1 100755 --- a/styleguide/format.py +++ b/styleguide/format.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 - """This script invokes format.py in the wpilibsuite/styleguide repository. Set the WPI_FORMAT environment variable to its location on disk before use. For @@ -12,17 +11,26 @@ import os import subprocess import sys + def main(): path = os.environ.get("WPI_FORMAT") if path == None: print("Error: WPI_FORMAT environment variable not set") sys.exit(1) - # Run main format.py script - args = ["python3", path + "/format.py"] - args.extend(sys.argv[1:]) - proc = subprocess.Popen(args) - sys.exit(proc.wait()) + try: + # Run main format.py script + args = ["python3", path + "/format.py"] + args.extend(sys.argv[1:]) + proc = subprocess.Popen(args) + sys.exit(proc.wait()) + except FileNotFoundError: + # Run main format.py script on windows + args = ["py", "-3", path + "/format.py"] + args.extend(sys.argv[1:]) + proc = subprocess.Popen(args) + sys.exit(proc.wait()) + if __name__ == "__main__": main()