mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[V3 Launcher] Use existing logic, fix bugs (#1168)
This commit is contained in:
parent
73d68e926d
commit
bc8b9d32db
@ -1,25 +1,16 @@
|
|||||||
# pylint: disable=missing-docstring
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import getpass
|
import getpass
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import appdirs
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from redbot.setup import basic_setup
|
from redbot.setup import basic_setup, load_existing_config
|
||||||
|
|
||||||
if sys.platform == "linux":
|
if sys.platform == "linux":
|
||||||
import distro
|
import distro
|
||||||
|
|
||||||
config_dir = Path(appdirs.AppDirs("Red-DiscordBot").user_config_dir)
|
|
||||||
config_file = config_dir / 'config.json'
|
|
||||||
|
|
||||||
PYTHON_OK = sys.version_info >= (3, 5)
|
PYTHON_OK = sys.version_info >= (3, 5)
|
||||||
INTERACTIVE_MODE = not len(sys.argv) > 1 # CLI flags = non-interactive
|
INTERACTIVE_MODE = not len(sys.argv) > 1 # CLI flags = non-interactive
|
||||||
|
|
||||||
@ -35,8 +26,7 @@ def parse_cli_args():
|
|||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Red - Discord Bot's launcher (V3)", allow_abbrev=False
|
description="Red - Discord Bot's launcher (V3)", allow_abbrev=False
|
||||||
)
|
)
|
||||||
with config_file.open("r") as fin:
|
instances = load_existing_config()
|
||||||
instances = json.loads(fin.read())
|
|
||||||
parser.add_argument("instancename", metavar="instancename", type=str,
|
parser.add_argument("instancename", metavar="instancename", type=str,
|
||||||
nargs="?", help="The instance to run", choices=list(instances.keys()))
|
nargs="?", help="The instance to run", choices=list(instances.keys()))
|
||||||
parser.add_argument("--start", "-s",
|
parser.add_argument("--start", "-s",
|
||||||
@ -206,8 +196,7 @@ def cli_flag_getter():
|
|||||||
|
|
||||||
|
|
||||||
def instance_menu():
|
def instance_menu():
|
||||||
with config_file.open("r") as fin:
|
instances = load_existing_config()
|
||||||
instances = json.loads(fin.read())
|
|
||||||
if not instances:
|
if not instances:
|
||||||
print("No instances found!")
|
print("No instances found!")
|
||||||
return None
|
return None
|
||||||
@ -260,7 +249,6 @@ def extras_selector():
|
|||||||
def debug_info():
|
def debug_info():
|
||||||
pyver = sys.version
|
pyver = sys.version
|
||||||
redver = pkg_resources.get_distribution("Red-DiscordBot").version
|
redver = pkg_resources.get_distribution("Red-DiscordBot").version
|
||||||
osver = ""
|
|
||||||
if IS_WINDOWS:
|
if IS_WINDOWS:
|
||||||
os_info = platform.uname()
|
os_info = platform.uname()
|
||||||
osver = "{} {} (version {}) {}".format(
|
osver = "{} {} (version {}) {}".format(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user