Exemplo n.º 1
0
                            break

                    if expected_bytes > 0:
                        if adf:
                            log.info(
                                "Expecting to read %s from scanner (per page)."
                                % utils.format_bytes(expected_bytes))
                        else:
                            log.info("Expecting to read %s from scanner." %
                                     utils.format_bytes(expected_bytes))

                    device.waitForScanActive()

                    pm = tui.ProgressMeter("Reading data:")

                    while device.isScanActive():
                        while update_queue.qsize():
                            try:
                                status, bytes_read = update_queue.get(0)

                                if not log.is_debug():
                                    if expected_bytes > 0:
                                        pm.update(
                                            int(100 * bytes_read /
                                                expected_bytes),
                                            utils.format_bytes(bytes_read))
                                    else:
                                        pm.update(
                                            0, utils.format_bytes(bytes_read))

                                if status != scanext.SANE_STATUS_GOOD:
Exemplo n.º 2
0
                        else:
                            log.info("Out of documents. Scanned %d pages total." % (page-1))
                            no_docs = True
                            break

                    if expected_bytes > 0:
                        if adf:
                            log.info("Expecting to read %s from scanner (per page)." % utils.format_bytes(expected_bytes))
                        else:
                            log.info("Expecting to read %s from scanner." % utils.format_bytes(expected_bytes))

                    device.waitForScanActive()

                    pm = tui.ProgressMeter("Reading data:")

                    while device.isScanActive():
                        while update_queue.qsize():
                            try:
                                status, bytes_read = update_queue.get(0)

                                if not log.is_debug():
                                    if expected_bytes > 0:
                                        pm.update(int(100*bytes_read/expected_bytes),
                                            utils.format_bytes(bytes_read))
                                    else:
                                        pm.update(0,
                                            utils.format_bytes(bytes_read))

                                if status != scanext.SANE_STATUS_GOOD:
                                    log.error("Error in reading data. Status=%d bytes_read=%d." % (status, bytes_read))
                                    sys.exit(1)