How to use the b2sdk.v1.exception.CommandError function in b2sdk

To help you get started, we’ve selected a few b2sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Backblaze / b2-sdk-python / b2sdk / v0 / sync.py View on Github external
def get_synchronizer_from_args(
    args,
    max_workers,
    policies_manager=DEFAULT_SCAN_MANAGER,
    dry_run=False,
    allow_empty_source=False,
):
    if args.replaceNewer and args.skipNewer:
        raise CommandError('--skipNewer and --replaceNewer are incompatible')
    elif args.replaceNewer:
        newer_file_mode = NewerFileSyncMode.REPLACE
    elif args.skipNewer:
        newer_file_mode = NewerFileSyncMode.SKIP
    else:
        newer_file_mode = NewerFileSyncMode.RAISE_ERROR

    if args.delete and (args.keepDays is not None):
        raise CommandError('--delete and --keepDays are incompatible')

    if args.compareVersions == 'none':
        compare_version_mode = CompareVersionMode.NONE
    elif args.compareVersions == 'modTime':
        compare_version_mode = CompareVersionMode.MODTIME
    elif args.compareVersions == 'size':
        compare_version_mode = CompareVersionMode.SIZE
github Backblaze / b2-sdk-python / b2sdk / v0 / sync.py View on Github external
else:
        newer_file_mode = NewerFileSyncMode.RAISE_ERROR

    if args.delete and (args.keepDays is not None):
        raise CommandError('--delete and --keepDays are incompatible')

    if args.compareVersions == 'none':
        compare_version_mode = CompareVersionMode.NONE
    elif args.compareVersions == 'modTime':
        compare_version_mode = CompareVersionMode.MODTIME
    elif args.compareVersions == 'size':
        compare_version_mode = CompareVersionMode.SIZE
    elif args.compareVersions is None:
        compare_version_mode = CompareVersionMode.MODTIME
    else:
        raise CommandError('Invalid option for --compareVersions')
    compare_threshold = args.compareThreshold

    keep_days = None

    if args.delete:
        keep_days_or_delete = KeepOrDeleteMode.DELETE
    elif args.keepDays:
        keep_days_or_delete = KeepOrDeleteMode.KEEP_BEFORE_DELETE
        keep_days = args.keepDays
    else:
        keep_days_or_delete = KeepOrDeleteMode.NO_DELETE

    return Synchronizer(
        max_workers,
        policies_manager=policies_manager,
        dry_run=dry_run,
github Backblaze / b2-sdk-python / b2sdk / v0 / sync.py View on Github external
max_workers,
    policies_manager=DEFAULT_SCAN_MANAGER,
    dry_run=False,
    allow_empty_source=False,
):
    if args.replaceNewer and args.skipNewer:
        raise CommandError('--skipNewer and --replaceNewer are incompatible')
    elif args.replaceNewer:
        newer_file_mode = NewerFileSyncMode.REPLACE
    elif args.skipNewer:
        newer_file_mode = NewerFileSyncMode.SKIP
    else:
        newer_file_mode = NewerFileSyncMode.RAISE_ERROR

    if args.delete and (args.keepDays is not None):
        raise CommandError('--delete and --keepDays are incompatible')

    if args.compareVersions == 'none':
        compare_version_mode = CompareVersionMode.NONE
    elif args.compareVersions == 'modTime':
        compare_version_mode = CompareVersionMode.MODTIME
    elif args.compareVersions == 'size':
        compare_version_mode = CompareVersionMode.SIZE
    elif args.compareVersions is None:
        compare_version_mode = CompareVersionMode.MODTIME
    else:
        raise CommandError('Invalid option for --compareVersions')
    compare_threshold = args.compareThreshold

    keep_days = None

    if args.delete:
github Backblaze / b2-sdk-python / b2sdk / v0 / sync.py View on Github external
def sync_folders(self, *args, **kwargs):
        try:
            super(Synchronizer, self).sync_folders(*args, **kwargs)
        except InvalidArgument as e:
            raise CommandError('--%s %s' % (e.parameter_name, e.message))
        except IncompleteSync as e:
            raise CommandError(str(e))
github Backblaze / b2-sdk-python / b2sdk / v0 / sync.py View on Github external
def sync_folders(self, *args, **kwargs):
        try:
            super(Synchronizer, self).sync_folders(*args, **kwargs)
        except InvalidArgument as e:
            raise CommandError('--%s %s' % (e.parameter_name, e.message))
        except IncompleteSync as e:
            raise CommandError(str(e))
github Backblaze / b2-sdk-python / b2sdk / v0 / sync.py View on Github external
args,
        1,
        policies_manager=policies_manager,
        dry_run=False,
        allow_empty_source=False,
    )
    try:
        return synchronizer.make_folder_sync_actions(
            source_folder,
            dest_folder,
            now_millis,
            reporter,
            policies_manager=policies_manager,
        )
    except InvalidArgument as e:
        raise CommandError('--%s %s' % (e.parameter_name, e.message))