Skip to content

Commit 6ea1594

Browse files
committed
[jobs] added memory device option to listing
1 parent 0cc098c commit 6ea1594

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

src/instrumentman/jobs/__init__.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Any
22

3-
from click_extra import extra_command
3+
from click_extra import extra_command, Choice, option
44

55
from ..utils import (
66
com_option_group,
@@ -15,6 +15,22 @@
1515
) # type: ignore[misc]
1616
@com_port_argument()
1717
@com_option_group()
18+
@option(
19+
"-d",
20+
"--device",
21+
help="Memory device",
22+
type=Choice(
23+
(
24+
"internal",
25+
"cf",
26+
"sd",
27+
"usb",
28+
"ram"
29+
),
30+
case_sensitive=False
31+
),
32+
default="internal"
33+
)
1834
def cli_list(**kwargs: Any) -> None:
1935
"""
2036
List job files on an instrument.

src/instrumentman/jobs/app.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
from geocompy.communication import open_serial
66
from geocompy.geo import GeoCom
77
from geocompy.geo.gctypes import GeoComCode
8+
from geocompy.geo.gcdata import Device
89

910
from ..utils import print_error, print_warning, console
1011

1112

1213
def run_listing(
1314
tps: GeoCom,
15+
device: Device,
1416
logger: Logger
1517
) -> None:
1618
logger.info("Starting job listing")
17-
resp_setup = tps.csv.setup_listing()
19+
resp_setup = tps.csv.setup_listing(device)
1820
if resp_setup.error != GeoComCode.OK:
1921
print_error("Could not set up listing")
2022
logger.critical(
@@ -58,12 +60,22 @@ def run_listing(
5860
logger.info("Listing complete")
5961

6062

63+
_DEVICE = {
64+
"internal": Device.INTERNAL,
65+
"cf": Device.CFCARD,
66+
"sd": Device.SDCARD,
67+
"usb": Device.USB,
68+
"ram": Device.RAM
69+
}
70+
71+
6172
def main_list(
6273
port: str,
6374
baud: int = 9600,
6475
timeout: int = 15,
6576
retry: int = 1,
66-
sync_after_timeout: bool = False
77+
sync_after_timeout: bool = False,
78+
device: str = "internal"
6779
) -> None:
6880
logger = getLogger("iman.jobs.list")
6981
with open_serial(
@@ -76,6 +88,6 @@ def main_list(
7688
) as com:
7789
tps = GeoCom(com, logger.getChild("instrument"))
7890
try:
79-
run_listing(tps, logger)
91+
run_listing(tps, _DEVICE[device], logger)
8092
finally:
8193
tps.csv.abort_listing()

0 commit comments

Comments
 (0)