Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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,
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:
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))
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))
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))