bug: Fix DataLocations defaulting to all get_config.

This commit is contained in:
b-rowan
2024-01-21 14:39:01 -07:00
parent cce1917c00
commit 3820b40f44
3 changed files with 13 additions and 1 deletions

View File

@@ -64,6 +64,10 @@ AVALON_DATA_LOC = DataLocations(
"_get_fault_light", "_get_fault_light",
[RPCAPICommand("api_stats", "stats")], [RPCAPICommand("api_stats", "stats")],
), ),
str(DataOptions.UPTIME): DataFunction(
"_get_uptime",
[RPCAPICommand("api_stats", "stats")],
),
} }
) )

View File

@@ -70,6 +70,10 @@ VNISH_DATA_LOC = DataLocations(
"_get_fans", "_get_fans",
[RPCAPICommand("api_stats", "stats")], [RPCAPICommand("api_stats", "stats")],
), ),
str(DataOptions.UPTIME): DataFunction(
"_get_uptime",
[RPCAPICommand("api_stats", "stats")],
),
} }
) )

View File

@@ -89,6 +89,9 @@ class DataFunction:
Union[RPCAPICommand, WebAPICommand, GRPCCommand, GraphQLCommand] Union[RPCAPICommand, WebAPICommand, GRPCCommand, GraphQLCommand]
] = field(default_factory=list) ] = field(default_factory=list)
def __call__(self, *args, **kwargs):
return self
DataLocations = make_dataclass( DataLocations = make_dataclass(
"DataLocations", "DataLocations",
@@ -96,11 +99,12 @@ DataLocations = make_dataclass(
( (
enum_value.value, enum_value.value,
DataFunction, DataFunction,
field(default_factory=lambda: DataFunction(enum_value.default_command())), field(default_factory=DataFunction(enum_value.default_command())),
) )
for enum_value in DataOptions for enum_value in DataOptions
], ],
) )
print(DataLocations())
class MinerProtocol(Protocol): class MinerProtocol(Protocol):