예제 #1
0
def handle_get(id2, command, job_type):
  """Handle simple get and collection get"""
  check_import_export_headers()
  if command:
    if command != "download":
      BadRequest("Unknown command")
    return handle_file_download(id2)
  try:
    import_export.clear_overtimed_tasks()
    if id2:
      res = import_export.get(id2).log_json()
    else:
      ids = request.args.get("id__in")
      res = import_export.get_jobs(job_type, ids.split(",") if ids else None)
  except (Forbidden, NotFound):
    raise
  except Exception as e:
    logger.exception(e.message)
    raise BadRequest(
        app_errors.INCORRECT_REQUEST_DATA.format(job_type=job_type))

  return make_import_export_response(res)
예제 #2
0
def handle_get(id2, command, job_type):
  """Handle simple get and collection get"""
  check_import_export_headers()
  if command:
    if command != "download":
      BadRequest("Unknown command")
    return handle_file_download(id2)
  try:
    import_export.clear_overtimed_tasks()
    if id2:
      res = import_export.get(id2).log_json()
    else:
      ids = request.args.get("id__in")
      res = import_export.get_jobs(job_type, ids.split(",") if ids else None)
  except (Forbidden, NotFound):
    raise
  except Exception as e:
    logger.exception("%s failed due incorrect request data: %s",
                     job_type, e.message)
    raise BadRequest("%s failed due incorrect request data" % job_type)

  return make_import_export_response(res)
예제 #3
0
def handle_get(id2, command, job_type):
    """Handle simple get and collection get"""
    check_import_export_headers()
    if command:
        if command != "download":
            BadRequest("Unknown command")
        return handle_file_download(id2)
    try:
        import_export.clear_overtimed_tasks()
        if id2:
            res = import_export.get(id2).log_json()
        else:
            ids = request.args.get("id__in")
            res = import_export.get_jobs(job_type,
                                         ids.split(",") if ids else None)
    except (Forbidden, NotFound):
        raise
    except Exception as e:
        logger.exception("%s failed due incorrect request data: %s", job_type,
                         e.message)
        raise BadRequest("%s failed due incorrect request data" % job_type)

    return make_import_export_response(res)