AutoBuild compatibility with Python3 (#15331)
This commit is contained in:
parent
7fc4f7b815
commit
4e5941fa57
@ -95,12 +95,7 @@ print('\nWorking\n')
|
|||||||
|
|
||||||
python_ver = sys.version_info[0] # major version - 2 or 3
|
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")
|
|
||||||
exit()
|
|
||||||
|
|
||||||
import platform
|
import platform
|
||||||
current_OS = platform.system()
|
current_OS = platform.system()
|
||||||
@ -135,9 +130,9 @@ def get_answer(board_name, cpu_label_txt, cpu_a_txt, cpu_b_txt):
|
|||||||
|
|
||||||
|
|
||||||
if python_ver == 2:
|
if python_ver == 2:
|
||||||
import Tkinter as tk
|
import Tkinter as tk
|
||||||
else:
|
else:
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
|
||||||
def CPU_exit_3(): # forward declare functions
|
def CPU_exit_3(): # forward declare functions
|
||||||
|
|
||||||
@ -615,9 +610,12 @@ def get_env(board_name, ver_Marlin):
|
|||||||
# end - get_env
|
# end - get_env
|
||||||
|
|
||||||
# puts screen text into queue so that the parent thread can fetch the data from this thread
|
# puts screen text into queue so that the parent thread can fetch the data from this thread
|
||||||
import Queue
|
if python_ver == 2:
|
||||||
IO_queue = Queue.Queue()
|
import Queue as queue
|
||||||
PIO_queue = Queue.Queue()
|
else:
|
||||||
|
import queue as queue
|
||||||
|
IO_queue = queue.Queue()
|
||||||
|
#PIO_queue = queue.Queue() not used!
|
||||||
def write_to_screen_queue(text, format_tag = 'normal'):
|
def write_to_screen_queue(text, format_tag = 'normal'):
|
||||||
double_in = [text, format_tag]
|
double_in = [text, format_tag]
|
||||||
IO_queue.put(double_in, block = False)
|
IO_queue.put(double_in, block = False)
|
||||||
@ -940,9 +938,13 @@ def run_PIO(dummy):
|
|||||||
raise SystemExit(0) # kill everything
|
raise SystemExit(0) # kill everything
|
||||||
|
|
||||||
# stream output from subprocess and split it into lines
|
# stream output from subprocess and split it into lines
|
||||||
for line in iter(pio_subprocess.stdout.readline, ''):
|
if python_ver == 2:
|
||||||
line_print(line.replace('\n', ''))
|
for line in iter(pio_subprocess.stdout.readline, ''):
|
||||||
|
line_print(line.replace('\n', ''))
|
||||||
|
else:
|
||||||
|
for line in iter(pio_subprocess.stdout.readline, b''):
|
||||||
|
line = line.decode('utf-8')
|
||||||
|
line_print(line.replace('\n', ''))
|
||||||
|
|
||||||
# append info used to run PlatformIO
|
# append info used to run PlatformIO
|
||||||
write_to_screen_queue('\nBoard name: ' + board_name + '\n') # put build info at the bottom of the screen
|
write_to_screen_queue('\nBoard name: ' + board_name + '\n') # put build info at the bottom of the screen
|
||||||
@ -958,21 +960,22 @@ def run_PIO(dummy):
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
import Tkinter as tk
|
if python_ver == 2:
|
||||||
import ttk
|
import Tkinter as tk
|
||||||
import Queue
|
import Queue as queue
|
||||||
|
import ttk
|
||||||
|
from Tkinter import Tk, Frame, Text, Scrollbar, Menu
|
||||||
|
#from tkMessageBox import askokcancel this is not used: removed
|
||||||
|
import tkFileDialog as fileDialog
|
||||||
|
else:
|
||||||
|
import tkinter as tk
|
||||||
|
import queue as queue
|
||||||
|
from tkinter import ttk, Tk, Frame, Text, Scrollbar, Menu
|
||||||
|
from tkinter import filedialog
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
que = Queue.Queue()
|
que = queue.Queue()
|
||||||
#IO_queue = Queue.Queue()
|
#IO_queue = queue.Queue()
|
||||||
|
|
||||||
from Tkinter import Tk, Frame, Text, Scrollbar, Menu
|
|
||||||
from tkMessageBox import askokcancel
|
|
||||||
|
|
||||||
import tkFileDialog
|
|
||||||
from tkMessageBox import askokcancel
|
|
||||||
import tkFileDialog
|
|
||||||
|
|
||||||
|
|
||||||
class output_window(Text):
|
class output_window(Text):
|
||||||
# based on Super Text
|
# based on Super Text
|
||||||
@ -1177,7 +1180,7 @@ class output_window(Text):
|
|||||||
|
|
||||||
|
|
||||||
def _file_save_as(self):
|
def _file_save_as(self):
|
||||||
self.filename = tkFileDialog.asksaveasfilename(defaultextension = '.txt')
|
self.filename = fileDialog.asksaveasfilename(defaultextension = '.txt')
|
||||||
f = open(self.filename, 'w')
|
f = open(self.filename, 'w')
|
||||||
f.write(self.get('1.0', 'end'))
|
f.write(self.get('1.0', 'end'))
|
||||||
f.close()
|
f.close()
|
||||||
@ -1267,33 +1270,28 @@ class output_window(Text):
|
|||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# #
|
# #
|
||||||
# main program #
|
# main program #
|
||||||
# #
|
# #
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
global build_type
|
global build_type
|
||||||
global target_env
|
global target_env
|
||||||
global board_name
|
global board_name
|
||||||
|
|
||||||
board_name, Marlin_ver = get_board_name()
|
board_name, Marlin_ver = get_board_name()
|
||||||
|
|
||||||
target_env = get_env(board_name, Marlin_ver)
|
target_env = get_env(board_name, Marlin_ver)
|
||||||
|
|
||||||
os.environ["BUILD_TYPE"] = build_type # let sub processes know what is happening
|
# Re-use the VSCode terminal, if possible
|
||||||
os.environ["TARGET_ENV"] = target_env
|
if os.environ.get('PLATFORMIO_CALLER', '') == 'vscode':
|
||||||
os.environ["BOARD_NAME"] = board_name
|
sys_PIO()
|
||||||
|
else:
|
||||||
# Re-use the VSCode terminal, if possible
|
auto_build = output_window()
|
||||||
if os.environ.get('PLATFORMIO_CALLER', '') == 'vscode':
|
auto_build.start_thread() # executes the "run_PIO" function
|
||||||
sys_PIO()
|
|
||||||
else:
|
|
||||||
auto_build = output_window()
|
|
||||||
auto_build.start_thread() # executes the "run_PIO" function
|
|
||||||
|
|
||||||
auto_build.root.mainloop()
|
|
||||||
|
|
||||||
|
auto_build.root.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user