arthur/server.py
def add(self):
        """Add tasks"""

        payload = cherrypy.request.json

        logger.debug("Reading tasks...")
        for task_data in payload['tasks']:
            try:
                category = task_data['category']
                backend_args = task_data['backend_args']
                archive_args = task_data.get('archive', None)
                sched_args = task_data.get('scheduler', None)
            except KeyError as ex:
                logger.error("Task badly formed")
                raise ex

            from_date = backend_args.get('from_date', None)

            if from_date:
                backend_args['from_date'] = str_to_datetime(from_date)

            super().add_task(task_data['task_id'],
                             task_data['backend'],
                             category,
                             backend_args,
                             archive_args=archive_args,
                             sched_args=sched_args)
        logger.debug("Done. Ready to work!")

        return "Tasks added"
def add(self):
        """Add tasks"""

        payload = cherrypy.request.json

        logger.debug("Reading tasks...")
        for task_data in payload['tasks']:
            try:
                category = task_data['category']
                backend_args = task_data['backend_args']
                archive_args = task_data.get('archive', None)
                sched_args = task_data.get('scheduler', None)
            except KeyError as ex:
                logger.error("Task badly formed")
                raise ex

            from_date = backend_args.get('from_date', None)

            if from_date:
                backend_args['from_date'] = str_to_datetime(from_date)

            super().add_task(task_data['task_id'],
                             task_data['backend'],
                             category,
                             backend_args,
                             archive_args=archive_args,
                             sched_args=sched_args)
        logger.debug("Done. Ready to work!")

        return "Tasks added"
Add tasks