Skip to content

Commit a25294c

Browse files
authored
292 put error message if pathfinder is not available (#295)
* Soft close if Pathfinder server not found * Handle no ShankCount input * Version bump * Update EXE name * Lint fixes
1 parent b6e1083 commit a25294c

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

ephys_link.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exe = EXE(
2222
a.binaries,
2323
a.datas,
2424
[],
25-
name=f"ephys_link-v{version}-Windows-x86_64",
25+
name=f"EphysLink-v{version}",
2626
debug=False,
2727
bootloader_ignore_signals=False,
2828
strip=False,

src/ephys_link/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.2.0"
1+
__version__ = "1.2.1"

src/ephys_link/platforms/new_scale_pathfinder_handler.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
from __future__ import annotations
99

1010
import json
11+
from sys import exit
1112
from typing import TYPE_CHECKING
1213
from urllib import request
14+
from urllib.error import URLError
1315

1416
from ephys_link import common as com
1517
from ephys_link.platform_handler import PlatformHandler
@@ -82,9 +84,11 @@ def __init__(self, port: int = 8080) -> None:
8284
# Test connection to New Scale HTTP server
8385
try:
8486
request.urlopen(f"http://localhost:{self.port}")
85-
except Exception as e:
86-
msg = f"New Scale HTTP server not online on port {self.port}"
87-
raise ValueError(msg) from e
87+
except URLError:
88+
print(f"New Scale Pathfinder HTTP server not online on port {self.port}")
89+
print("Please start the HTTP server and try again.")
90+
input("Press Enter to exit...")
91+
exit(1)
8892

8993
def query_data(self) -> dict:
9094
"""Query New Scale HTTP server for data and return as dict.
@@ -192,7 +196,11 @@ def _get_angles(self, manipulator_id: str) -> com.AngularOutputData:
192196
def _get_shank_count(self, manipulator_id: str) -> com.ShankCountOutputData:
193197
for probe in self.query_data()["ProbeArray"]:
194198
if probe["Id"] == manipulator_id:
195-
return com.ShankCountOutputData(probe["ShankCount"], "")
199+
if "ShankCount" in probe:
200+
return com.ShankCountOutputData(probe["ShankCount"], "")
201+
202+
# Default to 1.0 if shank count is not found
203+
return com.ShankCountOutputData(1, "")
196204

197205
return com.ShankCountOutputData(-1, "Unable to find manipulator")
198206

0 commit comments

Comments
 (0)