1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-23 08:13:14 +00:00

Add NO_CLI env var for tests (#1856)

This commit is contained in:
Vitiko 2022-05-28 22:08:26 -04:00 committed by GitHub
parent c501098982
commit 6515c42f26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,33 +5,34 @@ import argparse
from distutils.util import strtobool from distutils.util import strtobool
no_update = bool(os.environ.get("NO_UPDATE", False)) no_update = os.environ.get("NO_UPDATE", "false").strip() == "true"
no_cli = os.environ.get("NO_CLI", "false").strip() == "true"
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.register('type', bool, strtobool)
def get_args(): config_dir = os.path.realpath(os.path.join(os.path.dirname(os.path.dirname(__file__)), '..', 'data'))
parser.register('type', bool, strtobool) parser.add_argument('-c', '--config', default=config_dir, type=str, metavar="DIR",
dest="config_dir", help="Directory containing the configuration (default: %s)" % config_dir)
config_dir = os.path.realpath(os.path.join(os.path.dirname(os.path.dirname(__file__)), '..', 'data')) parser.add_argument('-p', '--port', type=int, metavar="PORT", dest="port",
parser.add_argument('-c', '--config', default=config_dir, type=str, metavar="DIR", help="Port number (default: 6767)")
dest="config_dir", help="Directory containing the configuration (default: %s)" % config_dir) if not no_update:
parser.add_argument('-p', '--port', type=int, metavar="PORT", dest="port", parser.add_argument('--no-update', default=False, type=bool, const=True, metavar="BOOL", nargs="?",
help="Port number (default: 6767)") help="Disable update functionality (default: False)")
if not no_update: parser.add_argument('--debug', default=False, type=bool, const=True, metavar="BOOL", nargs="?",
parser.add_argument('--no-update', default=False, type=bool, const=True, metavar="BOOL", nargs="?", help="Enable console debugging (default: False)")
help="Disable update functionality (default: False)") parser.add_argument('--release-update', default=False, type=bool, const=True, metavar="BOOL", nargs="?",
parser.add_argument('--debug', default=False, type=bool, const=True, metavar="BOOL", nargs="?", help="Enable file based updater (default: False)")
help="Enable console debugging (default: False)") parser.add_argument('--dev', default=False, type=bool, const=True, metavar="BOOL", nargs="?",
parser.add_argument('--release-update', default=False, type=bool, const=True, metavar="BOOL", nargs="?", help="Enable developer mode (default: False)")
help="Enable file based updater (default: False)") parser.add_argument('--no-tasks', default=False, type=bool, const=True, metavar="BOOL", nargs="?",
parser.add_argument('--dev', default=False, type=bool, const=True, metavar="BOOL", nargs="?", help="Disable all tasks (default: False)")
help="Enable developer mode (default: False)")
parser.add_argument('--no-tasks', default=False, type=bool, const=True, metavar="BOOL", nargs="?",
help="Disable all tasks (default: False)")
return parser.parse_args()
args = get_args() if not no_cli:
if no_update: args = parser.parse_args()
args.no_update = True if no_update:
args.no_update = True
else:
args = parser.parse_args(["-c", config_dir, "--no-update"])