def handle_authorized(self, *args, **options): task = options["task"] if task not in ("harvest", "export", "backup"): raise CommandError("Invalid task name '%s'" % task) mode = options.pop("mode") # get the duration when the task shall be scheduled if options.get("now"): interval = timedelta(0.0) elif options.get("in"): interval = parse_duration(options["in"]) else: # get the harvesting interval from collection configuration interval = None if task == "harvest": items = self.handle_harvest(mode, interval, *args, **options) elif task == "export": items = self.handle_export(mode, interval, *args, **options) else: raise CommandError("Unknown task '%s'." % task) # inform the daemon try: if items: schedule_many(items) else: send_reload_schedule() except Exception as exc: if options.get("traceback"): raise raise CommandError( "Failed to send 'reload' message to daemon. Error was '%s'" % exc)
def __init__(self, logs, config, app, incr): super(IncrementalBackup, self).__init__(logs, config, app) try: duration = parse_duration(incr) self.timestamp = timestamp(now() - duration) except ValueError: self.timestamp = timestamp(parse_datetime(incr))
def handle_authorized(self, *args, **options): task = options["task"] if task not in ("harvest", "export", "backup"): raise CommandError("Invalid task name '%s'" % task) mode = options.pop("mode") # get the duration when the task shall be scheduled if options.get("now"): interval = timedelta(0.0) elif options.get("in"): interval = parse_duration(options["in"]) else: # get the harvesting interval from collection configuration interval = None if task == "harvest": items = self.handle_harvest(mode, interval, *args, **options) elif task == "export": items = self.handle_export(mode, interval, *args, **options) else: raise CommandError("Unknown task '%s'." % task) # inform the daemon try: if items: schedule_many(items) else: send_reload_schedule() except Exception as exc: if options.get("traceback"): raise raise CommandError( "Failed to send 'reload' message to daemon. Error was '%s'" % exc )