From 03df3f4a88dd8ad5467905ea79d85866196045c9 Mon Sep 17 00:00:00 2001
From: Tanguy Pruvot <tpruvot@users.noreply.github.com>
Date: Tue, 13 Aug 2019 02:50:34 +0200
Subject: [PATCH] Fix Python scripts unhandled quotes (#14926)

---
 buildroot/share/PlatformIO/scripts/alfawise_Ux0.py          | 5 +++--
 buildroot/share/PlatformIO/scripts/fysetc_STM32F1.py        | 6 +++---
 .../PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py   | 2 +-
 buildroot/share/PlatformIO/scripts/mks_robin.py             | 2 +-
 buildroot/share/PlatformIO/scripts/mks_robin_lite.py        | 2 +-
 buildroot/share/PlatformIO/scripts/mks_robin_mini.py        | 2 +-
 buildroot/share/PlatformIO/scripts/mks_robin_nano.py        | 2 +-
 7 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/buildroot/share/PlatformIO/scripts/alfawise_Ux0.py b/buildroot/share/PlatformIO/scripts/alfawise_Ux0.py
index 055f95cc70..e2716a76be 100644
--- a/buildroot/share/PlatformIO/scripts/alfawise_Ux0.py
+++ b/buildroot/share/PlatformIO/scripts/alfawise_Ux0.py
@@ -7,7 +7,7 @@ for define in env['CPPDEFINES']:
 env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08010000"))
 env.Replace(LDSCRIPT_PATH="buildroot/share/PlatformIO/ldscripts/alfawise_Ux0.ld")
 
-# Encrypt ${PROGNAME}.bin and save it as 'project.bin'
+# Rename ${PROGNAME}.bin and save it as 'project.bin' (No encryption on the Longer3D)
 def encrypt(source, target, env):
     import os
 
@@ -23,4 +23,5 @@ def encrypt(source, target, env):
     finally:
         firmware.close()
         marlin_alfa.close()
-env.AddPostAction('"$BUILD_DIR/${PROGNAME}.bin"', encrypt);
+
+env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
diff --git a/buildroot/share/PlatformIO/scripts/fysetc_STM32F1.py b/buildroot/share/PlatformIO/scripts/fysetc_STM32F1.py
index c34b921454..845e582f77 100644
--- a/buildroot/share/PlatformIO/scripts/fysetc_STM32F1.py
+++ b/buildroot/share/PlatformIO/scripts/fysetc_STM32F1.py
@@ -12,7 +12,7 @@ env.AddPostAction(
 	join("$BUILD_DIR","${PROGNAME}.elf"),
 	env.VerboseAction(" ".join([
 		"$OBJCOPY", "-O ihex", "$TARGET", # TARGET=.pio/build/fysetc_STM32F1/firmware.elf
-		"'" + join("$BUILD_DIR","${PROGNAME}.hex") + "'", # Note: $BUILD_DIR is a full path
+		"\"" + join("$BUILD_DIR","${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path
 	]), "Building $TARGET"))
 
 # please keep $SOURCE variable, it will be replaced with a path to firmware
@@ -27,11 +27,11 @@ env.AddPostAction(
 UPLOAD_TOOL="stm32flash"
 platform = env.PioPlatform()
 if platform.get_package_dir("tool-stm32duino") != None:
-	UPLOAD_TOOL=expandvars("'" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "'")
+	UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"")
 
 env.Replace(
 	UPLOADER=UPLOAD_TOOL,
-	UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr $UPLOAD_PORT -R -w '" + join("$BUILD_DIR","${PROGNAME}.hex") + "'")
+	UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr $UPLOAD_PORT -R -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"")
 )
 
 # Python callback
diff --git a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py
index 25c1d96929..89e7b3bc1c 100644
--- a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py
+++ b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py
@@ -39,5 +39,5 @@ def addboot(source,target,env):
 	os.rename(target[0].path, firmware_without_bootloader_dir)
 	#os.rename(target[0].dir.path+'/firmware_with_bootloader.bin', target[0].dir.path+'/firmware.bin')
 
-env.AddPostAction('"$BUILD_DIR/${PROGNAME}.bin"', addboot);
+env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", addboot);
 
diff --git a/buildroot/share/PlatformIO/scripts/mks_robin.py b/buildroot/share/PlatformIO/scripts/mks_robin.py
index fec6c0ea9b..742f4cd173 100644
--- a/buildroot/share/PlatformIO/scripts/mks_robin.py
+++ b/buildroot/share/PlatformIO/scripts/mks_robin.py
@@ -27,4 +27,4 @@ def encrypt(source, target, env):
     finally:
         firmware.close()
         robin.close()
-env.AddPostAction('"$BUILD_DIR/${PROGNAME}.bin"', encrypt);
+env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_lite.py b/buildroot/share/PlatformIO/scripts/mks_robin_lite.py
index 4d28d3ff0c..c11bbb37f6 100644
--- a/buildroot/share/PlatformIO/scripts/mks_robin_lite.py
+++ b/buildroot/share/PlatformIO/scripts/mks_robin_lite.py
@@ -27,4 +27,4 @@ def encrypt(source, target, env):
     finally:
         firmware.close()
         robin.close()
-env.AddPostAction('"$BUILD_DIR/${PROGNAME}.bin"', encrypt);
+env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py
index 5247eaf171..2b3ba6f90d 100755
--- a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py
+++ b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py
@@ -27,4 +27,4 @@ def encrypt(source, target, env):
     finally:
         firmware.close()
         robin.close()
-env.AddPostAction('"$BUILD_DIR/${PROGNAME}.bin"', encrypt);
+env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py b/buildroot/share/PlatformIO/scripts/mks_robin_nano.py
index feb9b2e4e3..eb8bca9b52 100755
--- a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py
+++ b/buildroot/share/PlatformIO/scripts/mks_robin_nano.py
@@ -27,4 +27,4 @@ def encrypt(source, target, env):
     finally:
         firmware.close()
         robin.close()
-env.AddPostAction('"$BUILD_DIR/${PROGNAME}.bin"', encrypt);
+env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);
-- 
GitLab