[x] I have tested my changes against the dev branch (the latest developmental version), and this pull request is targeting that branch as a base
[x] I have tested my changes on Python 3.8 or higher
[x] I have ensured my code is formatted using Black
Description
This PR contains all the changes that have been made so far to the run.py and immediately connected files.
It is one in probably many PRs to bring changes from fae into dev in a more review/audit-friendly way. That said, this PR should be functional, but some features may be missing or bugs still present that anticipate future changes.
Here is a list of changes and impacts this PR should include:
It adds CLI args for logs and update checking, as well as disabling those checks.
Use -h or --help to list command line arguments and exit.
Use -V or --version to print bot version and exit.
Use --no-checks to disable all required and optional startup checks (this arg existed before this update.)
Use --update-check to disable only the startup update checks. (these only check for updates, nothing is applied)
Use --no-install-deps to prevent MusicBot from trying automatically to install dependencies when it encounters an ImportError.
Use --logs-kept [N] to set the number of logs to keep when rotating.
Default is 0, meaning no rotation happens and the log file is overwritten each launch.
Maximum is capped at 100 files arbitrarily.
Use --log-rotate-fmt to set a strftime compatible date-time format that will use time-of-rotation to rename the file.
Default is .ended-%Y-%j-%H%m%S which is added to the original log file name, just before it's extension.
Example default file(s): musicbot.ended-2024-043-150222.log and if Debug is enabled discord.ended-2024-043-150222.log
Use --log-level to set and override any DebugLevel setting given in the options.ini file for the session.
It includes a bug fix for python 3.12 deprecation warning printed by asyncio.
It converts doBotInit() to setup_hook() so that discord.py will run that step before login.
It moves all logging setup and related handling into utils.py as functions instead.
Log file creation is deferred until after argument parse is done, to prevent empty log files.
Log options such as Logs kept, and rotation date format will be added to options.ini at a later time.
Log file rotation is only handled on shutdown, so logs from previous runs without log rotation enabled will be lost if they are not manually rotated.
It likely also includes some groundwork for later changes in util.py, in the form of some unused imports.
Unfortunately this PR will not yet restore graceful handling of missing dependencies as that depends on changes that will be included in a future PR.
dev
branch (the latest developmental version), and this pull request is targeting that branch as a baseDescription
This PR contains all the changes that have been made so far to the run.py and immediately connected files.
It is one in probably many PRs to bring changes from
fae
intodev
in a more review/audit-friendly way. That said, this PR should be functional, but some features may be missing or bugs still present that anticipate future changes. Here is a list of changes and impacts this PR should include:It adds CLI args for logs and update checking, as well as disabling those checks.
-h
or--help
to list command line arguments and exit.-V
or--version
to print bot version and exit.--no-checks
to disable all required and optional startup checks (this arg existed before this update.)--update-check
to disable only the startup update checks. (these only check for updates, nothing is applied)--no-install-deps
to prevent MusicBot from trying automatically to install dependencies when it encounters an ImportError.--logs-kept [N]
to set the number of logs to keep when rotating.--log-rotate-fmt
to set astrftime
compatible date-time format that will use time-of-rotation to rename the file..ended-%Y-%j-%H%m%S
which is added to the original log file name, just before it's extension.musicbot.ended-2024-043-150222.log
and if Debug is enableddiscord.ended-2024-043-150222.log
--log-level
to set and override any DebugLevel setting given in the options.ini file for the session.It includes a bug fix for python 3.12 deprecation warning printed by asyncio.
It converts doBotInit() to setup_hook() so that discord.py will run that step before login.
It moves all logging setup and related handling into utils.py as functions instead.
It likely also includes some groundwork for later changes in util.py, in the form of some unused imports. Unfortunately this PR will not yet restore graceful handling of missing dependencies as that depends on changes that will be included in a future PR.