Exemplo n.º 1
0
def cli_main() -> None:
    """Main functionality when run from CLI."""
    args = cli.args_simple(NAME, DESCRIPTION, CMD_LINE_ARGS)

    if args.version_out:
        cli.print_version(NAME, VERSION)

    applog.setup_app_logging(args.debug_log, args.log_file)

    if args.max_image_height < 1:
        raise ValueError("Max image height must be greater than 0. Specified %d" % args.max_image_height)
    if args.target_volume < float(1):
        raise ValueError("Target volume must be greater than 0. Specified %f" % args.target_volume)

    if not os.path.exists(args.mp3_directory):
        raise FileNotFoundError("Specified directory does not exist: %s" % args.mp3_directory)

    dir_to_process = os.path.abspath(args.mp3_directory)

    if not os.path.isdir(dir_to_process):
        raise NotADirectoryError("Specified directory path is not a directory: %s" % args.mp3_directory)

    fops.required_executables(__REQUIRED_EXECS)

    LOGGER.info("Processing: %s", args.mp3_directory)
    main(debug=args.debug_log, directory=dir_to_process, ignore_folder=args.ignore_folder,
         image_height=args.max_image_height, tags_only=args.tags_only, target_volume=args.target_volume)
Exemplo n.º 2
0
def main() -> None:
    """Main function"""
    parser = argparse.ArgumentParser(description=PROJECT_DESCRIPTION)
    for a_dict in C_LINE_ARGS:
        parser.add_argument(a_dict['short'], a_dict['long'], **a_dict['opts'])

    subparsers = parser.add_subparsers(help='command help')

    for sub, opts in C_LINE_GROUPS.items():
        sub_parser = subparsers.add_parser(sub, help=opts['help'])
        for op_name, args in opts['ops'].items():
            sub_parser.add_argument(op_name, **args)
            sub_parser.set_defaults(func=opts['func'])

    args = parser.parse_args()

    if args.version_out:
        print("{0!s} - {1!s}".format(PROJECT_NAME, PROJECT_VERSION))
        raise SystemExit(0)

    setup_app_logging(args.debug_log)

    has_sub = False
    for sub in C_LINE_GROUPS:
        if sub in sys.argv:
            has_sub = True
            break

    if not has_sub:
        parser.print_help()
        raise SystemExit(1)

    args.func(args)
Exemplo n.º 3
0
def main() -> None:
    """Main function"""
    args = cli.args_simple(PROJECT_NAME, PROJECT_DESCRIPTION, CMD_LINE_ARGS)

    if args.version_out:
        cli.print_version(PROJECT_NAME, PROJECT_VERSION)

    setup_app_logging(args.debug_log)

    try:
        settings = backup.load_config(args.config_file, DEFAULTS)
        plugins = backup.load_plugins()
    except (FileNotFoundError, IOError, ValueError) as exception_object:
        raise SystemExit(exception_object) from exception_object

    if settings.backup.skip_backup_directory:
        main_no_backup_directory(settings, plugins)
        raise SystemExit(0)

    main_backup_directory(settings, plugins)
    raise SystemExit(0)
Exemplo n.º 4
0
def run() -> None:
    """Run functionality."""
    # pylint: disable=global-statement
    global _DEBUG

    args = do_args()

    _DEBUG = args.debug_log
    setup_app_logging(args.debug_log)

    if args.version_out:
        do_version()

    if args.setup:
        do_setup()

    files, licenses = load_files_and_licenses()

    if args.list_file_types:
        do_print_file_types(files)

    if args.list_licenses:
        do_print_license_types(licenses)

    config = merge_dictionaries(DEFAULTS, fops.file_read_convert(CONFIG_FILE_PATH, fops.YAML, True))
    config = verify_config(config, args)

    if not files.get(config.get('file_type')):
        LOGGER.error("unsupported file type: %s", config.get('file_type'))
        raise SystemExit(-1)

    if not licenses.get(config.get('license')):
        LOGGER.error("unsupported license type: %s", config.get('license)'))
        raise SystemExit(-1)

    license_obj = licenses.get(config.get('license'))
    new_file = files.get(config.get('file_type')).new(config, license_obj)
    new_file.write()
Exemplo n.º 5
0
def cli_main() -> None:
    """Main functionality when run from CLI."""
    args = cli.args_simple(NAME, DESCRIPTION, CMD_LINE_ARGS)

    if args.version_out:
        cli.print_version(NAME, VERSION)

    applog.setup_app_logging(args.debug_log)

    if not os.path.exists(args.comic_file):
        raise FileNotFoundError(f"'{args.comic_file}' not found")
    if not os.path.isfile(args.comic_file):
        raise IsADirectoryError(f"'{args.comic_file}' is not a file")

    comic_file = os.path.realpath(args.comic_file)
    LOGGER.info(" -- Processing %s", comic_file)

    main(comic_file=comic_file,
         copy_only=args.copy_only,
         debug=args.debug_log,
         img_conv=args.images_format,
         img_filter=args.filter_pages,
         img_multi=args.allow_image_multi)
Exemplo n.º 6
0
 def test_setup_app_logging(self):
     path = _get_file()
     applog.setup_app_logging(True, path)