tidy up f-strings etc.
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 54s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 54s
This commit is contained in:
parent
ad1ac4c6b9
commit
2c32f833bc
@ -111,13 +111,13 @@ class Console():
|
||||
datetime = message.Message.datetime.strftime(
|
||||
'%A, %B %-d, %Y at %-H:%M %p UTC')
|
||||
# Print the message
|
||||
self.write_output(f"")
|
||||
self.write_output("")
|
||||
self.write_output(f"Message: {message.Message.id}")
|
||||
self.write_output(f"Date: {datetime}")
|
||||
self.write_output(f"From: {message.Message.sender}")
|
||||
self.write_output(f"To: {message.Message.recipient}")
|
||||
self.write_output(f"Subject: {message.Message.subject}")
|
||||
self.write_output(f"")
|
||||
self.write_output("")
|
||||
self.write_output(f"{message.Message.message}")
|
||||
|
||||
def print_message_list(self, messages) -> None:
|
||||
|
||||
@ -22,7 +22,7 @@ from sqlalchemy import Boolean, DateTime, String, Integer,\
|
||||
Table, ForeignKey, Column
|
||||
|
||||
from sqlalchemy.orm import DeclarativeBase, Mapped
|
||||
from sqlalchemy.orm import mapped_column, relationship, backref
|
||||
from sqlalchemy.orm import mapped_column, relationship
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
|
||||
@ -53,7 +53,7 @@ class PluginLoader():
|
||||
|
||||
# Add the loaded plugin to the list of plugins
|
||||
self.plugins.append(plugin)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
def load_plugins(self) -> None:
|
||||
|
||||
@ -62,7 +62,7 @@ class Plugin():
|
||||
self.api.write_output("A message with that ID addressed "
|
||||
"to you was not found.")
|
||||
except sqlalchemy.exc.NoResultFound:
|
||||
self.api.write_output(f"Message not found.")
|
||||
self.api.write_output("Message not found.")
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ class Plugin():
|
||||
self.api.write_output(f"Deleted {count} messages")
|
||||
logging.info(f"deleted {count} messages")
|
||||
else:
|
||||
self.api.write_output(f"No messages to delete.")
|
||||
self.api.write_output("No messages to delete.")
|
||||
except Exception as e:
|
||||
self.api.write_output(f"Unable to delete messages: {e}")
|
||||
|
||||
|
||||
@ -40,15 +40,15 @@ class Plugin():
|
||||
"""Show a log of stations that have been heard by this station,
|
||||
also known as the 'mheard' (linux) or 'jheard' (KPC, etc.) log.
|
||||
"""
|
||||
self.api.write_output(f"Heard stations:")
|
||||
self.api.write_output("Heard stations:")
|
||||
try:
|
||||
result = subprocess.run(['mheard'], capture_output=True, text=True)
|
||||
self.api.write_output(result.stdout)
|
||||
logging.info("queried heard log")
|
||||
except FileNotFoundError:
|
||||
self.api.write_output(f"mheard utility not found.")
|
||||
except Exception as e:
|
||||
self.api.write_output("mheard utility not found.")
|
||||
except Exception:
|
||||
if self.api.config.debug:
|
||||
raise
|
||||
else:
|
||||
self.api.write_output(f"Heard stations not available.")
|
||||
self.api.write_output("Heard stations not available.")
|
||||
|
||||
@ -52,14 +52,14 @@ class Plugin():
|
||||
sqlalchemy.not_(Message.is_private))))
|
||||
result = session.execute(statement).one()
|
||||
self.api.print_message(result)
|
||||
logging.info(f"read message")
|
||||
logging.info("read message")
|
||||
session.commit()
|
||||
user = session.get(User, self.api.user.id)
|
||||
user.messages.append(result[0])
|
||||
logging.info(f"User {user.id} read message {result[0].id}")
|
||||
session.commit()
|
||||
except sqlalchemy.exc.NoResultFound:
|
||||
self.api.write_output(f"Message not found.")
|
||||
self.api.write_output("Message not found.")
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ class Plugin():
|
||||
result = session.execute(
|
||||
statement,
|
||||
execution_options={"prebuffer_rows": True})
|
||||
logging.info(f"read message")
|
||||
logging.info("read message")
|
||||
return result
|
||||
except Exception:
|
||||
raise
|
||||
@ -68,4 +68,4 @@ class Plugin():
|
||||
f"read message {message[0].id }")
|
||||
self.api.read_enter("Enter to continue...")
|
||||
else:
|
||||
self.api.write_output(f"No messages to read.")
|
||||
self.api.write_output("No messages to read.")
|
||||
|
||||
@ -48,7 +48,7 @@ class Plugin():
|
||||
result = session.execute(
|
||||
statement,
|
||||
execution_options={"prebuffer_rows": True})
|
||||
logging.info(f"read message")
|
||||
logging.info("read message")
|
||||
return result
|
||||
except Exception:
|
||||
raise
|
||||
@ -71,4 +71,4 @@ class Plugin():
|
||||
f"read message {message[0].id }")
|
||||
self.api.read_enter("Enter to continue...")
|
||||
else:
|
||||
self.api.write_output(f"No messages to read.")
|
||||
self.api.write_output("No messages to read.")
|
||||
|
||||
@ -77,4 +77,4 @@ class Plugin():
|
||||
response.append(f"Messages: {self.get_message_count()}")
|
||||
response.append(f"Uptime: {self.get_uptime()}")
|
||||
self.api.write_output('\r\n'.join(response))
|
||||
logging.info(f"report stats")
|
||||
logging.info("report stats")
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
|
||||
import logging
|
||||
|
||||
from rsbbs import __version__
|
||||
from rsbbs import Config, Console, Controller, Logger
|
||||
|
||||
from rsbbs.args import parse_args
|
||||
@ -38,7 +37,7 @@ def main():
|
||||
|
||||
# Start logging
|
||||
logger = Logger(config)
|
||||
logging.info(f"caller connected")
|
||||
logging.info("caller connected")
|
||||
|
||||
# Init the controller
|
||||
controller = Controller(config)
|
||||
|
||||
@ -23,9 +23,7 @@ from typing import Any
|
||||
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from rsbbs import __version__
|
||||
from rsbbs import Config, Controller
|
||||
|
||||
from rsbbs.models import User as SAUser
|
||||
|
||||
|
||||
@ -53,14 +51,14 @@ class User():
|
||||
logging.info(f"User {result[0].callsign} found.")
|
||||
session.commit()
|
||||
else:
|
||||
logging.info(f"User not found.")
|
||||
logging.info("User not found.")
|
||||
user = SAUser(
|
||||
callsign=self.callsign,
|
||||
login_count=1,
|
||||
)
|
||||
session.add(user)
|
||||
session.commit()
|
||||
logging.info(f"User added.")
|
||||
logging.info("User added.")
|
||||
return user
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
@ -81,9 +79,9 @@ class User():
|
||||
user.login_count = user.login_count + 1
|
||||
user.login_last = datetime.now(timezone.utc)
|
||||
session.commit()
|
||||
logging.info(f"User updated.")
|
||||
logging.info("User updated.")
|
||||
else:
|
||||
logging.info(f"User not found.")
|
||||
logging.info("User not found.")
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
raise
|
||||
|
||||
Loading…
Reference in New Issue
Block a user