1
0

external plugins: add methods to read image files

This commit is contained in:
ThomasV
2024-04-07 11:17:22 +02:00
parent 858d999d31
commit ad774a49be
2 changed files with 12 additions and 0 deletions

View File

@@ -422,6 +422,14 @@ class BasePlugin(Logger):
def settings_dialog(self, window):
raise NotImplementedError()
def read_file(self, filename: str) -> bytes:
""" note: only for external plugins """
import zipfile
plugin_file_path = os.path.join(self.parent.get_external_plugin_dir(), self.name + '.zip')
with zipfile.ZipFile(plugin_file_path) as myzip:
with myzip.open(os.path.join(self.name, filename)) as myfile:
s = myfile.read()
return s
class DeviceUnpairableError(UserFacingException): pass
class HardwarePluginLibraryUnavailable(Exception): pass