Пример #1
0
        else:
            log.error(
                "Unable to locate device %s using SANE backend hpaio:. Please check HPLIP installation."
                % device_uri)
            sys.exit(1)

        log.info(log.bold("Using device %s" % device_uri))
        log.info("Opening connection to device...")

        try:
            device = sane.openDevice(device_uri)
        except scanext.error, e:
            sane.reportError(e)
            sys.exit(1)

        tlx = device.getOptionObj('tl-x').limitAndSet(tlx)
        tly = device.getOptionObj('tl-y').limitAndSet(tly)
        brx = device.getOptionObj('br-x').limitAndSet(brx)
        bry = device.getOptionObj('br-y').limitAndSet(bry)

        scan_area = (brx - tlx) * (bry - tly)  # mm^2
        scan_px = scan_area * res * res / 645.16  # res is in DPI

        valid_res = device.getOptionObj('resolution').constraint
        log.debug("Device supported resolutions %s" % valid_res)
        if res not in valid_res:
            log.warn(
                "Invalid resolution. Using closest valid resolution of %d dpi"
                % res)
            log.warn("Valid resolutions are %s dpi." %
                     ', '.join([str(x) for x in valid_res]))
Пример #2
0
            if d == device_uri:
                break
        else:
            log.error("Unable to locate device %s using SANE backend hpaio:. Please check HPLIP installation." % device_uri)
            sys.exit(1)

        log.info(log.bold("Using device %s" % device_uri))
        log.info("Opening connection to device...")

        try:
            device = sane.openDevice(device_uri)
        except scanext.error, e:
            sane.reportError(e)
            sys.exit(1)

        tlx = device.getOptionObj('tl-x').limitAndSet(tlx)
        tly = device.getOptionObj('tl-y').limitAndSet(tly)
        brx = device.getOptionObj('br-x').limitAndSet(brx)
        bry = device.getOptionObj('br-y').limitAndSet(bry)

        scan_area = (brx - tlx) * (bry - tly) # mm^2
        scan_px = scan_area * res * res / 645.16 # res is in DPI
        
        valid_res = device.getOptionObj('resolution').constraint
        log.debug("Device supported resolutions %s" % (valid_res,))
        if 0 in valid_res: #min-max range in tuple
           if res < valid_res[0] or res > valid_res[1]:
             log.warn("Invalid resolution. Using closest valid resolution of %d dpi" % res)
           if res < valid_res[0]:
              res = valid_res[0]
           elif res > valid_res[1]:
Пример #3
0
                break
        else:
            log.error("Unable to locate device %s using SANE backend hpaio:. Please check HPLIP installation." % device_uri)
            sys.exit(1)

        log.info(log.bold("Using device %s" % device_uri))
        log.info("Opening connection to device...")

        try:
            device = sane.openDevice(device_uri)
        except scanext.error, e:
            sane.reportError(e)
            sys.exit(1)

        try:
            source_option = device.getOptionObj("source").constraint
            log.debug("Supported source Options: %s size=%d" % (source_option,len(source_option)))
            if source_option is None:
                log.error("Device doesn't have scanner.")
                sys.exit(1)
        except:
            log.error("Failed to get the source from device.")

        #check if device has only ADF
        if len(source_option) == 1 and 'ADF' in source_option:
             log.debug("Device has only ADF support")
             adf = True

        if adf:
            try:
                if 'ADF' not in source_option:
Пример #4
0
                break
        else:
            log.error("Unable to locate device %s using SANE backend hpaio:. Please check HPLIP installation." % device_uri)
            sys.exit(1)

        log.info(log.bold("Using device %s" % device_uri))
        log.info("Opening connection to device...")

        try:
            device = sane.openDevice(device_uri)
        except scanext.error as e:
            sane.reportError(e.args[0])
            sys.exit(1)

        try:
            source_option = device.getOptionObj("source").constraint
            log.debug("Supported source Options: %s size=%d" % (source_option,len(source_option)))
            if source_option is None:
                log.error("Device doesn't have scanner.")
                sys.exit(1)
        except:
            log.error("Failed to get the source from device.")

        #check if device has only ADF
        if len(source_option) == 1 and 'ADF' in source_option:
             log.debug("Device has only ADF support")
             adf = True

        if adf:
            try:
                if 'ADF' not in source_option:
        else:
            log.error(
                "Unable to locate device %s using SANE backend hpaio:. Please check HPLIP installation."
                % device_uri)
            sys.exit(1)

        log.info(log.bold("Using device %s" % device_uri))
        log.info("Opening connection to device...")

        try:
            device = sane.openDevice(device_uri)
        except scanext.error, e:
            sane.reportError(e)
            sys.exit(1)

        tlx = device.getOptionObj('tl-x').limitAndSet(tlx)
        tly = device.getOptionObj('tl-y').limitAndSet(tly)
        brx = device.getOptionObj('br-x').limitAndSet(brx)
        bry = device.getOptionObj('br-y').limitAndSet(bry)

        scan_area = (brx - tlx) * (bry - tly)  # mm^2
        scan_px = scan_area * res * res / 645.16  # res is in DPI

        if scan_mode == 'color':
            scan_size = scan_px * 3  # 3 bytes/px
        else:
            scan_size = scan_px  # 1 byte/px

        if scan_size > 52428800:  # 50MB
            if res > 600:
                log.warn(