Skip to content

Commit 7b22e91

Browse files
committed
update thonny backend
1 parent 57c232b commit 7b22e91

16 files changed

+42
-54
lines changed

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from setuptools import setup, find_packages
22

3+
VERSION = "0.1.9"
4+
35

46
def readme():
57
with open('README.rst', encoding='utf-8') as f:
@@ -8,9 +10,7 @@ def readme():
810

911

1012
def get_version():
11-
with open('VERSION', encoding='utf-8') as f:
12-
version = f.read()
13-
return version
13+
return VERSION
1414

1515

1616
setup(
@@ -43,6 +43,10 @@ def get_version():
4343
"thonnycontrib.quecpython.locale": [
4444
"zh_CN.lag",
4545
],
46+
"thonnycontrib.quecpython.backend": [
47+
"base_api_stubs/*",
48+
"generic_api_stubs/*",
49+
]
4650
},
4751
install_requires=[
4852
'thonny>=4.1.1',

thonnycontrib/quecpython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from thonny import get_workbench
2-
from thonny.plugins.quecpython.backend.mp_front import (
2+
from .backend.mp_front import (
33
add_quecpython_backend,
44
GenericBareMetalQuecPythonConfigPage,
55
GenericBareMetalQuecPythonProxy
Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +0,0 @@
1-
2-
from thonny.plugins.quecpython.backend.mp_front import (
3-
BareMetalQuecPythonConfigPage,
4-
BareMetalQuecPythonProxy,
5-
GenericBareMetalQuecPythonConfigPage,
6-
GenericBareMetalQuecPythonProxy,
7-
LocalQuecPythonConfigPage,
8-
LocalQuecPythonProxy,
9-
QuecPythonProxy,
10-
SshQuecPythonConfigPage,
11-
SshQuecPythonProxy,
12-
add_quecpython_backend,
13-
list_serial_ports,
14-
)

thonnycontrib/quecpython/backend/bare_metal_backend.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
serialize_message,
2727
)
2828
from thonny.misc_utils import find_volumes_by_name
29-
from thonny.plugins.quecpython.backend.connection import QuecPythonConnection
30-
from thonny.plugins.quecpython.backend.mp_back import (
29+
from thonnycontrib.quecpython.backend.connection import QuecPythonConnection
30+
from thonnycontrib.quecpython.backend.mp_back import (
3131
EOT,
3232
NORMAL_MODE_CMD,
3333
PASTE_MODE_CMD,
@@ -44,12 +44,12 @@
4444
is_continuation_byte,
4545
starts_with_continuation_byte,
4646
)
47-
from thonny.plugins.quecpython.backend.mp_common import (
47+
from thonnycontrib.quecpython.backend.mp_common import (
4848
PASTE_SUBMIT_MODE,
4949
RAW_PASTE_SUBMIT_MODE,
5050
RAW_SUBMIT_MODE,
5151
)
52-
from thonny.plugins.quecpython.backend.webrepl_connection import WebReplConnection
52+
from thonnycontrib.quecpython.backend.webrepl_connection import WebReplConnection
5353

5454
RAW_PASTE_COMMAND = b"\x05A\x01"
5555
RAW_PASTE_CONFIRMATION = b"R\x01"
@@ -122,7 +122,7 @@
122122
]
123123

124124
# Can't use __name__, because it will be "__main__"
125-
logger = getLogger("thonny.plugins.quecpython.backend.bare_metal_backend")
125+
logger = getLogger(".bare_metal_backend")
126126

127127

128128
class BareMetalQuecPythonBackend(QuecPythonBackend, UploadDownloadMixin):
@@ -207,7 +207,7 @@ def rmdir(cls, x):
207207
if self._read_block_size and self._read_block_size > 0:
208208
# make sure management prints are done in blocks
209209
result = result.replace("cls.builtins.print", "cls.controlled_print")
210-
from thonny.plugins.quecpython.backend.serial_connection import OUTPUT_ENQ
210+
from thonnycontrib.quecpython.backend.serial_connection import OUTPUT_ENQ
211211

212212
result += indent(
213213
dedent(
@@ -544,7 +544,7 @@ def _check_reconnect(self):
544544
self._connection = self._connection.close_and_return_new_connection()
545545

546546
def _connected_over_webrepl(self):
547-
from thonny.plugins.quecpython.backend.webrepl_connection import WebReplConnection
547+
from thonnycontrib.quecpython.backend.webrepl_connection import WebReplConnection
548548

549549
return isinstance(self._connection, WebReplConnection)
550550

@@ -1737,7 +1737,7 @@ def launch_bare_metal_backend(backend_class: Callable[..., BareMetalQuecPythonBa
17371737
elif args["port"] == "webrepl":
17381738
connection = WebReplConnection(args["url"], args["password"])
17391739
else:
1740-
from thonny.plugins.quecpython.backend.serial_connection import (
1740+
from thonnycontrib.quecpython.backend.serial_connection import (
17411741
DifficultSerialConnection,
17421742
SerialConnection,
17431743
)

thonnycontrib/quecpython/backend/base_flashing_dialog.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ def is_ready_for_work(self):
401401
return self._target_combo.get_selected_value() and self._version_combo.get_selected_value()
402402

403403
def start_work(self):
404-
from thonny.plugins.quecpython.backend import BareMetalQuecPythonProxy
405404

406405
variant_info: Dict[str, Any] = self._variant_combo.get_selected_value()
407406
download_info: Dict[str, Any] = self._version_combo.get_selected_value()

thonnycontrib/quecpython/backend/esptool_dialog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
from thonny import get_runner, get_workbench, ui_utils
1313
from thonny.common import normpath_with_actual_case
1414
from thonny.misc_utils import get_menu_char, running_on_windows
15-
from thonny.plugins.quecpython.backend import BareMetalQuecPythonProxy, list_serial_ports
16-
from thonny.plugins.quecpython.backend.base_flashing_dialog import (
15+
from thonnycontrib.quecpython.backend.mp_front import BareMetalQuecPythonProxy, list_serial_ports
16+
from thonnycontrib.quecpython.backend.base_flashing_dialog import (
1717
BaseFlashingDialog,
1818
TargetInfo,
1919
family_code_to_name,
2020
)
21-
from thonny.plugins.quecpython.backend.mp_front import get_serial_port_label
21+
from thonnycontrib.quecpython.backend.mp_front import get_serial_port_label
2222
from thonny.running import get_front_interpreter_for_subprocess
2323
from thonny.ui_utils import EnhancedBooleanVar, MappingCombobox
2424

thonnycontrib/quecpython/backend/mp_back.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
parse_message,
7676
serialize_message,
7777
)
78-
from thonny.plugins.quecpython.backend.connection import QuecPythonConnection
78+
from thonnycontrib.quecpython.backend.connection import QuecPythonConnection
7979

8080
ENCODING = "utf-8"
8181

thonnycontrib/quecpython/backend/mp_front.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def get_target_executable(self) -> Optional[str]:
9696
return None
9797

9898
def get_pip_gui_class(self):
99-
from thonny.plugins.quecpython.backend.pip_gui import QuecPythonPipDialog
99+
from thonnycontrib.quecpython.backend.pip_gui import QuecPythonPipDialog
100100

101101
return QuecPythonPipDialog
102102

@@ -170,9 +170,9 @@ def stop_restart_kills_user_program(self) -> bool:
170170
return False
171171

172172
def _get_backend_launcher_path(self) -> str:
173-
import thonny.plugins.quecpython.backend.bare_metal_backend
173+
from thonnycontrib.quecpython.backend import bare_metal_backend
174174

175-
return thonny.plugins.quecpython.backend.bare_metal_backend.__file__
175+
return bare_metal_backend.__file__
176176

177177
def _get_write_block_size(self):
178178
return get_workbench().get_option(self.backend_name + ".write_block_size")
@@ -394,7 +394,7 @@ def open_custom_system_shell(self):
394394
running.get_front_interpreter_for_subprocess(sys.executable),
395395
"-m",
396396
# "serial.tools.miniterm",
397-
"thonny.plugins.quecpython.backend.miniterm_wrapper",
397+
"thonnycontrib.quecpython.backend.miniterm_wrapper",
398398
"--exit-char",
399399
"20",
400400
"--menu-char",
@@ -700,10 +700,10 @@ def get_target_executable(self) -> Optional[str]:
700700
return self._target_executable
701701

702702
def _get_launcher_with_args(self):
703-
import thonny.plugins.quecpython.backend.os_mp_backend
703+
from thonnycontrib.quecpython.backend import os_mp_backend
704704

705705
cmd = [
706-
thonny.plugins.quecpython.backend.os_mp_backend.__file__,
706+
os_mp_backend.__file__,
707707
repr(
708708
{
709709
"interpreter": self._target_executable,
@@ -829,7 +829,7 @@ def __init__(self, clean):
829829
super().__init__(clean)
830830

831831
def _get_launcher_with_args(self):
832-
import thonny.plugins.quecpython.backend.os_mp_backend
832+
from thonnycontrib.quecpython.backend import os_mp_backend
833833

834834
args = {
835835
"cwd": get_workbench().get_option(f"{self.backend_name}.cwd") or "",
@@ -842,7 +842,7 @@ def _get_launcher_with_args(self):
842842
args.update(self._get_extra_launcher_args())
843843

844844
cmd = [
845-
thonny.plugins.quecpython.backend.os_mp_backend.__file__,
845+
os_mp_backend.__file__,
846846
repr(args),
847847
]
848848
return cmd

thonnycontrib/quecpython/backend/os_mp_backend.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
from thonny import report_time
2020
from thonny.backend import SshMixin
2121
from thonny.common import PROCESS_ACK, BackendEvent, serialize_message
22-
from thonny.plugins.quecpython.backend.bare_metal_backend import LF, NORMAL_PROMPT
23-
from thonny.plugins.quecpython.backend.connection import QuecPythonConnection
24-
from thonny.plugins.quecpython.backend.mp_back import (
22+
from thonnycontrib.quecpython.backend.bare_metal_backend import LF, NORMAL_PROMPT
23+
from thonnycontrib.quecpython.backend.connection import QuecPythonConnection
24+
from thonnycontrib.quecpython.backend.mp_back import (
2525
ENCODING,
2626
EOT,
2727
PASTE_MODE_CMD,
@@ -30,10 +30,10 @@
3030
QuecPythonBackend,
3131
ends_overlap,
3232
)
33-
from thonny.plugins.quecpython.backend.mp_common import PASTE_SUBMIT_MODE
33+
from thonnycontrib.quecpython.backend.mp_common import PASTE_SUBMIT_MODE
3434

3535
# Can't use __name__, because it will be "__main__"
36-
logger = getLogger("thonny.plugins.quecpython.backend.os_mp_backend")
36+
logger = getLogger("thonnycontrib.quecpython.backend.os_mp_backend")
3737

3838

3939
FALLBACK_BUILTIN_MODULES = [
@@ -317,7 +317,7 @@ def _extract_block_without_splitting_chars(self, source_bytes: bytes) -> bytes:
317317

318318
class LocalUnixMicroPythonBackend(UnixQuecPythonBackend):
319319
def _create_connection(self, run_args=[]):
320-
from thonny.plugins.quecpython.backend.subprocess_connection import SubprocessConnection
320+
from thonnycontrib.quecpython.backend.subprocess_connection import SubprocessConnection
321321

322322
return SubprocessConnection(self._interpreter, ["-i"] + run_args)
323323

@@ -357,7 +357,7 @@ def _which(self, executable):
357357

358358
def _create_connection(self, run_args=[]):
359359
# NB! It's connection to the micropython process, not to the host
360-
from thonny.plugins.quecpython.backend.ssh_connection import SshProcessConnection
360+
from thonnycontrib.quecpython.backend.ssh_connection import SshProcessConnection
361361

362362
return SshProcessConnection(
363363
self._client,

0 commit comments

Comments
 (0)