form_data = data['template']
  form_data['type'] = 'paper'
  form_data['mapping'] = {}

  # Iterate over parcel sets and create forms
  for parcelset in parcelsets:
    for i in range(len(parcelset)):
      form_data['parcels'][i]['parcel_id'] = parcelset[i]
    if noact:
      form_id = 'TEST0001'
    else:
      # Post form data to the API get an ID back
      ret_data = api.post_form(survey_id, {'forms' : [form_data]})
      form_id = ret_data['id']

    form_img = skeleton_img.copy()

    # Draw the barcode
    bc.drawbarcode_json(form_img, paperinfo, form_id)

    # Save the form
    # TODO: Use PNG or JPEG instead of TIFF
    outpath = '%s/%s.tif' % (outdir, form_id)
    form_img.save(outpath, 'TIFF')
    print 'Saved form to %s' % outpath


if __name__ == '__main__':
  sys.exit(main())

Esempio n. 2
0
    bs.draw(skeleton_img)

  # Draw the registration marks
  for mark in rmarks:
    mark.draw(skeleton_img)

  # Iterate over parcels and create forms
  form_data = {"forms" : [{"parcels" : [], "type" : "paper", "mapping" : {}, "survey" : survey_id}]}
  for parcel in parcels:
    form_data["forms"][0]["parcels"] = [{"parcel_id" : parcel, "bubblesets" : data["bubblesets"]}]
    if noact:
      form_id = "TEST0001"
    else:
      # Post form data to the API, get an ID back
      ret_data = api.post_form(survey_id, form_data)
      form_id = ret_data["id"]
    #
    form_img = skeleton_img.copy()
    #
    # Draw the barcode
    bc.drawbarcode_json(form_img, survey['paperinfo'], form_id)
    #
    # Save the form
    outpath = "%s/%s.tif" % (outdir, form_id)
    form_img.save(outpath, "TIFF")
    print "Saved form to %s"  % outpath

if __name__ == '__main__':
  sys.exit(main())