mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 13:30:36 +01:00
Added appearance sync to bulk telemetry transfers
This commit is contained in:
parent
e2e55237ed
commit
9481938d41
@ -1641,7 +1641,7 @@ class SidebandCore():
|
|||||||
RNS.log("An error occurred while saving telemetry to database: "+str(e), RNS.LOG_ERROR)
|
RNS.log("An error occurred while saving telemetry to database: "+str(e), RNS.LOG_ERROR)
|
||||||
self.db = None
|
self.db = None
|
||||||
|
|
||||||
def _db_update_appearance(self, context_dest, timestamp, appearance):
|
def _db_update_appearance(self, context_dest, timestamp, appearance, from_bulk_telemetry=False):
|
||||||
conv = self._db_conversation(context_dest)
|
conv = self._db_conversation(context_dest)
|
||||||
|
|
||||||
if conv == None:
|
if conv == None:
|
||||||
@ -1650,6 +1650,7 @@ class SidebandCore():
|
|||||||
# Probably expire after 14 days or so.
|
# Probably expire after 14 days or so.
|
||||||
self.setpersistent("temp.peer_appearance."+RNS.hexrep(context_dest, delimit=False), ae)
|
self.setpersistent("temp.peer_appearance."+RNS.hexrep(context_dest, delimit=False), ae)
|
||||||
else:
|
else:
|
||||||
|
if not from_bulk_telemetry:
|
||||||
data_dict = conv["data"]
|
data_dict = conv["data"]
|
||||||
if data_dict == None:
|
if data_dict == None:
|
||||||
data_dict = {}
|
data_dict = {}
|
||||||
@ -1670,7 +1671,7 @@ class SidebandCore():
|
|||||||
result = dbc.fetchall()
|
result = dbc.fetchall()
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
def _db_get_appearance(self, context_dest, conv = None):
|
def _db_get_appearance(self, context_dest, conv = None, raw=False):
|
||||||
if context_dest == self.lxmf_destination.hash:
|
if context_dest == self.lxmf_destination.hash:
|
||||||
return [self.config["telemetry_icon"], self.config["telemetry_fg"], self.config["telemetry_bg"]]
|
return [self.config["telemetry_icon"], self.config["telemetry_fg"], self.config["telemetry_bg"]]
|
||||||
else:
|
else:
|
||||||
@ -1686,7 +1687,11 @@ class SidebandCore():
|
|||||||
data_dict = {}
|
data_dict = {}
|
||||||
apd = self.getpersistent("temp.peer_appearance."+RNS.hexrep(context_dest, delimit=False))
|
apd = self.getpersistent("temp.peer_appearance."+RNS.hexrep(context_dest, delimit=False))
|
||||||
if apd != None:
|
if apd != None:
|
||||||
data_dict["appearance"] = apd
|
try:
|
||||||
|
data_dict["appearance"] = apd[0]
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log("Could not get appearance data from database: "+str(e),RNS.LOG_ERROR)
|
||||||
|
data_dict = None
|
||||||
|
|
||||||
if data_dict != None:
|
if data_dict != None:
|
||||||
try:
|
try:
|
||||||
@ -1698,6 +1703,9 @@ class SidebandCore():
|
|||||||
b = round(struct.unpack("!B", bytes([cbytes[2]]))[0]*d, 4)
|
b = round(struct.unpack("!B", bytes([cbytes[2]]))[0]*d, 4)
|
||||||
return [r,g,b]
|
return [r,g,b]
|
||||||
|
|
||||||
|
if raw:
|
||||||
|
appearance = data_dict["appearance"]
|
||||||
|
else:
|
||||||
appearance = [data_dict["appearance"][0], htf(data_dict["appearance"][1]), htf(data_dict["appearance"][2])]
|
appearance = [data_dict["appearance"][0], htf(data_dict["appearance"][1]), htf(data_dict["appearance"][2])]
|
||||||
|
|
||||||
return appearance
|
return appearance
|
||||||
@ -2088,10 +2096,13 @@ class SidebandCore():
|
|||||||
if lxm.fields[LXMF.FIELD_TELEMETRY_STREAM] != None and len(lxm.fields[LXMF.FIELD_TELEMETRY_STREAM]) > 0:
|
if lxm.fields[LXMF.FIELD_TELEMETRY_STREAM] != None and len(lxm.fields[LXMF.FIELD_TELEMETRY_STREAM]) > 0:
|
||||||
for telemetry_entry in lxm.fields[LXMF.FIELD_TELEMETRY_STREAM]:
|
for telemetry_entry in lxm.fields[LXMF.FIELD_TELEMETRY_STREAM]:
|
||||||
tsource = telemetry_entry[0]
|
tsource = telemetry_entry[0]
|
||||||
ttstemp = telemetry_entry[1]
|
ttstamp = telemetry_entry[1]
|
||||||
tpacked = telemetry_entry[2]
|
tpacked = telemetry_entry[2]
|
||||||
|
appearance = telemetry_entry[3]
|
||||||
if self._db_save_telemetry(tsource, tpacked, via = context_dest):
|
if self._db_save_telemetry(tsource, tpacked, via = context_dest):
|
||||||
RNS.log("Saved telemetry stream entry from "+RNS.prettyhexrep(tsource), RNS.LOG_WARNING)
|
RNS.log("Saved telemetry stream entry from "+RNS.prettyhexrep(tsource), RNS.LOG_WARNING)
|
||||||
|
if appearance != None:
|
||||||
|
self._db_update_appearance(tsource, ttstamp, appearance, from_bulk_telemetry=True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("Received telemetry stream field with no data: "+str(lxm.fields[LXMF.FIELD_TELEMETRY_STREAM]), RNS.LOG_DEBUG)
|
RNS.log("Received telemetry stream field with no data: "+str(lxm.fields[LXMF.FIELD_TELEMETRY_STREAM]), RNS.LOG_DEBUG)
|
||||||
@ -3503,7 +3514,8 @@ class SidebandCore():
|
|||||||
for entry in sources[source]:
|
for entry in sources[source]:
|
||||||
elements += 1
|
elements += 1
|
||||||
timestamp = entry[0]; packed_telemetry = entry[1]
|
timestamp = entry[0]; packed_telemetry = entry[1]
|
||||||
te = [source, timestamp, packed_telemetry]
|
appearance = self._db_get_appearance(source, raw=True)
|
||||||
|
te = [source, timestamp, packed_telemetry, appearance]
|
||||||
if only_latest:
|
if only_latest:
|
||||||
if not source in added_sources:
|
if not source in added_sources:
|
||||||
added_sources[source] = True
|
added_sources[source] = True
|
||||||
|
Loading…
Reference in New Issue
Block a user