mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-09 04:38:55 -05:00
[Core] Add redbot --debuginfo flag (#3183)
* [Core] Add `redbot --debuginfo` flag * Update cli.py * Create 3183.enhance.rst * Update __main__.py * Update __main__.py
This commit is contained in:
parent
c67b6cd443
commit
b6ae7a6d21
1
changelog.d/3183.enhance.rst
Normal file
1
changelog.d/3183.enhance.rst
Normal file
@ -0,0 +1 @@
|
|||||||
|
Add ``redbot --debuginfo`` flag that shows useful information for debugging.
|
||||||
@ -3,9 +3,12 @@
|
|||||||
# Discord Version check
|
# Discord Version check
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import getpass
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import pip
|
||||||
|
import platform
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
@ -16,7 +19,7 @@ import discord
|
|||||||
# Set the event loop policies here so any subsequent `get_event_loop()`
|
# Set the event loop policies here so any subsequent `get_event_loop()`
|
||||||
# calls, in particular those as a result of the following imports,
|
# calls, in particular those as a result of the following imports,
|
||||||
# return the correct loop object.
|
# return the correct loop object.
|
||||||
from redbot import _update_event_loop_policy
|
from redbot import _update_event_loop_policy, __version__
|
||||||
|
|
||||||
_update_event_loop_policy()
|
_update_event_loop_policy()
|
||||||
|
|
||||||
@ -73,6 +76,44 @@ def list_instances():
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def debug_info():
|
||||||
|
"""Shows debug information useful for debugging."""
|
||||||
|
if sys.platform == "linux":
|
||||||
|
import distro # pylint: disable=import-error
|
||||||
|
|
||||||
|
IS_WINDOWS = os.name == "nt"
|
||||||
|
IS_MAC = sys.platform == "darwin"
|
||||||
|
IS_LINUX = sys.platform == "linux"
|
||||||
|
|
||||||
|
pyver = sys.version
|
||||||
|
pipver = pip.__version__
|
||||||
|
redver = __version__
|
||||||
|
dpy_version = discord.__version__
|
||||||
|
if IS_WINDOWS:
|
||||||
|
os_info = platform.uname()
|
||||||
|
osver = "{} {} (version {})".format(os_info.system, os_info.release, os_info.version)
|
||||||
|
elif IS_MAC:
|
||||||
|
os_info = platform.mac_ver()
|
||||||
|
osver = "Mac OSX {} {}".format(os_info[0], os_info[2])
|
||||||
|
else:
|
||||||
|
os_info = distro.linux_distribution()
|
||||||
|
osver = "{} {}".format(os_info[0], os_info[1]).strip()
|
||||||
|
user_who_ran = getpass.getuser()
|
||||||
|
info = (
|
||||||
|
"Debug Info for Red\n\n"
|
||||||
|
+ "Red version: {}\n".format(redver)
|
||||||
|
+ "Python version: {}\n".format(pyver)
|
||||||
|
+ "Python executable: {}\n".format(sys.executable)
|
||||||
|
+ "Discord.py version: {}\n".format(dpy_version)
|
||||||
|
+ "Pip version: {}\n".format(pipver)
|
||||||
|
+ "OS version: {}\n".format(osver)
|
||||||
|
+ "System arch: {}\n".format(platform.machine())
|
||||||
|
+ "User: {}\n".format(user_who_ran)
|
||||||
|
)
|
||||||
|
print(info)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
def edit_instance(red, cli_flags):
|
def edit_instance(red, cli_flags):
|
||||||
no_prompt = cli_flags.no_prompt
|
no_prompt = cli_flags.no_prompt
|
||||||
token = cli_flags.token
|
token = cli_flags.token
|
||||||
@ -231,6 +272,8 @@ def main():
|
|||||||
print(description)
|
print(description)
|
||||||
print("Current Version: {}".format(__version__))
|
print("Current Version: {}".format(__version__))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
elif cli_flags.debuginfo:
|
||||||
|
debug_info()
|
||||||
elif not cli_flags.instance_name and (not cli_flags.no_instance or cli_flags.edit):
|
elif not cli_flags.instance_name and (not cli_flags.no_instance or cli_flags.edit):
|
||||||
print("Error: No instance name was provided!")
|
print("Error: No instance name was provided!")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
@ -73,6 +73,7 @@ def parse_cli_flags(args):
|
|||||||
description="Red - Discord Bot", usage="redbot <instance_name> [arguments]"
|
description="Red - Discord Bot", usage="redbot <instance_name> [arguments]"
|
||||||
)
|
)
|
||||||
parser.add_argument("--version", "-V", action="store_true", help="Show Red's current version")
|
parser.add_argument("--version", "-V", action="store_true", help="Show Red's current version")
|
||||||
|
parser.add_argument("--debuginfo", action="store_true", help="Show debug information.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--list-instances",
|
"--list-instances",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user