|
5 | 5 | from asyncio import run, sleep |
6 | 6 | from zipfile import ZipFile |
7 | 7 | from hashlib import sha256 |
| 8 | +from importlib.resources import path |
8 | 9 |
|
9 | | -from pybricksdev.connections import CharacterGlue, USBConnection |
10 | | -from pybricksdev.flash import crc32_checksum |
| 10 | +from . import resources |
| 11 | + |
| 12 | +from .connections import CharacterGlue, USBConnection |
| 13 | +from .flash import crc32_checksum |
11 | 14 |
|
12 | 15 |
|
13 | 16 | class USBREPLConnection(CharacterGlue, USBConnection): |
@@ -128,10 +131,11 @@ async def install(self, firmware_archive_path): |
128 | 131 | await self.upload_file('_pybricks/__init__.py', b'# Intentionally left blank.') |
129 | 132 |
|
130 | 133 | # Upload installation script. |
131 | | - with open('pybricksdev/resources/install_pybricks.py', "rb") as install_script: |
132 | | - install_blob = install_script.read() |
133 | | - install_hash = sha256(install_blob).hexdigest().encode('utf-8') |
134 | | - await self.upload_file('_pybricks/install.py', install_blob) |
| 134 | + with path(resources, resources.INSTALL_PYBRICKS) as install_path: |
| 135 | + with open(install_path, "rb") as install_script: |
| 136 | + install_blob = install_script.read() |
| 137 | + install_hash = sha256(install_blob).hexdigest().encode('utf-8') |
| 138 | + await self.upload_file('_pybricks/install.py', install_blob) |
135 | 139 |
|
136 | 140 | # Upload file with hashes to verify uploaded file integrity. |
137 | 141 | await self.upload_file('_pybricks/hash.txt', pybricks_hash + b"\n" + install_hash + b"\n") |
|
0 commit comments