def CronJobToApiCronJob(cron_job):
  """Converts AFF4 CronJob to api-friendly ApiCronJob."""
  cron_args = cron_job.Get(cron_job.Schema.CRON_ARGS)

  api_cron_job = ApiCronJob(urn=cron_job.urn,
                            description=cron_args.description,
                            flow_name=cron_args.flow_runner_args.flow_name,
                            flow_runner_args=cron_args.flow_runner_args,
                            periodicity=cron_args.periodicity,
                            lifetime=cron_args.lifetime,
                            allow_overruns=cron_args.allow_overruns,
                            state=GetCronJobState(cron_job),
                            last_run_time=cron_job.Get(
                                cron_job.Schema.LAST_RUN_TIME),
                            is_failing=IsCronJobFailing(cron_job))
  try:
    api_cron_job.flow_args = cron_args.flow_args
  except __HOLE__:
    # If args class name has changed, ValueError will be raised. Handling
    # this gracefully - we should still try to display some useful info
    # about the flow.
    pass

  return api_cron_job
dataset/ETHPy150Open google/grr/grr/gui/api_plugins/cron.py/CronJobToApiCronJob