From 7d88234987aabc93334bf3d06f7ddf25677df403 Mon Sep 17 00:00:00 2001 From: John Burwell Date: Mon, 24 Apr 2023 19:44:03 -0500 Subject: [PATCH] fix issues with config file and package files --- rsbbs/bbs.py | 9 +++++---- {config => rsbbs}/config_default.yaml | 7 ++++--- rsbbs/rsbbs.py | 6 +++--- setup.py | 4 +++- 4 files changed, 15 insertions(+), 11 deletions(-) rename {config => rsbbs}/config_default.yaml (90%) diff --git a/rsbbs/bbs.py b/rsbbs/bbs.py index 7b3d279..6a93a1a 100644 --- a/rsbbs/bbs.py +++ b/rsbbs/bbs.py @@ -21,6 +21,7 @@ import os import subprocess import sys import yaml +import pkg_resources import platformdirs from sqlalchemy import create_engine, delete, select, or_ @@ -71,11 +72,11 @@ class BBS(): platformdirs.user_config_dir(appname='rsbbs', ensure_exists=True), 'config.yaml' ) + print(config_path) # If the file doesn't exist there, create it if not os.path.exists(config_path): - config_template_path = os.path.join( - os.path.dirname(__file__), - 'config_default.yaml') + config_template_path = pkg_resources.resource_filename( + __name__, 'config_default.yaml') try: with open(config_template_path, 'r') as f: config_template = yaml.load(f, Loader=yaml.FullLoader) @@ -442,7 +443,7 @@ class BBS(): # Show greeting greeting = [] greeting.append(f"[RSBBS-1.0.0] listening on " - f"{self.config['callsign']}") + f"{self.config['callsign']} ") greeting.append(f"Welcome to {self.config['bbs_name']}, " f"{self.calling_station}") greeting.append(self.config['banner_message']) diff --git a/config/config_default.yaml b/rsbbs/config_default.yaml similarity index 90% rename from config/config_default.yaml rename to rsbbs/config_default.yaml index 8403556..9eed185 100644 --- a/config/config_default.yaml +++ b/rsbbs/config_default.yaml @@ -5,9 +5,10 @@ # Basic BBS info bbs_name: Really Simple BBS -callsign: KI5QKX-10 -banner_message: KI5QKX-10 welcomes you -command_prompt: "ENTER COMMAND >" +callsign: N0CALL +banner_message: Leave a message! + +command_prompt: ENTER COMMAND > # Logging diff --git a/rsbbs/rsbbs.py b/rsbbs/rsbbs.py index 7cf5656..c101178 100755 --- a/rsbbs/rsbbs.py +++ b/rsbbs/rsbbs.py @@ -35,9 +35,9 @@ def main(): ['-d', '--debug', 'store_true', None, 'debug', 'Enable debugging output to stdout', False], ['-s', '--calling-station', 'store', 'N0CALL', 'calling_station', - 'The callsign of the calling station', True], - ['-f', '--config-file', 'store', 'config.yaml', 'config_file', - 'specify path to config.yaml file', False], + 'Callsign of the calling station', True], + ['-f', '--config-file', 'store', None, 'config_file', + 'Path to config.yaml file', False], ] for arg in args_list: sysv_parser.add_argument( diff --git a/setup.py b/setup.py index 2e626aa..b6554d8 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,9 @@ setup( url='https://git.b-wells.us/jmbwell/rsbbs', license=license, packages=find_packages(exclude=('tests', 'docs')), - data_files=[('config', ['config/config_default.yaml'])], + package_data={ + 'rsbbs': ['config_default.yaml'], + }, entry_points=""" [console_scripts] rsbbs=rsbbs.rsbbs:main