From 059269d7324bddebaae9a6cbc721b82b8636a843 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 7 May 2019 20:54:01 -0500 Subject: [PATCH] More python updates Followup to #13931 --- buildroot/share/atom/auto_build.py | 40 ++++++++++--------- .../atom/create_custom_upload_command_CDC.py | 4 +- .../scripts/createTemperatureLookupMarlin.py | 2 +- buildroot/share/scripts/g29_auto.py | 2 +- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/buildroot/share/atom/auto_build.py b/buildroot/share/atom/auto_build.py index b51d598f7..6eceb7fab 100644 --- a/buildroot/share/atom/auto_build.py +++ b/buildroot/share/atom/auto_build.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python ####################################### # # Marlin 3D Printer Firmware @@ -68,6 +69,9 @@ # ####################################### +from __future__ import print_function +from __future__ import division + import sys import os @@ -76,26 +80,26 @@ pwd = pwd.replace('\\', '/') if 0 <= pwd.find('buildroot/share/atom'): pwd = pwd[ : pwd.find('buildroot/share/atom')] os.chdir(pwd) -print 'pwd: ', pwd +print('pwd: ', pwd) num_args = len(sys.argv) if num_args > 1: build_type = str(sys.argv[1]) else: - print 'Please specify build type' + print('Please specify build type') exit() -print'build_type: ', build_type +print('build_type: ', build_type) -print '\nWorking\n' +print('\nWorking\n') python_ver = sys.version_info[0] # major version - 2 or 3 if python_ver == 2: - print "python version " + str(sys.version_info[0]) + "." + str(sys.version_info[1]) + "." + str(sys.version_info[2]) + print("python version " + str(sys.version_info[0]) + "." + str(sys.version_info[1]) + "." + str(sys.version_info[2])) else: - print "python version " + str(sys.version_info[0]) - print "This script only runs under python 2" + print("python version " + str(sys.version_info[0])) + print("This script only runs under python 2") exit() import platform @@ -544,13 +548,13 @@ def get_CPU_name(environment): # returns: environment def get_env(board_name, ver_Marlin): def no_environment(): - print 'ERROR - no environment for this board' - print board_name + print('ERROR - no environment for this board') + print(board_name) raise SystemExit(0) # no environment so quit def invalid_board(): - print 'ERROR - invalid board' - print board_name + print('ERROR - invalid board') + print(board_name) raise SystemExit(0) # quit if unable to find board @@ -601,9 +605,9 @@ def get_env(board_name, ver_Marlin): invalid_board() if build_type == 'traceback' and not(target_env == 'LPC1768_debug_and_upload' or target_env == 'DUE_debug') and Marlin_ver == 2: - print "ERROR - this board isn't setup for traceback" - print 'board_name: ', board_name - print 'target_env: ', target_env + print("ERROR - this board isn't setup for traceback") + print('board_name: ', board_name) + print('target_env: ', target_env) raise SystemExit(0) return target_env @@ -825,12 +829,12 @@ def run_PIO(dummy): global build_type global target_env global board_name - print 'build_type: ', build_type + print('build_type: ', build_type) import subprocess import sys - print 'starting platformio' + print('starting platformio') if build_type == 'build': # platformio run -e target_env @@ -881,7 +885,7 @@ def run_PIO(dummy): else: - print 'ERROR - unknown build type: ', build_type + print('ERROR - unknown build type: ', build_type) raise SystemExit(0) # kill everything # stream output from subprocess and split it into lines @@ -1099,7 +1103,7 @@ class output_window(Text): self.start_thread() def rebuild(self, event): - print "event happened" + print("event happened") self._rebuild() diff --git a/buildroot/share/atom/create_custom_upload_command_CDC.py b/buildroot/share/atom/create_custom_upload_command_CDC.py index 46df38729..484842f77 100644 --- a/buildroot/share/atom/create_custom_upload_command_CDC.py +++ b/buildroot/share/atom/create_custom_upload_command_CDC.py @@ -84,8 +84,8 @@ else: if com_CDC == 'COM_PORT_NOT_FOUND': print(com_CDC, '\n') else: - print('FOUND: ' ,com_CDC) - print('DESCRIPTION: ', description_CDC , '\n') + print('FOUND: ', com_CDC) + print('DESCRIPTION: ', description_CDC, '\n') if current_OS == 'Windows': diff --git a/buildroot/share/scripts/createTemperatureLookupMarlin.py b/buildroot/share/scripts/createTemperatureLookupMarlin.py index 15fe217d3..03450bc0e 100755 --- a/buildroot/share/scripts/createTemperatureLookupMarlin.py +++ b/buildroot/share/scripts/createTemperatureLookupMarlin.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python """Thermistor Value Lookup Table Generator Generates lookup to temperature values for use in a microcontroller in C format based on: diff --git a/buildroot/share/scripts/g29_auto.py b/buildroot/share/scripts/g29_auto.py index 608fa0c0f..ffcb0d9f3 100755 --- a/buildroot/share/scripts/g29_auto.py +++ b/buildroot/share/scripts/g29_auto.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # This file is for preprocessing gcode and the new G29 Autobedleveling from Marlin # It will analyse the first 2 Layer and return the maximum size for this part