Skip to content

Commit c58d4b9

Browse files
authored
Merge pull request #38 from MrClock8163/change/geocompy-update
Updates for new GeoComPy
2 parents 249596b + 72a5f7f commit c58d4b9

File tree

18 files changed

+83
-67
lines changed

18 files changed

+83
-67
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ readme = "README.md"
1313
requires-python = ">=3.11"
1414
dependencies = [
1515
"pyserial ~= 3.5.0",
16-
"geocompy >= 0.13.0",
16+
"geocompy ~= 0.14.0",
1717
"rich >= 13.9",
1818
"textual >= 3.2.0",
1919
"rapidfuzz ~= 3.13.0",

src/instrumentman/control/app.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def main_shutdown_gsidna(
1212
port: str,
1313
timeout: int = 15,
14-
retry: int = 1,
14+
attempts: int = 1,
1515
baud: int = 9600,
1616
sync_after_timeout: bool = False
1717
) -> None:
@@ -20,11 +20,11 @@ def main_shutdown_gsidna(
2020
port,
2121
speed=baud,
2222
timeout=timeout,
23-
retry=retry,
23+
attempts=attempts,
2424
sync_after_timeout=sync_after_timeout,
2525
logger=logger.getChild("com")
2626
) as com:
27-
instrument = GsiOnlineDNA(com, logger.getChild("instrument"))
27+
instrument = GsiOnlineDNA(com, logger=logger.getChild("instrument"))
2828
resp = instrument.shutdown()
2929

3030
if resp.value:
@@ -38,7 +38,7 @@ def main_shutdown_geocom(
3838
component: str,
3939
port: str,
4040
timeout: int = 15,
41-
retry: int = 1,
41+
attempts: int = 1,
4242
baud: int = 9600,
4343
sync_after_timeout: bool = False
4444
) -> None:
@@ -47,11 +47,11 @@ def main_shutdown_geocom(
4747
port,
4848
speed=baud,
4949
timeout=timeout,
50-
retry=retry,
50+
attempts=attempts,
5151
sync_after_timeout=sync_after_timeout,
5252
logger=logger.getChild("com")
5353
) as com:
54-
instrument = GeoCom(com, logger.getChild("instrument"))
54+
instrument = GeoCom(com, logger=logger.getChild("instrument"))
5555

5656
match component:
5757
case "protocol":
@@ -81,7 +81,7 @@ def main_shutdown_geocom(
8181
def main_startup_gsidna(
8282
port: str,
8383
timeout: int = 15,
84-
retry: int = 1,
84+
attempts: int = 1,
8585
baud: int = 9600,
8686
sync_after_timeout: bool = False
8787
) -> None:
@@ -90,11 +90,11 @@ def main_startup_gsidna(
9090
port,
9191
speed=baud,
9292
timeout=timeout,
93-
retry=retry,
93+
attempts=attempts,
9494
sync_after_timeout=sync_after_timeout,
9595
logger=logger.getChild("com")
9696
) as com:
97-
instrument = GsiOnlineDNA(com, logger.getChild("instrument"))
97+
instrument = GsiOnlineDNA(com, logger=logger.getChild("instrument"))
9898
resp = instrument.wakeup()
9999

100100
if resp.value:
@@ -108,7 +108,7 @@ def main_startup_geocom(
108108
component: str,
109109
port: str,
110110
timeout: int = 15,
111-
retry: int = 1,
111+
attempts: int = 1,
112112
baud: int = 9600,
113113
sync_after_timeout: bool = False
114114
) -> None:
@@ -117,11 +117,11 @@ def main_startup_geocom(
117117
port,
118118
speed=baud,
119119
timeout=timeout,
120-
retry=retry,
120+
attempts=attempts,
121121
sync_after_timeout=sync_after_timeout,
122122
logger=logger.getChild("com")
123123
) as com:
124-
instrument = GeoCom(com, logger.getChild("instrument"))
124+
instrument = GeoCom(com, logger=logger.getChild("instrument"))
125125

126126
match component:
127127
case "instrument":

src/instrumentman/datatransfer/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from io import BufferedWriter, TextIOWrapper
22
from logging import getLogger
33

4-
from serial import SerialTimeoutException
54
from rich.progress import Progress, TextColumn, BarColumn, TimeElapsedColumn
65
from geocompy.communication import open_serial
76

@@ -92,7 +91,7 @@ def main_download(
9291
total=lines
9392
)
9493
break
95-
except SerialTimeoutException:
94+
except TimeoutError:
9695
if started and autoclose:
9796
logger.info("Download finished (timeout)")
9897
print_success("Download finished due to timeout")

src/instrumentman/filetransfer/app.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def main_download(
307307
output: BufferedWriter,
308308
baud: int = 9600,
309309
timeout: int = 15,
310-
retry: int = 1,
310+
attempts: int = 1,
311311
sync_after_timeout: bool = False,
312312
device: str = "internal",
313313
filetype: str = "unknown",
@@ -319,11 +319,11 @@ def main_download(
319319
port=port,
320320
speed=baud,
321321
timeout=timeout,
322-
retry=retry,
322+
attempts=attempts,
323323
sync_after_timeout=sync_after_timeout,
324324
logger=logger.getChild("com")
325325
) as com:
326-
tps = GeoCom(com, logger.getChild("instrument"))
326+
tps = GeoCom(com, logger=logger.getChild("instrument"))
327327
try:
328328
run_download(
329329
tps,
@@ -344,7 +344,7 @@ def main_list(
344344
directory: str = "/",
345345
baud: int = 9600,
346346
timeout: int = 15,
347-
retry: int = 1,
347+
attempts: int = 1,
348348
sync_after_timeout: bool = False,
349349
device: str = "internal",
350350
filetype: str | None = None,
@@ -355,11 +355,11 @@ def main_list(
355355
port=port,
356356
speed=baud,
357357
timeout=timeout,
358-
retry=retry,
358+
attempts=attempts,
359359
sync_after_timeout=sync_after_timeout,
360360
logger=logger.getChild("com")
361361
) as com:
362-
tps = GeoCom(com, logger.getChild("instrument"))
362+
tps = GeoCom(com, logger=logger.getChild("instrument"))
363363
try:
364364
run_listing_tree(
365365
tps,

src/instrumentman/inclination/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def main_measure(
115115
port: str,
116116
baud: int = 9600,
117117
timeout: int = 15,
118-
retry: int = 1,
118+
attempts: int = 1,
119119
sync_after_timeout: bool = False,
120120
output: TextIOWrapper | None = None,
121121
positions: int = 1,
@@ -126,13 +126,13 @@ def main_measure(
126126
logger.info(f"Opening connection on {port}")
127127
with open_serial(
128128
port,
129-
retry=retry,
129+
attempts=attempts,
130130
sync_after_timeout=sync_after_timeout,
131131
speed=baud,
132132
timeout=timeout,
133133
logger=logger.getChild("com")
134134
) as com:
135-
tps = GeoCom(com, logger.getChild("instrument"))
135+
tps = GeoCom(com, logger=logger.getChild("instrument"))
136136
run_measure(
137137
tps,
138138
logger,

src/instrumentman/jobs/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def main_list(
7373
port: str,
7474
baud: int = 9600,
7575
timeout: int = 15,
76-
retry: int = 1,
76+
attempts: int = 1,
7777
sync_after_timeout: bool = False,
7878
device: str = "internal"
7979
) -> None:
@@ -82,11 +82,11 @@ def main_list(
8282
port=port,
8383
speed=baud,
8484
timeout=timeout,
85-
retry=retry,
85+
attempts=attempts,
8686
sync_after_timeout=sync_after_timeout,
8787
logger=logger.getChild("com")
8888
) as com:
89-
tps = GeoCom(com, logger.getChild("instrument"))
89+
tps = GeoCom(com, logger=logger.getChild("instrument"))
9090
try:
9191
run_listing(tps, _DEVICE[device], logger)
9292
finally:

src/instrumentman/morse/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def main(
133133
ignore_non_ascii: bool = False,
134134
baud: int = 9600,
135135
timeout: int = 15,
136-
retry: int = 1,
136+
attempts: int = 1,
137137
sync_after_timeout: bool = False,
138138
unittime: int = 50,
139139
compatibility: str = "none",
@@ -151,11 +151,11 @@ def main(
151151
port,
152152
speed=baud,
153153
timeout=timeout,
154-
retry=retry,
154+
attempts=attempts,
155155
sync_after_timeout=sync_after_timeout,
156156
logger=logger.getChild("com")
157157
) as com:
158-
tps = GeoCom(com, logger.getChild("instrument"))
158+
tps = GeoCom(com, logger=logger.getChild("instrument"))
159159
beepstart = tps.bmm.beep_start
160160
beepstop = tps.bmm.beep_stop
161161
match compatibility.lower():

src/instrumentman/panorama/measure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def main(
396396
metadata: TextIO,
397397
baud: int = 9600,
398398
timeout: int = 15,
399-
retry: int = 1,
399+
attempts: int = 1,
400400
sync_after_timeout: bool = False,
401401
zoom: str = "x1",
402402
overlap: tuple[int, int] = (5, 10),
@@ -411,13 +411,13 @@ def main(
411411
logger = getLogger("iman.panorama.measure")
412412
with open_serial(
413413
port,
414-
retry=retry,
414+
attempts=attempts,
415415
sync_after_timeout=sync_after_timeout,
416416
speed=baud,
417417
timeout=timeout,
418418
logger=logger.getChild("com")
419419
) as com:
420-
tps = GeoCom(com, logger.getChild("instrument"))
420+
tps = GeoCom(com, logger=logger.getChild("instrument"))
421421
tolerances: tuple[Angle, Angle] | None = None
422422
try:
423423
resp_tol = tps.aut.get_tolerance()

src/instrumentman/protocoltest/app.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from rich.live import Live
66
from rich.table import Table, Column
77
from rich.prompt import Confirm
8-
from serial import SerialException
98
from geocompy.data import Angle
109
from geocompy.geo import GeoCom
1110
from geocompy.geo.gcdata import Device
@@ -145,7 +144,7 @@ def main(
145144
protocol: str,
146145
baud: int = 9600,
147146
timeout: int = 15,
148-
retry: int = 1,
147+
attempts: int = 1,
149148
sync_after_timeout: bool = False
150149
) -> None:
151150
logger = getLogger("iman.protocoltest")
@@ -154,23 +153,29 @@ def main(
154153
port,
155154
speed=baud,
156155
timeout=timeout,
157-
retry=retry,
156+
attempts=attempts,
158157
sync_after_timeout=sync_after_timeout,
159158
logger=logger.getChild("com")
160159
) as com:
161160
try:
162161
if protocol == "geocom":
163-
tps = GeoCom(com, logger.getChild("instrument"))
162+
tps = GeoCom(
163+
com,
164+
logger=logger.getChild("instrument")
165+
)
164166
tests_geocom(tps, logger)
165167
elif protocol == "gsidna":
166-
dna = GsiOnlineDNA(com, logger.getChild("instrument"))
168+
dna = GsiOnlineDNA(
169+
com,
170+
logger=logger.getChild("instrument")
171+
)
167172
tests_gsidna(dna, logger)
168173
except Exception:
169174
print_error("An exception occured while running the tests")
170175
logger.exception(
171176
"An exception occured while running the tests"
172177
)
173178

174-
except (SerialException, ConnectionError) as e:
179+
except (ConnectionRefusedError, ConnectionError) as e:
175180
print_error(f"Connection was not successful ({e})")
176181
logger.exception("Connection was not successful")

src/instrumentman/setmeasurement/measure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def main(
180180
output: str,
181181
baud: int = 9600,
182182
timeout: int = 15,
183-
retry: int = 1,
183+
attempts: int = 1,
184184
sync_after_timeout: bool = False,
185185
dateformat: str = "%Y%m%d",
186186
timeformat: str = "%H%M%S",
@@ -192,13 +192,13 @@ def main(
192192
logger = getLogger("iman.sets.measure")
193193
with open_serial(
194194
port,
195-
retry=retry,
195+
attempts=attempts,
196196
sync_after_timeout=sync_after_timeout,
197197
speed=baud,
198198
timeout=timeout,
199199
logger=logger.getChild("com")
200200
) as com:
201-
tps = GeoCom(com, logger.getChild("instrument"))
201+
tps = GeoCom(com, logger=logger.getChild("instrument"))
202202
if sync_time:
203203
tps.csv.set_datetime(datetime.now())
204204
logger.info("Synced instrument date-time to computer")

0 commit comments

Comments
 (0)