make linter happy
This commit is contained in:
parent
42280d6c71
commit
8a8b20f22e
16 changed files with 56 additions and 63 deletions
|
@ -195,7 +195,7 @@ class ChipRevFormat(SimpleFormat):
|
|||
def __init__(self):
|
||||
super().__init__('H')
|
||||
|
||||
def decode(self, data: bytes) -> tuple[tuple[int,int], bytes]:
|
||||
def decode(self, data: bytes) -> tuple[tuple[int, int], bytes]:
|
||||
value, data = super().decode(data)
|
||||
return (value // 100, value % 100), data
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ class MeshConsumer(AsyncWebsocketConsumer):
|
|||
traceback.print_exc()
|
||||
return
|
||||
|
||||
#print(msg)
|
||||
# print(msg)
|
||||
|
||||
if msg.dst != messages.MESH_ROOT_ADDRESS and msg.dst != messages.MESH_PARENT_ADDRESS:
|
||||
# message not adressed to us, forward it
|
||||
|
@ -370,7 +370,6 @@ class MeshConsumer(AsyncWebsocketConsumer):
|
|||
else:
|
||||
node_state.ota_recipient = None
|
||||
|
||||
|
||||
@database_sync_to_async
|
||||
def get_nodes_with_ota(self, addresses) -> dict[str, Optional[OTAUpdateRecipient]]:
|
||||
return {node.address: node.current_ota
|
||||
|
@ -429,11 +428,13 @@ class MeshConsumer(AsyncWebsocketConsumer):
|
|||
traceback.print_exc()
|
||||
await asyncio.sleep(1)
|
||||
|
||||
async def ota_set_chunks(self, update: OTAUpdate, chunks: Optional[set[int]] = None, min_chunk: int=0):
|
||||
async def ota_set_chunks(self, update: OTAUpdate, chunks: Optional[set[int]] = None, min_chunk: int = 0):
|
||||
async with self.ota_chunks_available_condition:
|
||||
num_chunks = (update.build.binary.size-1)//OTA_CHUNK_SIZE+1
|
||||
print('queueing chunks for update', update.id, 'num_chunks=%d' % num_chunks, "chunks:", chunks)
|
||||
chunks = set(range(min_chunk, num_chunks*0+10)) if chunks is None else {chunk for chunk in chunks if chunk < num_chunks}
|
||||
chunks = (set(range(min_chunk, num_chunks*0+10))
|
||||
if chunks is None
|
||||
else {chunk for chunk in chunks if chunk < num_chunks})
|
||||
self.ota_chunks.setdefault(update.id, set()).update(chunks)
|
||||
self.ota_chunks_available_condition.notify_all()
|
||||
|
||||
|
@ -522,7 +523,6 @@ class MeshConsumer(AsyncWebsocketConsumer):
|
|||
"uplink": self.channel_name
|
||||
})
|
||||
|
||||
|
||||
async def remove_dst_nodes(self, addresses):
|
||||
for address in tuple(addresses):
|
||||
await self.log_text(address, "destination removed")
|
||||
|
@ -559,12 +559,12 @@ class MeshUIConsumer(AsyncJsonWebsocketConsumer):
|
|||
if content.get("subscribe", None) == "log":
|
||||
await self.channel_layer.group_add("mesh_log", self.channel_name)
|
||||
# disabled because security
|
||||
#if content.get("subscribe", None) == "msg_sent":
|
||||
# await self.channel_layer.group_add("mesh_msg_sent", self.channel_name)
|
||||
# self.msg_sent_filter = dict(content.get("filter", {}))
|
||||
#if content.get("subscribe", None) == "msg_received":
|
||||
# await self.channel_layer.group_add("mesh_msg_sent", self.channel_name)
|
||||
# self.msg_received_filter = dict(content.get("filter", {}))
|
||||
# if content.get("subscribe", None) == "msg_sent":
|
||||
# await self.channel_layer.group_add("mesh_msg_sent", self.channel_name)
|
||||
# self.msg_sent_filter = dict(content.get("filter", {}))
|
||||
# if content.get("subscribe", None) == "msg_received":
|
||||
# await self.channel_layer.group_add("mesh_msg_sent", self.channel_name)
|
||||
# self.msg_received_filter = dict(content.get("filter", {}))
|
||||
if content.get("subscribe", None) == "ranging":
|
||||
await self.channel_layer.group_add("mesh_msg_received", self.channel_name)
|
||||
self.msg_received_filter = {"msg_type": MeshMessageType.LOCATE_RANGE_RESULTS.name}
|
||||
|
|
|
@ -161,7 +161,6 @@ class MeshLayerAnnounceMessage(MeshMessage, msg_type=MeshMessageType.MESH_LAYER_
|
|||
})
|
||||
|
||||
|
||||
|
||||
@dataclass
|
||||
class MeshAddDestinationsMessage(MeshMessage, msg_type=MeshMessageType.MESH_ADD_DESTINATIONS):
|
||||
""" downstream node announces served destination """
|
||||
|
|
|
@ -421,6 +421,7 @@ class FirmwareBuild(models.Model):
|
|||
unique_together = [
|
||||
('version', 'variant'),
|
||||
]
|
||||
|
||||
@property
|
||||
def boards(self):
|
||||
return {BoardType[board.board] for board in self.firmwarebuildboard_set.all()
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.urls import path
|
|||
|
||||
from c3nav.mesh.consumers import MeshConsumer, MeshUIConsumer
|
||||
from c3nav.mesh.views.firmware import (FirmwareBuildDetailView, FirmwareDetailView, FirmwaresCurrentListView,
|
||||
FirmwaresListView, OTAListView, OTADetailView)
|
||||
FirmwaresListView, OTADetailView, OTAListView)
|
||||
from c3nav.mesh.views.messages import MeshMessageListView, MeshMessageSendingView, MeshMessageSendView
|
||||
from c3nav.mesh.views.misc import MeshLogView, MeshRangingView
|
||||
from c3nav.mesh.views.nodes import NodeDetailView, NodeEditView, NodeListView
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.contrib.messages.views import SuccessMessageMixin
|
|||
from django.views.generic import DetailView, ListView, TemplateView
|
||||
from django.views.generic.edit import FormMixin
|
||||
|
||||
from c3nav.mesh.models import FirmwareBuild, FirmwareVersion, MeshNode, OTAUpdate, OTARecipientStatus
|
||||
from c3nav.mesh.models import FirmwareBuild, FirmwareVersion, MeshNode, OTARecipientStatus, OTAUpdate
|
||||
from c3nav.mesh.views.base import MeshControlMixin
|
||||
from c3nav.site.forms import OTACreateForm
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import DetailView, ListView, UpdateView
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue