Skip to content

Commit

Permalink
Added runtime pyjls version check.
Browse files Browse the repository at this point in the history
  • Loading branch information
mliberty1 committed Apr 14, 2023
1 parent ca4144a commit f60c891
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pyjoulescope_driver/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@
import logging


_PYJLS_VERSION_MIN = (0, 5, 0) # inclusive
_PYJLS_VERSION_MAX = (1, 0, 0) # exclusive


try:
from pyjls import Writer, SignalType, DataType
from pyjls import Writer, SignalType, DataType, __version__
_DTYPE_MAP = {
'f32': DataType.F32,
'u8': DataType.U8,
Expand Down Expand Up @@ -131,6 +135,11 @@ def __init__(self, driver, device_path, signals=None):
if Writer is None:
raise RuntimeError('pyjls package not found. Install using:\n' +
' pip3 install -U pyjls')
pyjls_version = [int(x) for x in __version__.split('.')]
if pyjls_version < _PYJLS_VERSION_MIN or pyjls_version >= _PYJLS_VERSION_MAX:
raise ImportError(f'Unsupported pyjls version {__version__}\n' +
f' Require {_PYJLS_VERSION_MIN} <= pyjls version < {_PYJLS_VERSION_MAX}\n' +
' pip3 install -U pyjls')
self._utc_interval = time64.MINUTE
self._log = logging.getLogger(__name__)
self._wr = None
Expand Down

0 comments on commit f60c891

Please sign in to comment.