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

@ -22,11 +22,11 @@ class BasicCommandPlugin(SidebandCommandPlugin):
super().stop()
def handle_command(self, arguments, lxm):
response_content = "Hello "+RNS.prettyhexrep(lxm.source_hash)+". "
response_content = f"Hello {RNS.prettyhexrep(lxm.source_hash)}. "
response_content += "This is a response from the basic command example. It doesn't do much, but here is a list of the arguments you included:\n"
for argument in arguments:
response_content += "\n"+str(argument)
response_content += f"\n{argument)}"
# Let the Sideband core send a reply.
self.get_sideband().send_message(

View file

@ -61,7 +61,7 @@ class ComicCommandPlugin(SidebandCommandPlugin):
except Exception as e:
# Send an error message
self.get_sideband().send_message(
"An error occurred while trying to fetch the specified comic:\n\n"+str(e),
f"An error occurred while trying to fetch the specified comic:\n\n{e)}",
lxm.source_hash,
False, # Don't use propagation by default, try direct first
skip_fields = True, # Don't include any additional fields automatically

View file

@ -12,9 +12,9 @@ class BasicServicePlugin(SidebandServicePlugin):
def service_jobs(self):
while self.should_run:
time.sleep(5)
RNS.log("Service ping from "+str(self))
RNS.log(f"Service ping from {self)}")
RNS.log("Jobs stopped running for "+str(self))
RNS.log(f"Jobs stopped running for {self)}")
def start(self):
# Do any initialisation work here

View file

@ -131,7 +131,7 @@ class CameraSource(ViewSource):
self.frame_queue.put(frame)
except Exception as e:
RNS.log("An error occurred while reading frames from the camera: "+str(e), RNS.LOG_ERROR)
RNS.log(f"An error occurred while reading frames from the camera: {e)}", RNS.LOG_ERROR)
self.release_camera()
@ -195,10 +195,10 @@ class StreamSource(ViewSource):
self.frame_queue.put(frame)
RNS.log(str(self)+" idled", RNS.LOG_DEBUG)
RNS.log(f"{self)} idled", RNS.LOG_DEBUG)
except Exception as e:
RNS.log("An error occurred while reading frames from the stream: "+str(e), RNS.LOG_ERROR)
RNS.log(f"An error occurred while reading frames from the stream: {e)}", RNS.LOG_ERROR)
self.release_stream()
@ -236,7 +236,7 @@ class FileSource(ViewSource):
self.source_data = image_file.read()
except Exception as e:
RNS.log("Could not read image at \"{self.path}\": "+str(e), RNS.LOG_ERROR)
RNS.log(f"Could not read image at \"{self.path}\": {e)}", RNS.LOG_ERROR)
self.source_data = None
class ViewCommandPlugin(SidebandCommandPlugin):
@ -292,7 +292,7 @@ class ViewCommandPlugin(SidebandCommandPlugin):
else:
response = "Available Sources:\n"
for source in self.sources:
response += "\n - "+str(source)
response += f"\n - {source)}"
self.message_response(response, requestor)
return