def run(self, schedule_id, **kwargs):
        """
        Synchronises the schedule specified by the ID `schedule_id` to the
        scheduler service.

        Arguments:
            schedule_id {str} -- The ID of the schedule to sync
        """
        log = self.get_logger(**kwargs)

        try:
            schedule = Schedule.objects.get(id=schedule_id)
        except Schedule.DoesNotExist:
            log.error("Missing Schedule %s", schedule_id, exc_info=True)

        if schedule.scheduler_schedule_id is None:
            # Create the new schedule
            result = self.scheduler.create_schedule(schedule.scheduler_format)
            schedule.scheduler_schedule_id = result["id"]
            # Disable update signal here to avoid calling twice
            post_save.disconnect(schedule_saved, sender=Schedule)
            schedule.save(update_fields=("scheduler_schedule_id",))
            post_save.connect(schedule_saved, sender=Schedule)

            log.info(
                "Created schedule %s on scheduler for schedule %s",
                schedule.scheduler_schedule_id,
                schedule.id,
            )
        else:
            # Update the existing schedule
            result = self.scheduler.update_schedule(
                str(schedule.scheduler_schedule_id), schedule.scheduler_format
            )
            log.info(
                "Updated schedule %s on scheduler for schedule %s",
                schedule.scheduler_schedule_id,
                schedule.id,
            )
def run ( self , schedule_id , ** kwargs ) : log = self . get_logger ( ** kwargs ) try : schedule = Schedule . objects . get ( id = schedule_id ) except Schedule . DoesNotExist : log . error ( "Missing Schedule %s" , schedule_id , exc_info = True ) if schedule . scheduler_schedule_id is None : result = self . scheduler . create_schedule ( schedule . scheduler_format ) schedule . scheduler_schedule_id = result [ "id" ] post_save . disconnect ( schedule_saved , sender = Schedule ) schedule . save ( update_fields = ( "scheduler_schedule_id" , ) ) post_save . connect ( schedule_saved , sender = Schedule ) log . info ( "Created schedule %s on scheduler for schedule %s" , schedule . scheduler_schedule_id , schedule . id , ) else : result = self . scheduler . update_schedule ( str ( schedule . scheduler_schedule_id ) , schedule . scheduler_format ) log . info ( "Updated schedule %s on scheduler for schedule %s" , schedule . scheduler_schedule_id , schedule . id , )
Synchronises the schedule specified by the ID `schedule_id` to the
        scheduler service.

        Arguments:
            schedule_id {str} -- The ID of the schedule to sync