diff options
| author | 2018-09-24 15:26:31 +0100 | |
|---|---|---|
| committer | 2018-09-24 15:26:31 +0100 | |
| commit | bb641b08709c3e6177729121010bc02692600360 (patch) | |
| tree | 9ddee03d0b9f4aa222f222b104f0a1fec9259356 | |
| parent | Move most code in root directory to src/ (diff) | |
| signature | ||
Move log and database files to their own folders
| -rw-r--r-- | databases/.keep | 0 | ||||
| -rw-r--r-- | logs/.keep | 0 | ||||
| -rw-r--r-- | modules/database_backup.py | 7 | ||||
| -rw-r--r-- | src/Database.py | 2 | ||||
| -rwxr-xr-x | start.py | 6 |
5 files changed, 9 insertions, 6 deletions
diff --git a/databases/.keep b/databases/.keep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/databases/.keep diff --git a/logs/.keep b/logs/.keep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/logs/.keep diff --git a/modules/database_backup.py b/modules/database_backup.py index eeddbdf2..f842fa70 100644 --- a/modules/database_backup.py +++ b/modules/database_backup.py @@ -15,14 +15,15 @@ class Module(object): next_due=time.time()+until_next_hour) def backup(self, event): - files = glob.glob("%s.*" % self.bot.args.database) + full_location = self.bot.database.full_location + files = glob.glob("%s.*" % full_location) files = sorted(files) if len(files) == 5: os.remove(files[0]) suffix = datetime.datetime.now().strftime("%y-%m-%d.%H:%M:%S") - backup_file = "%s.%s" % (self.bot.args.database, suffix) - shutil.copy2(self.bot.args.database, backup_file) + backup_file = "%s.%s" % (full_location, suffix) + shutil.copy2(fulllocation, backup_file) event["timer"].redo() diff --git a/src/Database.py b/src/Database.py index dc87b004..3bf3fe90 100644 --- a/src/Database.py +++ b/src/Database.py @@ -239,7 +239,7 @@ class UserChannelSettings(Table): [user_id, channel_id, setting.lower()]) class Database(object): - def __init__(self, bot, directory, filename="bot.db"): + def __init__(self, bot, directory, filename): self.bot = bot self.filename = filename self.full_location = os.path.join(directory, filename) @@ -12,8 +12,10 @@ arg_parser = argparse.ArgumentParser( description="Python3 event-driven asynchronous modular IRC bot") arg_parser.add_argument("--config", "-c", default="bot.conf", help="Location of the JSON config file") -arg_parser.add_argument("--database", "-d", default="bot.db", +arg_parser.add_argument("--database", "-d", default="databases/bot.db", help="Location of the sqlite3 database file") +arg_parser.add_argument("--log", "-l", default="logs/bot.log", + help="Location of the main log file") arg_parser.add_argument("--verbose", "-v", action="store_true") args = arg_parser.parse_args() @@ -27,7 +29,7 @@ bot._exports = exports = Exports.Exports() bot.modules = modules = ModuleManager.ModuleManager(bot, events, exports, os.path.join(directory, "modules")) bot.line_handler = IRCLineHandler.LineHandler(bot, bot._events) -bot.log = Logging.Log(bot, directory, "bot.log") +bot.log = Logging.Log(bot, directory, args.log) bot.database = Database.Database(bot, directory, args.database) bot.config = Config.Config(bot, directory, args.config).load_config() bot.args = args |
