bug: fix some issues with boser handlers.
This commit is contained in:
@@ -865,7 +865,9 @@ class BOSer(BraiinsOSFirmware):
|
|||||||
) -> Optional[int]:
|
) -> Optional[int]:
|
||||||
if grpc_active_performance_mode is None:
|
if grpc_active_performance_mode is None:
|
||||||
try:
|
try:
|
||||||
grpc_active_performance_mode = self.web.get_active_performance_mode()
|
grpc_active_performance_mode = (
|
||||||
|
await self.web.get_active_performance_mode()
|
||||||
|
)
|
||||||
except APIError:
|
except APIError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -78,13 +78,16 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
for command in commands:
|
for command in commands:
|
||||||
try:
|
try:
|
||||||
tasks[command] = asyncio.create_task(getattr(self, command)())
|
tasks[command] = asyncio.create_task(getattr(self, command)())
|
||||||
except (APIError, AttributeError):
|
except AttributeError:
|
||||||
result["command"] = {}
|
pass
|
||||||
|
|
||||||
await asyncio.gather(*list(tasks.values()))
|
await asyncio.gather(*[t for t in tasks.values()], return_exceptions=True)
|
||||||
|
|
||||||
for cmd in tasks:
|
for cmd in tasks:
|
||||||
result[cmd] = tasks[cmd].result()
|
try:
|
||||||
|
result[cmd] = await tasks[cmd]
|
||||||
|
except (GRPCError, APIError):
|
||||||
|
pass
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -149,42 +152,55 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def start(self) -> dict:
|
async def start(self) -> dict:
|
||||||
return await self.send_command("start", message=StartRequest())
|
return await self.send_command("start", message=StartRequest(), privileged=True)
|
||||||
|
|
||||||
async def stop(self) -> dict:
|
async def stop(self) -> dict:
|
||||||
return await self.send_command("stop", message=StopRequest())
|
return await self.send_command("stop", message=StopRequest(), privileged=True)
|
||||||
|
|
||||||
async def pause_mining(self) -> dict:
|
async def pause_mining(self) -> dict:
|
||||||
return await self.send_command("pause_mining", message=PauseMiningRequest())
|
return await self.send_command(
|
||||||
|
"pause_mining", message=PauseMiningRequest(), privileged=True
|
||||||
|
)
|
||||||
|
|
||||||
async def resume_mining(self) -> dict:
|
async def resume_mining(self) -> dict:
|
||||||
return await self.send_command("resume_mining", message=ResumeMiningRequest())
|
return await self.send_command(
|
||||||
|
"resume_mining", message=ResumeMiningRequest(), privileged=True
|
||||||
|
)
|
||||||
|
|
||||||
async def restart(self) -> dict:
|
async def restart(self) -> dict:
|
||||||
return await self.send_command("restart", message=RestartRequest())
|
return await self.send_command(
|
||||||
|
"restart", message=RestartRequest(), privileged=True
|
||||||
|
)
|
||||||
|
|
||||||
async def reboot(self) -> dict:
|
async def reboot(self) -> dict:
|
||||||
return await self.send_command("reboot", message=RebootRequest())
|
return await self.send_command(
|
||||||
|
"reboot", message=RebootRequest(), privileged=True
|
||||||
|
)
|
||||||
|
|
||||||
async def set_locate_device_status(self, enable: bool) -> dict:
|
async def set_locate_device_status(self, enable: bool) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"set_locate_device_status",
|
"set_locate_device_status",
|
||||||
message=SetLocateDeviceStatusRequest(enable=enable),
|
message=SetLocateDeviceStatusRequest(enable=enable),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_locate_device_status(self) -> dict:
|
async def get_locate_device_status(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_locate_device_status", message=GetLocateDeviceStatusRequest()
|
"get_locate_device_status",
|
||||||
|
message=GetLocateDeviceStatusRequest(),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_password(self, password: str = None) -> dict:
|
async def set_password(self, password: str = None) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"set_password", message=SetPasswordRequest(password=password)
|
"set_password",
|
||||||
|
message=SetPasswordRequest(password=password),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_cooling_state(self) -> dict:
|
async def get_cooling_state(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_cooling_state", message=GetCoolingStateRequest()
|
"get_cooling_state", message=GetCoolingStateRequest(), privileged=True
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_immersion_mode(
|
async def set_immersion_mode(
|
||||||
@@ -197,16 +213,17 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
message=SetImmersionModeRequest(
|
message=SetImmersionModeRequest(
|
||||||
enable_immersion_mode=enable, save_action=save_action
|
enable_immersion_mode=enable, save_action=save_action
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_tuner_state(self) -> dict:
|
async def get_tuner_state(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_tuner_state", message=GetTunerStateRequest()
|
"get_tuner_state", message=GetTunerStateRequest(), privileged=True
|
||||||
)
|
)
|
||||||
|
|
||||||
async def list_target_profiles(self) -> dict:
|
async def list_target_profiles(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"list_target_profiles", message=ListTargetProfilesRequest()
|
"list_target_profiles", message=ListTargetProfilesRequest(), privileged=True
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_default_power_target(
|
async def set_default_power_target(
|
||||||
@@ -215,6 +232,7 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"set_default_power_target",
|
"set_default_power_target",
|
||||||
message=SetDefaultPowerTargetRequest(save_action=save_action),
|
message=SetDefaultPowerTargetRequest(save_action=save_action),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_power_target(
|
async def set_power_target(
|
||||||
@@ -227,6 +245,7 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
message=SetPowerTargetRequest(
|
message=SetPowerTargetRequest(
|
||||||
power_target=Power(watt=power_target), save_action=save_action
|
power_target=Power(watt=power_target), save_action=save_action
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def increment_power_target(
|
async def increment_power_target(
|
||||||
@@ -240,6 +259,7 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
power_target_increment=Power(watt=power_target_increment),
|
power_target_increment=Power(watt=power_target_increment),
|
||||||
save_action=save_action,
|
save_action=save_action,
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def decrement_power_target(
|
async def decrement_power_target(
|
||||||
@@ -253,6 +273,7 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
power_target_decrement=Power(watt=power_target_decrement),
|
power_target_decrement=Power(watt=power_target_decrement),
|
||||||
save_action=save_action,
|
save_action=save_action,
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_default_hashrate_target(
|
async def set_default_hashrate_target(
|
||||||
@@ -261,6 +282,7 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"set_default_hashrate_target",
|
"set_default_hashrate_target",
|
||||||
message=SetDefaultHashrateTargetRequest(save_action=save_action),
|
message=SetDefaultHashrateTargetRequest(save_action=save_action),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_hashrate_target(
|
async def set_hashrate_target(
|
||||||
@@ -274,6 +296,7 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
hashrate_target=TeraHashrate(terahash_per_second=hashrate_target),
|
hashrate_target=TeraHashrate(terahash_per_second=hashrate_target),
|
||||||
save_action=save_action,
|
save_action=save_action,
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def increment_hashrate_target(
|
async def increment_hashrate_target(
|
||||||
@@ -289,6 +312,7 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
),
|
),
|
||||||
save_action=save_action,
|
save_action=save_action,
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def decrement_hashrate_target(
|
async def decrement_hashrate_target(
|
||||||
@@ -304,6 +328,7 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
),
|
),
|
||||||
save_action=save_action,
|
save_action=save_action,
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_dps(
|
async def set_dps(
|
||||||
@@ -327,6 +352,7 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def set_performance_mode(
|
async def set_performance_mode(
|
||||||
@@ -356,6 +382,7 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
if hashrate_target is not None:
|
if hashrate_target is not None:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
@@ -372,16 +399,19 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_active_performance_mode(self) -> dict:
|
async def get_active_performance_mode(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_active_performance_mode", message=GetPerformanceModeRequest()
|
"get_active_performance_mode",
|
||||||
|
message=GetPerformanceModeRequest(),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_pool_groups(self) -> dict:
|
async def get_pool_groups(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_pool_groups", message=GetPoolGroupsRequest()
|
"get_pool_groups", message=GetPoolGroupsRequest(), privileged=True
|
||||||
)
|
)
|
||||||
|
|
||||||
async def create_pool_group(self) -> dict:
|
async def create_pool_group(self) -> dict:
|
||||||
@@ -395,40 +425,44 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
|
|
||||||
async def get_miner_configuration(self) -> dict:
|
async def get_miner_configuration(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_miner_configuration", message=GetMinerConfigurationRequest()
|
"get_miner_configuration",
|
||||||
|
message=GetMinerConfigurationRequest(),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_constraints(self) -> dict:
|
async def get_constraints(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_constraints", message=GetConstraintsRequest()
|
"get_constraints", message=GetConstraintsRequest(), privileged=True
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_license_state(self) -> dict:
|
async def get_license_state(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_license_state", message=GetLicenseStateRequest()
|
"get_license_state", message=GetLicenseStateRequest(), privileged=True
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_miner_status(self) -> dict:
|
async def get_miner_status(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_miner_status", message=GetMinerStatusRequest()
|
"get_miner_status", message=GetMinerStatusRequest(), privileged=True
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_miner_details(self) -> dict:
|
async def get_miner_details(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_miner_details", message=GetMinerDetailsRequest()
|
"get_miner_details", message=GetMinerDetailsRequest(), privileged=True
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_miner_stats(self) -> dict:
|
async def get_miner_stats(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_miner_stats", message=GetMinerStatsRequest()
|
"get_miner_stats", message=GetMinerStatsRequest(), privileged=True
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_hashboards(self) -> dict:
|
async def get_hashboards(self) -> dict:
|
||||||
return await self.send_command("get_hashboards", message=GetHashboardsRequest())
|
return await self.send_command(
|
||||||
|
"get_hashboards", message=GetHashboardsRequest(), privileged=True
|
||||||
|
)
|
||||||
|
|
||||||
async def get_support_archive(self) -> dict:
|
async def get_support_archive(self) -> dict:
|
||||||
return await self.send_command(
|
return await self.send_command(
|
||||||
"get_support_archive", message=GetSupportArchiveRequest()
|
"get_support_archive", message=GetSupportArchiveRequest(), privileged=True
|
||||||
)
|
)
|
||||||
|
|
||||||
async def enable_hashboards(
|
async def enable_hashboards(
|
||||||
@@ -441,6 +475,7 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
message=EnableHashboardsRequest(
|
message=EnableHashboardsRequest(
|
||||||
hashboard_ids=hashboard_ids, save_action=save_action
|
hashboard_ids=hashboard_ids, save_action=save_action
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def disable_hashboards(
|
async def disable_hashboards(
|
||||||
@@ -453,4 +488,5 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
message=DisableHashboardsRequest(
|
message=DisableHashboardsRequest(
|
||||||
hashboard_ids=hashboard_ids, save_action=save_action
|
hashboard_ids=hashboard_ids, save_action=save_action
|
||||||
),
|
),
|
||||||
|
privileged=True,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user