AutoBuild compatibility with Python3 (#15331)
This commit is contained in:
parent
7fc4f7b815
commit
4e5941fa57
1 changed files with 48 additions and 50 deletions
|
@ -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()
|
||||||
|
@ -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
|
||||||
|
if python_ver == 2:
|
||||||
for line in iter(pio_subprocess.stdout.readline, ''):
|
for line in iter(pio_subprocess.stdout.readline, ''):
|
||||||
line_print(line.replace('\n', ''))
|
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
|
||||||
|
if python_ver == 2:
|
||||||
import Tkinter as tk
|
import Tkinter as tk
|
||||||
|
import Queue as queue
|
||||||
import ttk
|
import ttk
|
||||||
import Queue
|
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()
|
||||||
|
@ -1281,10 +1284,6 @@ def main():
|
||||||
|
|
||||||
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
|
|
||||||
os.environ["TARGET_ENV"] = target_env
|
|
||||||
os.environ["BOARD_NAME"] = board_name
|
|
||||||
|
|
||||||
# Re-use the VSCode terminal, if possible
|
# Re-use the VSCode terminal, if possible
|
||||||
if os.environ.get('PLATFORMIO_CALLER', '') == 'vscode':
|
if os.environ.get('PLATFORMIO_CALLER', '') == 'vscode':
|
||||||
sys_PIO()
|
sys_PIO()
|
||||||
|
@ -1296,7 +1295,6 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Reference in a new issue