Exemple #1
0
def get_spotfinder_url(filename,host,port):
  if filename.find("EXIT")>=0:
    kill_server(host,port)
    return
  testurl = "%s:%d"%(host,port)
  selector = "/spotfinder"
  query_object = [
    ("filename",filename),
    ("bin",1),
  ]

  Response = post_multipart(host=testurl, selector=selector,
    fields = query_object, files = [])

  print(Response.getresponse().read())
  Response.close()
def get_spotfinder_url(filename,host,port):
  if filename.find("EXIT")>=0:
    kill_server(host,port)
    return
  testurl = "%s:%d"%(host,port)
  selector = "/spotfinder"
  query_object = [
    ("filename",filename),
    ("bin",1),
  ]

  Response = post_multipart(host=testurl, selector=selector,
    fields = query_object, files = [])

  print Response.getresponse().read()
  Response.close()
Exemple #3
0
def kill_server(host,port):
  from socket import error as socketerror
  try:
    while 1:
      testurl = "%s:%d"%(host,port)
      selector = "/spotfinder"
      query_object = [
      ("filename","EXIT"),
      ("bin",1),
      ]

      Response = post_multipart(host=testurl, selector=selector,
      fields = query_object, files = [])
      Response.getresponse()
      Response.close()
  except socketerror as e:
    pass
def kill_server(host,port):
  from socket import error as socketerror
  try:
    while 1:
      testurl = "%s:%d"%(host,port)
      selector = "/spotfinder"
      query_object = [
      ("filename","EXIT"),
      ("bin",1),
      ]

      Response = post_multipart(host=testurl, selector=selector,
      fields = query_object, files = [])
      Response.getresponse()
      Response.close()
  except socketerror,e:
    pass
Exemple #5
0
def get_spotfinder_url(file_object, host, port):
    testurl = "%s:%d" % (host, port)
    selector = "/spotfinder"
    start_index = 0
    stop_index = file_object.linearintdata.size()
    raw_string = file_object.linearintdata.slice_to_byte_str(
        start_index, stop_index)
    query_object = [
        ("moduleindex", file_object.__dict__.get("moduleindex", -1)),
        ("filename", file_object.filename),
        ("bin", 1),
        ("vendortype", file_object.vendortype),
        ("beam_center_reference_frame",
         file_object.beam_center_reference_frame),
        ("beam_center_convention", file_object.beam_center_convention),
        ("header", file_object.header),
        ("headerlines", ""),
    ]
    for item in [
            'DISTANCE', 'PHI', 'WAVELENGTH', 'TWOTHETA', 'OSC_RANGE',
            'CCD_IMAGE_SATURATION', 'OSC_START', 'DETECTOR_SN', 'PIXEL_SIZE',
            'SIZE1', 'SIZE2', 'BEAM_CENTER_X', 'BEAM_CENTER_Y'
    ]:
        if type(file_object.parameters[item]) == type(1.0):
            query_object.append((item, "%.6f" % file_object.parameters[item]))
        else:
            query_object.append((item, file_object.parameters[item]))

    files = [("adsc_data", file_object.filename, raw_string)]

    print("length of data in ints", stop_index)
    print("length of data in bytes", len(raw_string))
    assert len(raw_string) / 4 == stop_index

    Response = post_multipart(host=testurl,
                              selector=selector,
                              fields=query_object,
                              files=files)

    print(Response.getresponse().read())
def get_spotfinder_url(file_object,host,port):
  testurl = "%s:%d"%(host,port)
  selector = "/spotfinder"
  start_index=0
  stop_index = file_object.linearintdata.size()
  raw_string=file_object.linearintdata.slice_to_byte_str(start_index,stop_index)
  query_object = [
    ("moduleindex",file_object.__dict__.get("moduleindex",-1)),
    ("filename",file_object.filename),
    ("bin",1),
    ("vendortype",file_object.vendortype),
    ("beam_center_reference_frame",file_object.beam_center_reference_frame),
    ("beam_center_convention",file_object.beam_center_convention),
    ("header",file_object.header),
    ("headerlines",""),
  ]
  for item in ['DISTANCE', 'PHI', 'WAVELENGTH',
    'TWOTHETA', 'OSC_RANGE',
    'CCD_IMAGE_SATURATION', 'OSC_START', 'DETECTOR_SN', 'PIXEL_SIZE',
    'SIZE1','SIZE2','BEAM_CENTER_X','BEAM_CENTER_Y'
    ]:
    if type(file_object.parameters[item])==type(1.0):
      query_object.append((item,"%.6f"%file_object.parameters[item]))
    else:
      query_object.append((item,file_object.parameters[item]))

  files = [
    ("adsc_data",file_object.filename,raw_string)
  ]

  print "length of data in ints",stop_index
  print "length of data in bytes",len(raw_string)
  assert len(raw_string)/4==stop_index

  Response = post_multipart(host=testurl, selector=selector,
    fields = query_object, files = files)

  print Response.getresponse().read()