Skip to content

Commit 1117dfa

Browse files
authored
Merge pull request #237 from sandialabs/patch_import_errors
bug(drivers): Fixed driver import exceptions to actually load driver
2 parents 488b33a + e4f5955 commit 1117dfa

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import sys
22

33
name = 'pylablib'
4-
5-
if name in sys.modules:
4+
try:
5+
import pylablib
66
from .attocubeANC350 import AttocubeANC350
7-
else:
7+
except ModuleNotFoundError:
88
from .attocube_exceptions import PylabLibMissingException as AttocubeANC350

pyscan/drivers/heliotis/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
name = 'libHeLIC'
44

5-
if name in sys.modules:
5+
try:
6+
import libHeLIC
67
from .helioscamera import HeliosCamera
7-
else:
8+
except ModuleNotFoundError:
89
from .helios_exceptions import HeliosImportException as HeliosCamera

pyscan/drivers/oceanoptics/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# For illustrative purposes.
44
name = 'seabreeze'
55

6-
if name in sys.modules:
6+
try:
7+
import seabreeze
78
from .oceanopticsqepro import OceanOpticsQEPro
8-
else:
9+
except ModuleNotFoundError:
910
from .oceanoptics_exceptions import SeabreezeMissingException as OceanOpticsQEPro

pyscan/drivers/thorlabs/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
import importlib.util
33
import sys
44

5-
name = 'thorlabs_kinesis'
6-
7-
8-
if name in sys.modules:
5+
try:
6+
import pyscan_tlk
97
from .thorlabsbpc303 import ThorlabsBPC303
108
from .thorlabsbsc203 import ThorlabsBSC203
119
from .thorlabsmff101 import ThorlabsMFF101
12-
else:
10+
except ModuleNotFoundError:
1311
from .thorlabs_exceptions import ThorlabsKinesisImportException as ThorlabsBPC303
1412
from .thorlabs_exceptions import ThorlabsKinesisImportException as ThorlabsBSC203
1513
from .thorlabs_exceptions import ThorlabsKinesisImportException as ThorlabsMFF101

0 commit comments

Comments
 (0)