Compare commits

..

11 Commits

Author SHA1 Message Date
42d578da76 attempt chunked output to avoid message too long error
All checks were successful
Test / Test (push) Successful in 1m0s
2023-08-31 13:02:10 -05:00
d729d69ea3 adjust line endings depending on invocation
All checks were successful
Test / Test (push) Successful in 1m45s
2023-08-31 12:41:23 -05:00
498defc003 flush output from stdout so that it transmits 2023-05-29 10:56:04 -05:00
c67179cdba fix multiline entry
All checks were successful
Test / Test (push) Successful in 1m16s
2023-05-28 14:07:02 -05:00
1bef879dac use result.rowcount instead of RETURNING for compatibility
All checks were successful
Test / Test (push) Successful in 1m24s
2023-05-28 14:03:54 -05:00
ea71dec87d add info_default.txt to package
All checks were successful
Test / Test (push) Successful in 1m18s
2023-05-12 16:47:33 -05:00
f813aa2656 fix path on info plugin
All checks were successful
Test / Test (push) Successful in 1m17s
2023-05-12 16:41:56 -05:00
6a8188f873 create dirs explicitly to deal with older versions of platformdirs
All checks were successful
Test / Test (push) Successful in 1m28s
2023-05-12 16:37:22 -05:00
db940aa983 fix imports on plugins
All checks were successful
Test / Test (push) Successful in 1m15s
2023-05-04 16:57:59 -05:00
46632fbef0 fix skipping init step
All checks were successful
Test / Test (push) Successful in 1m23s
2023-05-04 13:23:16 -05:00
e28756efa2 go back to importing the other way
All checks were successful
Test / Test (push) Successful in 1m28s
2023-05-04 13:15:27 -05:00
24 changed files with 98 additions and 50 deletions

View File

@ -29,6 +29,8 @@ user calls your station, `ax25d` answers the call and routes the connection to
you have configured your axports, and that ax25d can answer calls.
- **Python 3:** As this is a python 3 application, you will need python 3 and
pip.
- Note on compiling Python3: If you build Python3 from source on
debian/raspbian, you will need libssl-dev, libffi-dev, and libsqlite3-dev
- **Hardware:** A system capable of running Direwolf and ax25d should be more
than sufficient.

View File

@ -30,7 +30,7 @@ rsbbs = "rsbbs.rsbbs:main"
repository = "https://git.b-wells.us/jmbwell/rsbbs"
[tool.setuptools.package-data]
rsbbs = ["config_default.yaml"]
rsbbs = ["config_default.yaml","plugins/info/info_default.txt"]
[tool.setuptools.dynamic]
version = {attr = "rsbbs.__version__"}

View File

@ -20,11 +20,3 @@ __all__ = ['config', 'console', 'controller',
'logger', 'models', 'parser', 'pluginloader']
__version__ = "0.4.0"
from .config import Config
from .console import Console
from .controller import Controller
from .logger import Logger
from .parser import Parser
from .pluginloader import PluginLoader
from .user import User

View File

@ -28,13 +28,15 @@ class Config():
self.app_name = app_name
self._argv_config_file = args.config_file
self._init_config_file()
self._load_config()
# Put the messages db file in the system's user data directory
db_dir = platformdirs.user_data_dir(appname=self.app_name)
if not os.path.exists(db_dir):
os.makedirs(db_dir)
self._config['db_path'] = os.path.join(
platformdirs.user_data_dir(
appname=self.app_name,
ensure_exists=True),
db_dir,
'messages.db')
# Grab some config from the command line for convenience
@ -63,10 +65,11 @@ class Config():
@property
def config_file(self):
# Use either the specified file or a file in a system config location
config_dir = platformdirs.user_config_dir(appname=self.app_name)
if not os.path.exists(config_dir):
os.makedirs(config_dir)
config_file = self._argv_config_file or os.path.join(
platformdirs.user_config_dir(
appname=self.app_name,
ensure_exists=True),
config_dir,
'config.yaml'
)
return config_file

View File

@ -16,11 +16,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import io
import logging
import sys
import rsbbs
from rsbbs import Config, Controller
from rsbbs.config import Config
from rsbbs.controller import Controller
from rsbbs.parser import Parser
from rsbbs.pluginloader import PluginLoader
from rsbbs.models import User
@ -34,11 +38,20 @@ class Console():
self.controller = controller
self.user = user
self.parser = rsbbs.Parser()
self.parser = Parser()
self.pluginloader = rsbbs.PluginLoader(self)
self.pluginloader = PluginLoader(self)
self.pluginloader.load_plugins()
# Configure stdin and stdout newlines and encoding
# when invoked by ax25:
if not sys.stdin.isatty():
sys.stdout = io.TextIOWrapper(sys.stdout.detach(),
newline=None)
sys.stdin = io.TextIOWrapper(sys.stdin.detach(),
newline=None)
#
# Input and output
#
@ -87,18 +100,31 @@ class Console():
self.write_output(prompt)
while True:
input_line = sys.stdin.readline()
if input_line.lower().strip() != "/ex":
if input_line.lower().strip() == "/ex":
break
input_lines.append(input_line)
return ''.join(input_lines)
def write_chunk(self, chunk: str) -> None:
"""Write a chunk of data to stdout.
:param output: the chunk to write to stdout
"""
sys.stdout.write(chunk + '\r\n')
sys.stdout.flush()
def write_output(self, output: str) -> None:
"""Write something to stdout.
:param output: the string to write to stdout
"""
sys.stdout.write(output + '\r\n')
chunk_size = 256 # Adjust the chunk size as needed
for i in range(0, len(output), chunk_size):
chunk = output[i:i + chunk_size]
self.write_chunk(chunk)
def print_configuration(self) -> None:
"""Print the current running configuration.

View File

@ -19,7 +19,7 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from rsbbs import Config
from rsbbs.config import Config
from rsbbs.models import Base

View File

@ -48,10 +48,12 @@ class Logger(logging.Logger):
logger.removeHandler(handler)
# Log to a file in the system user log directory
log_dir = platformdirs.user_log_dir(appname=self.name,
ensure_exists=True)
log_dir = platformdirs.user_log_dir(appname=self.name)
log_filepath = os.path.join(log_dir, 'activity.log')
if not os.path.exists(log_dir):
os.makedirs(log_dir)
handler = logging.FileHandler(filename=log_filepath)
# Add the calling station to the log messages
@ -60,7 +62,6 @@ class Logger(logging.Logger):
# Add the handler!
logger.addHandler(handler)
class Formatter(logging.Formatter):
def __init__(self, var):
super().__init__()

View File

@ -18,7 +18,8 @@
import logging
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
class Plugin():

View File

@ -21,7 +21,8 @@ import logging
import sqlalchemy
import sqlalchemy.exc
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
from rsbbs.models import Message
@ -48,13 +49,12 @@ class Plugin():
sqlalchemy.and_(
Message.recipient == self.api.config.calling_station,
Message.id == number,
)).returning(Message)
))
result = session.execute(
statement,
execution_options={"prebuffer_rows": True})
count = result.rowcount
session.commit()
results = result.all()
count = len(results)
if count > 0:
self.api.write_output(f"Deleted message #{number}")
logging.info(f"deleted message {number}")

View File

@ -19,7 +19,8 @@
import logging
import sqlalchemy
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
from rsbbs.models import Message
@ -42,13 +43,12 @@ class Plugin():
try:
statement = sqlalchemy.delete(Message).where(
Message.recipient == self.api.config.calling_station
).returning(Message)
)
result = session.execute(
statement,
execution_options={"prebuffer_rows": True})
count = result.rowcount
session.commit()
messages = result.all()
count = len(messages)
if count > 0:
self.api.write_output(f"Deleted {count} messages")
logging.info(f"deleted {count} messages")

View File

@ -19,7 +19,8 @@
import logging
import subprocess
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
class Plugin():

View File

@ -16,7 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
class Plugin():

View File

@ -17,12 +17,14 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging
import os
import pkg_resources
import platformdirs
from pathlib import Path
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
class Plugin():
@ -42,10 +44,12 @@ class Plugin():
@property
def file(self) -> Path:
file_dir = platformdirs.user_config_dir(
appname=self.api.config.app_name)
if not os.path.exists(file_dir):
os.makedirs(file_dir)
self._file = Path().joinpath(
platformdirs.user_config_dir(
appname=self.api.config.app_name,
ensure_exists=True),
file_dir,
'info.txt'
)
return self._file

View File

@ -19,7 +19,8 @@
import logging
import sqlalchemy
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
from rsbbs.models import Message

View File

@ -19,7 +19,8 @@
import logging
import sqlalchemy
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
from rsbbs.models import Message

View File

@ -19,7 +19,8 @@
import logging
import sqlalchemy
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
from rsbbs.models import Message, User

View File

@ -20,7 +20,8 @@ import logging
import sqlalchemy
import sqlalchemy.exc
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
from rsbbs.models import Message, User

View File

@ -19,7 +19,8 @@
import logging
import sqlalchemy
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
from rsbbs.models import Message, User

View File

@ -19,7 +19,8 @@
import logging
import sqlalchemy
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
from rsbbs.models import Message, User

View File

@ -18,7 +18,8 @@
import logging
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
from rsbbs.models import Message

View File

@ -18,7 +18,8 @@
import logging
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
from rsbbs.models import Message

View File

@ -23,7 +23,8 @@ import sqlalchemy.orm
import subprocess
from rsbbs import __version__
from rsbbs import Console, Parser
from rsbbs.console import Console
from rsbbs.parser import Parser
from rsbbs.models import Message, User

View File

@ -18,7 +18,10 @@
import logging
from rsbbs import Config, Console, Controller, Logger
from rsbbs.config import Config
from rsbbs.console import Console
from rsbbs.controller import Controller
from rsbbs.logger import Logger
from rsbbs.args import parse_args
@ -26,6 +29,10 @@ from rsbbs.user import User
def main():
"""RSBBS - The BBS for packet radio that is really simple.
main function.
"""
# Grab the invocation arguments
args = parse_args()

View File

@ -23,7 +23,8 @@ from typing import Any
from datetime import datetime, timezone
from rsbbs import Config, Controller
from rsbbs.config import Config
from rsbbs.controller import Controller
from rsbbs.models import User as SAUser