File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 11from typing import Any
22
3- from click_extra import extra_command
3+ from click_extra import extra_command , Choice , option
44
55from ..utils import (
66 com_option_group ,
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+ )
1834def cli_list (** kwargs : Any ) -> None :
1935 """
2036 List job files on an instrument.
Original file line number Diff line number Diff line change 55from geocompy .communication import open_serial
66from geocompy .geo import GeoCom
77from geocompy .geo .gctypes import GeoComCode
8+ from geocompy .geo .gcdata import Device
89
910from ..utils import print_error , print_warning , console
1011
1112
1213def 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+
6172def 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 ()
You can’t perform that action at this time.
0 commit comments