Esempio n. 1
0
    def interface3_parse_command(self):
        #The assumption is that there will be one or two regular files specified
        # on command line that are valid image file names
        # If there are two, root and ext must be the same in each case.
        # In Unix, wildcards are permitted because they are expanded by the shell.

        for file in self.arg_module.argv[1:]:
            if os.path.isfile(file):
                self.interface3_FN_factory(
                    os.path.abspath(file),
                    error_message="File name not accepted")
            else:
                A = url_support.potential_url_request(file)
                if file == "data_in_object":
                    VF = FileName("cxi_data", "present_image_0000001")
                    VF.number = 1
                    VF.template = "present_image_#######"
                    VF.fileroot = "present_image"
                    self.FN.append(VF)
                elif A.is_url_request():
                    VF = self.interface3_FN_factory(
                        A.file, error_message="URL %s not accepted" % file)
                    VF.full_url = A.text
                else:
                    raise Exception("File not found: %s" % file)
Esempio n. 2
0
def ImageFactory(filename, optional_index=None):
    from iotbx.detectors import url_support
    from libtbx.utils import Sorry
    if os.path.isfile(filename):
        if not os.access(filename, os.R_OK):
            raise Sorry("No read access to file %s" % filename)
        import dxtbx.format.Registry
        format_instance = dxtbx.format.Registry.get_format_class_for_file(
            filename)
        instance = format_instance(filename)
        if optional_index is not None:
            return instance.get_detectorbase(optional_index)
        return instance.get_detectorbase()
    A = url_support.potential_url_request(filename)
    if A.is_url_request():
        for utype in all_url_types:
            try:
                I = utype(filename)
                I.readHeader()
                return I
            except Exception:
                pass
        raise ImageException(filename +
                             " does not work as a functioning image URL")
    raise ImageException(filename +
                         " not recognized as any known detector image type")
Esempio n. 3
0
def ImageFactory(filename):
  from iotbx.detectors import url_support
  from libtbx.utils import Sorry
  if os.path.isfile(filename):
    if not os.access(filename, os.R_OK):
      raise Sorry("No read access to file %s" % filename)
    from dxtbx.format.Registry import Registry
    format_instance = Registry.find(filename)
    instance = format_instance(filename)
    return instance.get_detectorbase()
  A = url_support.potential_url_request(filename)
  if A.is_url_request():
    for utype in all_url_types:
      try:
        I = utype(filename)
        I.readHeader()
        return I
      except Exception:
        pass
    raise ImageException(filename+" does not work as a functioning image URL")
  raise ImageException(filename+" not recognized as any known detector image type")
Esempio n. 4
0
  def interface3_parse_command(self):
    #The assumption is that there will be one or two regular files specified
    # on command line that are valid image file names
    # If there are two, root and ext must be the same in each case.
    # In Unix, wildcards are permitted because they are expanded by the shell.

    for file in self.arg_module.argv[1:]:
      if os.path.isfile(file):
        self.interface3_FN_factory(os.path.abspath(file),error_message="File name not accepted")
      else:
        A = url_support.potential_url_request(file)
        if file=="data_in_object":
          VF = FileName("cxi_data","present_image_0000001")
          VF.number = 1
          VF.template = "present_image_#######"
          VF.fileroot = "present_image"
          self.FN.append(VF)
        elif A.is_url_request():
          VF = self.interface3_FN_factory(A.file,error_message="URL %s not accepted"%file)
          VF.full_url = A.text
        else:
          raise Exception("File not found: %s"%file)