tools/pyboard.py: Keep ProcessToSerial class in global scope

Considering ProcessToSerial is a part of the public API of this file, it is defined in the global scope. This leaves the Pyboard class code unchanged.
pull/8435/head
Victor Malai 2022-04-04 11:12:36 +02:00 zatwierdzone przez GitHub
rodzic 0e16b2e33b
commit 6889dde7f5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 7 dodań i 6 usunięć

Wyświetl plik

@ -263,6 +263,12 @@ class ProcessToSerialPosix:
return 1
return 0
# Class selector based on select module platform dependancy (available on Unix, but not on Windows)
import select
if hasattr(select, "poll"):
ProcessToSerial = ProcessToSerialPosix
else:
ProcessToSerial = ProcessToSerialThreading
class ProcessPtyToTerminal:
"""Execute a process which creates a PTY and prints slave PTY as
@ -316,12 +322,7 @@ class Pyboard:
self.in_raw_repl = False
self.use_raw_paste = True
if device.startswith("exec:"):
# Class selector based on select module platform dependancy (available on Unix, but not on Windows)
import select
if hasattr(select, "poll"):
self.serial = ProcessToSerialPosix(device[len("exec:") :])
else:
self.serial = ProcessToSerialThreading(device[len("exec:") :])
self.serial = ProcessToSerial(device[len("exec:") :])
elif device.startswith("execpty:"):
self.serial = ProcessPtyToTerminal(device[len("qemupty:") :])
elif device and device[0].isdigit() and device[-1].isdigit() and device.count(".") == 3: