modernize

This commit is contained in:
Pavol Rusnak 2024-10-07 11:15:03 +02:00
parent 5e15c43ab7
commit 2a13ed0921
No known key found for this signature in database
GPG key ID: 91F3B339B9A02A3D
103 changed files with 822 additions and 906 deletions

View file

@ -1,5 +1,5 @@
import os
import glob
modules = glob.glob(os.path.dirname(__file__)+"/*.py")
modules = glob.glob(f"{os.path.dirname(__file__)}/*.py")
__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')]

View file

@ -63,7 +63,7 @@ class Announces():
self.fetch_announces()
self.update_widget()
self.app.sideband.setstate("app.flags.new_announces", False)
RNS.log("Updated announce stream widgets in "+RNS.prettytime(time.time()-us), RNS.LOG_DEBUG)
RNS.log(f"Updated announce stream widgets in {RNS.prettytime(time.time() - us)}", RNS.LOG_DEBUG)
def update_widget(self):
if self.list == None:
@ -105,10 +105,10 @@ class Announces():
def x(sender):
yes_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
if dtype == "lxmf.delivery":
ad_text = "[size=22dp]LXMF Peer[/size]\n\n[b]Received[/b] "+ts+"\n[b]Address[/b] "+RNS.prettyhexrep(dest)+"\n[b]Name[/b] "+name+"\n[b]Stamp Cost[/b] "+cost
ad_text = f"[size=22dp]LXMF Peer[/size]\n\n[b]Received[/b] {ts}\n[b]Address[/b] {RNS.prettyhexrep(dest)}\n[b]Name[/b] {name}\n[b]Stamp Cost[/b] {cost}"
if dtype == "lxmf.propagation":
ad_text = "[size=22dp]LXMF Propagation Node[/size]\n\n[b]Received[/b] "+ts+"\n[b]Address[/b] "+RNS.prettyhexrep(dest)
ad_text = f"[size=22dp]LXMF Propagation Node[/size]\n\n[b]Received[/b] {ts}\n[b]Address[/b] {RNS.prettyhexrep(dest)}"
dialog = MDDialog(
text=ad_text,
@ -130,7 +130,7 @@ class Announces():
iconl = IconLeftWidget(icon=trust_icon)
elif dest_type == "lxmf.propagation":
disp_name = "Propagation Node "+RNS.prettyhexrep(context_dest)
disp_name = f"Propagation Node {RNS.prettyhexrep(context_dest)}"
iconl = IconLeftWidget(icon="upload-network")
else:

View file

@ -224,7 +224,7 @@ class Conversations():
dialog = MDDialog(
title="Edit Conversation",
text= "With "+RNS.prettyhexrep(dest),
text= f"With {RNS.prettyhexrep(dest)}",
type="custom",
content_cls=dialog_content,
buttons=[ yes_button, no_button ],
@ -269,7 +269,7 @@ class Conversations():
self.app.sideband.named_conversation(name, dest)
except Exception as e:
RNS.log("Error while saving conversation settings: "+str(e), RNS.LOG_ERROR)
RNS.log(f"Error while saving conversation settings: {e)}", RNS.LOG_ERROR)
dialog.dismiss()
@ -284,10 +284,10 @@ class Conversations():
no_button.bind(on_release=dl_no)
item.dmenu.dismiss()
dialog.open()
RNS.log("Generated edit dialog in "+str(RNS.prettytime(time.time()-t_s)), RNS.LOG_DEBUG)
RNS.log(f"Generated edit dialog in {RNS.prettytime(time.time() - t_s))}", RNS.LOG_DEBUG)
except Exception as e:
RNS.log("Error while creating conversation settings: "+str(e), RNS.LOG_ERROR)
RNS.log(f"Error while creating conversation settings: {e)}", RNS.LOG_ERROR)
return x
@ -479,7 +479,7 @@ class Conversations():
self.list.children.sort(key=lambda w: (w.trusted, w.last_activity))
RNS.log("Updated conversation list widgets in "+RNS.prettytime(time.time()-us), RNS.LOG_DEBUG)
RNS.log(f"Updated conversation list widgets in {RNS.prettytime(time.time() - us)}", RNS.LOG_DEBUG)
def get_widget(self):
return self.list

View file

@ -83,7 +83,7 @@ def multilingual_markup(data):
if pfont != "default":
do += "[/font]"
if rfont != "default":
do += "[font="+str(rfont)+"]"
do += f"[font={rfont)}]"
do += cp

View file

@ -278,7 +278,7 @@ class Messages():
sphrase = "Sending"
prg = self.app.sideband.get_lxm_progress(msg["hash"])
if prg != None:
prgstr = ", "+str(round(prg*100, 1))+"% done"
prgstr = f", {round(prg * 100, 1))}% done"
if prg <= 0.00:
stamp_cost = self.app.sideband.get_lxm_stamp_cost(msg["hash"])
if stamp_cost:
@ -296,8 +296,8 @@ class Messages():
sphrase = "Sending"
if msg["title"]:
titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n"
w.heading = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] "+sphrase+prgstr+" "
titlestr = f"[b]Title[/b] {msg['title'].decode('utf-8')}\n"
w.heading = f"{titlestr}[b]Sent[/b] {txstr}\n[b]State[/b] {sphrase}{prgstr} "
if w.has_audio:
alstr = RNS.prettysize(w.audio_size)
w.heading += f"\n[b]Audio Message[/b] ({alstr})"
@ -309,8 +309,8 @@ class Messages():
txstr = time.strftime(ts_format, time.localtime(msg["sent"]))
titlestr = ""
if msg["title"]:
titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n"
w.heading = titlestr+"[b]Sent[/b] "+txstr+delivery_syms+"\n[b]State[/b] Delivered"
titlestr = f"[b]Title[/b] {msg['title'].decode('utf-8')}\n"
w.heading = f"{titlestr}[b]Sent[/b] {txstr}{delivery_syms}\n[b]State[/b] Delivered"
if w.has_audio:
alstr = RNS.prettysize(w.audio_size)
w.heading += f"\n[b]Audio Message[/b] ({alstr})"
@ -321,8 +321,8 @@ class Messages():
txstr = time.strftime(ts_format, time.localtime(msg["sent"]))
titlestr = ""
if msg["title"]:
titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n"
w.heading = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Paper Message"
titlestr = f"[b]Title[/b] {msg['title'].decode('utf-8')}\n"
w.heading = f"{titlestr}[b]Sent[/b] {txstr}\n[b]State[/b] Paper Message"
m["state"] = msg["state"]
if msg["method"] == LXMF.LXMessage.PROPAGATED and msg["state"] == LXMF.LXMessage.SENT:
@ -330,8 +330,8 @@ class Messages():
txstr = time.strftime(ts_format, time.localtime(msg["sent"]))
titlestr = ""
if msg["title"]:
titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n"
w.heading = titlestr+"[b]Sent[/b] "+txstr+delivery_syms+"\n[b]State[/b] On Propagation Net"
titlestr = f"[b]Title[/b] {msg['title'].decode('utf-8')}\n"
w.heading = f"{titlestr}[b]Sent[/b] {txstr}{delivery_syms}\n[b]State[/b] On Propagation Net"
if w.has_audio:
alstr = RNS.prettysize(w.audio_size)
w.heading += f"\n[b]Audio Message[/b] ({alstr})"
@ -342,8 +342,8 @@ class Messages():
txstr = time.strftime(ts_format, time.localtime(msg["sent"]))
titlestr = ""
if msg["title"]:
titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n"
w.heading = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Failed"
titlestr = f"[b]Title[/b] {msg['title'].decode('utf-8')}\n"
w.heading = f"{titlestr}[b]Sent[/b] {txstr}\n[b]State[/b] Failed"
m["state"] = msg["state"]
if w.has_audio:
alstr = RNS.prettysize(w.audio_size)
@ -388,7 +388,7 @@ class Messages():
if message_input.strip() == b"":
if not ("lxm" in m and m["lxm"] != None and m["lxm"].fields != None and LXMF.FIELD_COMMANDS in m["lxm"].fields):
message_input = "[i]This message contains no text content[/i]".encode("utf-8")
message_input = b"[i]This message contains no text content[/i]"
message_markup = multilingual_markup(message_input)
@ -438,18 +438,18 @@ class Messages():
commands = m["lxm"].fields[LXMF.FIELD_COMMANDS]
for command in commands:
if Commands.ECHO in command:
extra_content = "[font=RobotoMono-Regular]> echo "+command[Commands.ECHO].decode("utf-8")+"[/font]\n"
extra_content = f"[font=RobotoMono-Regular]> echo {command[Commands.ECHO].decode('utf-8')}[/font]\n"
if Commands.PING in command:
extra_content = "[font=RobotoMono-Regular]> ping[/font]\n"
if Commands.SIGNAL_REPORT in command:
extra_content = "[font=RobotoMono-Regular]> sig[/font]\n"
if Commands.PLUGIN_COMMAND in command:
cmd_content = command[Commands.PLUGIN_COMMAND]
extra_content = "[font=RobotoMono-Regular]> "+str(cmd_content)+"[/font]\n"
extra_content = f"[font=RobotoMono-Regular]> {cmd_content)}[/font]\n"
extra_content = extra_content[:-1]
force_markup = True
except Exception as e:
RNS.log("Error while generating command display: "+str(e), RNS.LOG_ERROR)
RNS.log(f"Error while generating command display: {e)}", RNS.LOG_ERROR)
if telemeter == None and "lxm" in m and m["lxm"] and m["lxm"].fields != None and LXMF.FIELD_TELEMETRY in m["lxm"].fields:
try:
@ -488,11 +488,11 @@ class Messages():
if "euclidian" in d:
edst = d["euclidian"]
if edst != None:
rcvd_d_str = "\n[b]Distance[/b] "+RNS.prettydistance(edst)
rcvd_d_str = f"\n[b]Distance[/b] {RNS.prettydistance(edst)}"
elif "geodesic" in d:
gdst = d["geodesic"]
if gdst != None:
rcvd_d_str = "\n[b]Distance[/b] "+RNS.prettydistance(gdst) + " (geodesic)"
rcvd_d_str = f"\n[b]Distance[/b] {RNS.prettydistance(gdst)} (geodesic)"
phy_stats_str = ""
if "extras" in m and m["extras"] != None:
@ -500,64 +500,64 @@ class Messages():
if "q" in phy_stats:
try:
lq = round(float(phy_stats["q"]), 1)
phy_stats_str += "[b]Link Quality[/b] "+str(lq)+"% "
phy_stats_str += f"[b]Link Quality[/b] {lq)}% "
extra_telemetry["quality"] = lq
except:
pass
if "rssi" in phy_stats:
try:
lr = round(float(phy_stats["rssi"]), 1)
phy_stats_str += "[b]RSSI[/b] "+str(lr)+"dBm "
phy_stats_str += f"[b]RSSI[/b] {lr)}dBm "
extra_telemetry["rssi"] = lr
except:
pass
if "snr" in phy_stats:
try:
ls = round(float(phy_stats["snr"]), 1)
phy_stats_str += "[b]SNR[/b] "+str(ls)+"dB "
phy_stats_str += f"[b]SNR[/b] {ls)}dB "
extra_telemetry["snr"] = ls
except:
pass
if m["title"]:
titlestr = "[b]Title[/b] "+m["title"].decode("utf-8")+"\n"
titlestr = f"[b]Title[/b] {m['title'].decode('utf-8')}\n"
if m["source"] == self.app.sideband.lxmf_destination.hash:
if m["state"] == LXMF.LXMessage.DELIVERED:
msg_color = mdc(color_delivered, intensity_msgs)
heading_str = titlestr+"[b]Sent[/b] "+txstr+delivery_syms+"\n[b]State[/b] Delivered"
heading_str = f"{titlestr}[b]Sent[/b] {txstr}{delivery_syms}\n[b]State[/b] Delivered"
elif m["method"] == LXMF.LXMessage.PROPAGATED and m["state"] == LXMF.LXMessage.SENT:
msg_color = mdc(color_propagated, intensity_msgs)
heading_str = titlestr+"[b]Sent[/b] "+txstr+delivery_syms+"\n[b]State[/b] On Propagation Net"
heading_str = f"{titlestr}[b]Sent[/b] {txstr}{delivery_syms}\n[b]State[/b] On Propagation Net"
elif m["method"] == LXMF.LXMessage.PAPER:
msg_color = mdc(color_paper, intensity_msgs)
heading_str = titlestr+"[b]Created[/b] "+txstr+"\n[b]State[/b] Paper Message"
heading_str = f"{titlestr}[b]Created[/b] {txstr}\n[b]State[/b] Paper Message"
elif m["state"] == LXMF.LXMessage.FAILED:
msg_color = mdc(color_failed, intensity_msgs)
heading_str = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Failed"
heading_str = f"{titlestr}[b]Sent[/b] {txstr}\n[b]State[/b] Failed"
elif m["state"] == LXMF.LXMessage.OUTBOUND or m["state"] == LXMF.LXMessage.SENDING:
msg_color = mdc(color_unknown, intensity_msgs)
heading_str = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Sending "
heading_str = f"{titlestr}[b]Sent[/b] {txstr}\n[b]State[/b] Sending "
else:
msg_color = mdc(color_unknown, intensity_msgs)
heading_str = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Unknown"
heading_str = f"{titlestr}[b]Sent[/b] {txstr}\n[b]State[/b] Unknown"
else:
msg_color = mdc(color_received, intensity_msgs)
heading_str = titlestr
if phy_stats_str != "" and self.app.sideband.config["advanced_stats"]:
heading_str += phy_stats_str+"\n"
heading_str += f"{phy_stats_str}\n"
# TODO: Remove
# if stamp_valid:
# txstr += f" [b]Stamp[/b] value is {stamp_value} "
heading_str += "[b]Sent[/b] "+txstr+delivery_syms
heading_str += "\n[b]Received[/b] "+rxstr
heading_str += f"[b]Sent[/b] {txstr}{delivery_syms}"
heading_str += f"\n[b]Received[/b] {rxstr}"
if rcvd_d_str != "":
heading_str += rcvd_d_str
@ -575,7 +575,7 @@ class Messages():
if has_attachment:
heading_str += "\n[b]Attachments[/b] "
for attachment in attachments_field:
heading_str += str(attachment[0])+", "
heading_str += f"{attachment[0])}, "
heading_str = heading_str[:-2]
if has_audio:
@ -724,7 +724,7 @@ class Messages():
def x():
image_field = item.image_field
extension = str(image_field[0]).replace(".", "")
filename = time.strftime("LXM_%Y_%m_%d_%H_%M_%S", time.localtime(time.time()))+"."+str(extension)
filename = f"{time.strftime('LXM_%Y_%m_%d_%H_%M_%S', time.localtime(time.time()))}.{extension)}"
self.app.share_image(image_field[1], filename)
item.dmenu.dismiss()
@ -735,11 +735,11 @@ class Messages():
image_field = item.image_field
try:
extension = str(image_field[0]).replace(".", "")
filename = time.strftime("LXM_%Y_%m_%d_%H_%M_%S", time.localtime(time.time()))+"."+str(extension)
filename = f"{time.strftime('LXM_%Y_%m_%d_%H_%M_%S', time.localtime(time.time()))}.{extension)}"
if RNS.vendor.platformutils.is_darwin():
save_path = str(plyer.storagepath.get_downloads_dir()+filename).replace("file://", "")
else:
save_path = plyer.storagepath.get_downloads_dir()+"/"+filename
save_path = f"{plyer.storagepath.get_downloads_dir()}/{filename}"
with open(save_path, "wb") as save_file:
save_file.write(image_field[1])
@ -749,7 +749,7 @@ class Messages():
ok_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
dialog = MDDialog(
title="Image Saved",
text="The image has been saved to: "+save_path+"",
text=f"The image has been saved to: {save_path}",
buttons=[ ok_button ],
# elevation=0,
)
@ -764,7 +764,7 @@ class Messages():
ok_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
dialog = MDDialog(
title="Error",
text="Could not save the image:\n\n"+save_path+"\n\n"+str(e),
text=f"Could not save the image:\n\n{save_path}\n\n{e)}",
buttons=[ ok_button ],
# elevation=0,
)
@ -786,13 +786,13 @@ class Messages():
if RNS.vendor.platformutils.is_darwin():
output_path = str(plyer.storagepath.get_downloads_dir()).replace("file://", "")
else:
output_path = plyer.storagepath.get_downloads_dir()+"/"
output_path = f"{plyer.storagepath.get_downloads_dir()}/"
if len(attachments_field) == 1:
saved_text = "The attached file has been saved to: "+output_path
saved_text = f"The attached file has been saved to: {output_path}"
saved_title = "Attachment Saved"
else:
saved_text = "The attached files have been saved to: "+output_path
saved_text = f"The attached files have been saved to: {output_path}"
saved_title = "Attachment Saved"
for attachment in attachments_field:
@ -800,15 +800,15 @@ class Messages():
if RNS.vendor.platformutils.is_darwin():
save_path = str(plyer.storagepath.get_downloads_dir()+filename).replace("file://", "")
else:
save_path = plyer.storagepath.get_downloads_dir()+"/"+filename
save_path = f"{plyer.storagepath.get_downloads_dir()}/{filename}"
name_counter = 1
pre_count = save_path
while os.path.exists(save_path):
save_path = str(pre_count)+"."+str(name_counter)
save_path = f"{pre_count)}.{name_counter)}"
name_counter += 1
saved_text = "The attached file has been saved to: "+save_path
saved_text = f"The attached file has been saved to: {save_path}"
with open(save_path, "wb") as save_file:
save_file.write(attachment[1])
@ -833,7 +833,7 @@ class Messages():
ok_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
dialog = MDDialog(
title="Error",
text="Could not save the attachment:\n\n"+save_path+"\n\n"+str(e),
text=f"Could not save the attachment:\n\n{save_path}\n\n{e)}",
buttons=[ ok_button ],
# elevation=0,
)
@ -863,7 +863,7 @@ class Messages():
Clipboard.copy(str(tlm))
item.dmenu.dismiss()
except Exception as e:
RNS.log("An error occurred while decoding telemetry. The contained exception was: "+str(e), RNS.LOG_ERROR)
RNS.log(f"An error occurred while decoding telemetry. The contained exception was: {e)}", RNS.LOG_ERROR)
Clipboard.copy("Could not decode telemetry")
return x
@ -880,7 +880,7 @@ class Messages():
def x():
qr_image = lxm.as_qr()
hash_str = RNS.hexrep(lxm.hash[-2:], delimit=False)
filename = "Paper_Message_"+time.strftime(file_ts_format, time.localtime(m["sent"]))+"_"+hash_str+".png"
filename = f"Paper_Message_{time.strftime(file_ts_format, time.localtime(m['sent']))}_{hash_str}.png"
# filename = "Paper_Message.png"
self.app.share_image(qr_image, filename)
item.dmenu.dismiss()
@ -891,11 +891,11 @@ class Messages():
try:
qr_image = lxm.as_qr()
hash_str = RNS.hexrep(lxm.hash[-2:], delimit=False)
filename = "Paper_Message_"+time.strftime(file_ts_format, time.localtime(m["sent"]))+"_"+hash_str+".png"
filename = f"Paper_Message_{time.strftime(file_ts_format, time.localtime(m['sent']))}_{hash_str}.png"
if RNS.vendor.platformutils.is_darwin():
save_path = str(plyer.storagepath.get_downloads_dir()+filename).replace("file://", "")
else:
save_path = plyer.storagepath.get_downloads_dir()+"/"+filename
save_path = f"{plyer.storagepath.get_downloads_dir()}/{filename}"
qr_image.save(save_path)
item.dmenu.dismiss()
@ -903,7 +903,7 @@ class Messages():
ok_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
dialog = MDDialog(
title="QR Code Saved",
text="The paper message has been saved to: "+save_path+"",
text=f"The paper message has been saved to: {save_path}",
buttons=[ ok_button ],
# elevation=0,
)
@ -918,7 +918,7 @@ class Messages():
ok_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
dialog = MDDialog(
title="Error",
text="Could not save the paper message QR-code to:\n\n"+save_path+"\n\n"+str(e),
text=f"Could not save the paper message QR-code to:\n\n{save_path}\n\n{e)}",
buttons=[ ok_button ],
# elevation=0,
)
@ -940,10 +940,10 @@ class Messages():
def x():
try:
qr_image = lxm.as_qr()
qr_tmp_path = self.app.sideband.tmp_dir+"/"+str(RNS.hexrep(lxm.hash, delimit=False))
qr_tmp_path = f"{self.app.sideband.tmp_dir}/{RNS.hexrep(lxm.hash, delimit=False))}"
qr_image.save(qr_tmp_path)
print_command = self.app.sideband.config["print_command"]+" "+qr_tmp_path
print_command = f"{self.app.sideband.config['print_command']} {qr_tmp_path}"
return_code = subprocess.call(shlex.split(print_command), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
os.unlink(qr_tmp_path)
@ -955,7 +955,7 @@ class Messages():
ok_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
dialog = MDDialog(
title="Error",
text="Could not print the paper message QR-code.\n\n"+str(e),
text=f"Could not print the paper message QR-code.\n\n{e)}",
buttons=[ ok_button ],
# elevation=0,
)

View file

@ -155,9 +155,9 @@ class ObjectDetails():
self.screen.ids.name_label.text = pds
if source_dest == own_address:
self.screen.ids.name_label.text = pds+" (this device)"
self.screen.ids.name_label.text = f"{pds} (this device)"
elif source_dest == self.app.sideband.config["telemetry_collector"]:
self.screen.ids.name_label.text = pds+" (collector)"
self.screen.ids.name_label.text = f"{pds} (collector)"
self.screen.ids.coordinates_button.disabled = True
self.screen.ids.object_appearance.icon = appearance[0]
@ -211,7 +211,7 @@ class ObjectDetails():
except Exception as e:
import traceback
exception_info = "".join(traceback.TracebackException.from_exception(e).format())
RNS.log(f"An {str(type(e))} occurred while updating service telemetry: {str(e)}", RNS.LOG_ERROR)
RNS.log(f"An {type(e))} occurred while updating service telemetry: {e)}", RNS.LOG_ERROR)
RNS.log(exception_info, RNS.LOG_ERROR)
def reload(self):
@ -274,7 +274,7 @@ class ObjectDetails():
def update(self):
us = time.time()
self.update_widget()
RNS.log("Updated object details in "+RNS.prettytime(time.time()-us), RNS.LOG_DEBUG)
RNS.log(f"Updated object details in {RNS.prettytime(time.time() - us)}", RNS.LOG_DEBUG)
def update_widget(self):
if self.widget == None:
@ -414,7 +414,7 @@ class RVDetails(MDRecycleView):
else:
cs_str = f" ({cs})"
if p != None: formatted_values = f"{name} [b]{p}%[/b]"+cs_str
if p != None: formatted_values = f"{name} [b]{p}%[/b]{cs_str}"
elif name == "Ambient Pressure":
p = s["values"]["mbar"]
@ -447,10 +447,10 @@ class RVDetails(MDRecycleView):
if q != None: q_str = f"Link Quality [b]{q}%[/b]"
if rssi != None:
rssi_str = f"RSSI [b]{rssi} dBm[/b]"
if q != None: rssi_str = ", "+rssi_str
if q != None: rssi_str = f", {rssi_str}"
if snr != None:
snr_str = f"SNR [b]{snr} dB[/b]"
if q != None or rssi != None: snr_str = ", "+snr_str
if q != None or rssi != None: snr_str = f", {snr_str}"
if q_str or rssi_str or snr_str:
formatted_values = q_str+rssi_str+snr_str
@ -592,7 +592,7 @@ class RVDetails(MDRecycleView):
pct = round(load*100.0, 1)
avgs_str = f", averages are [b]{round(avgs[0],2)}[/b], [b]{round(avgs[1],2)}[/b], [b]{round(avgs[2],2)}[/b]" if avgs != None and len(avgs) == 3 else ""
clock_str = " at [b]"+RNS.prettyfrequency(clock)+"[/b]" if clock != None else ""
clock_str = f" at [b]{RNS.prettyfrequency(clock)}[/b]" if clock != None else ""
e_text = f"Using [b]{pct}%[/b] of {label}{clock_str}{avgs_str}"
e_text = f"{label} use is [b]{pct}%[/b]{clock_str}{avgs_str}"
@ -650,7 +650,7 @@ class RVDetails(MDRecycleView):
speed_formatted_values = f"Object is [b]stationary[/b]"
else:
speed_formatted_values = None
extra_formatted_values = f"Uncertainty [b]{accuracy} meters[/b]"+updated_str
extra_formatted_values = f"Uncertainty [b]{accuracy} meters[/b]{updated_str}"
data = {"icon": s["icon"], "text": f"{formatted_values}"}
@ -778,7 +778,7 @@ class RVDetails(MDRecycleView):
except Exception as e:
RNS.log("An error ocurred while displaying telemetry for object", RNS.LOG_ERROR)
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
RNS.log(f"The contained exception was: {e)}", RNS.LOG_ERROR)
RNS.trace_exception(e)
try:
@ -816,7 +816,7 @@ class RVDetails(MDRecycleView):
if ticket_expires:
t_str = ", but have ticket"
if stamp_cost:
self.entries.append({"icon": "postage-stamp", "text": f"Required stamp cost [b]{stamp_cost}[/b]"+t_str, "on_release": pass_job})
self.entries.append({"icon": "postage-stamp", "text": f"Required stamp cost [b]{stamp_cost}[/b]{t_str}", "on_release": pass_job})
else:
self.entries.append({"icon": "postage-stamp", "text": f"No required stamp cost", "on_release": pass_job})
if ticket_expires:
@ -834,7 +834,7 @@ class RVDetails(MDRecycleView):
except Exception as e:
import traceback
exception_info = "".join(traceback.TracebackException.from_exception(e).format())
RNS.log(f"An {str(type(e))} occurred while updating service telemetry: {str(e)}", RNS.LOG_ERROR)
RNS.log(f"An {type(e))} occurred while updating service telemetry: {e)}", RNS.LOG_ERROR)
RNS.log(exception_info, RNS.LOG_ERROR)

View file

@ -99,7 +99,7 @@ class Telemetry():
info += "Sideband will become a Telemetry Collector, and other authorized peers will be able to query its collected data.\n"
if self.app.theme_cls.theme_style == "Dark":
info = "[color=#"+self.app.dark_theme_text_color+"]"+info+"[/color]"
info = f"[color=#{self.app.dark_theme_text_color}]{info}[/color]"
self.screen.ids.telemetry_info.text = info
@ -118,7 +118,7 @@ class Telemetry():
interval_text = RNS.prettytime(interval)
if self.screen.ids.telemetry_send_to_collector.active:
self.screen.ids.telemetry_send_to_collector_label.text = "Auto sync to collector every "+interval_text
self.screen.ids.telemetry_send_to_collector_label.text = f"Auto sync to collector every {interval_text}"
else:
self.screen.ids.telemetry_send_to_collector_label.text = "Auto sync to collector"
@ -164,7 +164,7 @@ class Telemetry():
interval_text = RNS.prettytime(interval)
if self.screen.ids.telemetry_request_from_collector.active:
self.screen.ids.telemetry_request_from_collector_label.text = "Auto sync from collector every "+interval_text
self.screen.ids.telemetry_request_from_collector_label.text = f"Auto sync from collector every {interval_text}"
else:
self.screen.ids.telemetry_request_from_collector_label.text = "Auto sync from collector"
@ -329,7 +329,7 @@ class Telemetry():
info3 = "\nTo include a specific type of telemetry data while sending, it must be enabled below. Please note that some sensor types are not supported on all devices. Sideband will only be able to read a specific type of sensor if your device actually includes hardware for it.\n"
if self.app.theme_cls.theme_style == "Dark":
info3 = "[color=#"+self.app.dark_theme_text_color+"]"+info3+"[/color]"
info3 = f"[color=#{self.app.dark_theme_text_color}]{info3}[/color]"
self.sensors_screen.ids.telemetry_info3.text = info3
self.sensors_screen.ids.sensors_scrollview.effect_cls = ScrollEffect
@ -506,7 +506,7 @@ class Telemetry():
self.own_appearance_changed = True
def icons_selected(self, selected=None):
RNS.log("Selected: "+str(selected))
RNS.log(f"Selected: {selected)}")
if selected == None:
selected = "alpha-p-circle-outline"
self.telemetry_set_icon(selected)