예제 #1
0
 def test_cancelled_scan(self):
     try:
         rawapi.sane_start(self.dev_handle)
     except StopIteration:
         self.skipTest("cannot scan, no document loaded")
     buf = rawapi.sane_read(self.dev_handle, 128*1024)
     self.assertTrue(len(buf) > 0)
     rawapi.sane_cancel(self.dev_handle)
예제 #2
0
 def test_cancelled_scan(self):
     try:
         rawapi.sane_start(self.dev_handle)
     except StopIteration:
         self.skipTest("cannot scan, no document loaded")
     buf = rawapi.sane_read(self.dev_handle, 128 * 1024)
     self.assertTrue(len(buf) > 0)
     rawapi.sane_cancel(self.dev_handle)
예제 #3
0
    def __init__(self, scanner):
        self.__scanner = scanner

        self.__is_scanning = True
        self.__raw_output = []
        self.__img = None

        self.__scanner._open()
        rawapi.sane_start(sane_dev_handle[1])
        try:
            self.__parameters = \
                    rawapi.sane_get_parameters(sane_dev_handle[1])
        except Exception:
            rawapi.sane_cancel(sane_dev_handle[1])
            raise
예제 #4
0
    def test_simple_scan(self):
        # XXX(Jflesch): set_io_mode() always return SANE_STATUS_UNSUPPORTED
        # with my scanner
        # rawapi.sane_set_io_mode(self.dev_handle, non_blocking=False)

        rawapi.sane_start(self.dev_handle)

        # XXX(Jflesch): get_select_fd() always return SANE_STATUS_UNSUPPORTED
        # with my scanner
        # fd = rawapi.sane_get_select_fd(self.dev_handle)
        # self.assertTrue(fd > 0)

        try:
            while True:
                buf = rawapi.sane_read(self.dev_handle, 128 * 1024)
                self.assertTrue(len(buf) > 0)
        except EOFError:
            pass
        rawapi.sane_cancel(self.dev_handle)
예제 #5
0
    def test_simple_scan(self):
        # XXX(Jflesch): set_io_mode() always return SANE_STATUS_UNSUPPORTED
        # with my scanner
        #rawapi.sane_set_io_mode(self.dev_handle, non_blocking=False)

        try:
            rawapi.sane_start(self.dev_handle)
        except StopIteration:
            self.skipTest("cannot scan, no document loaded")

        # XXX(Jflesch): get_select_fd() always return SANE_STATUS_UNSUPPORTED
        # with my scanner
        #fd = rawapi.sane_get_select_fd(self.dev_handle)
        #self.assertTrue(fd > 0)

        try:
            while True:
                buf = rawapi.sane_read(self.dev_handle, 128 * 1024)
                self.assertTrue(len(buf) > 0)
        except EOFError:
            pass
        rawapi.sane_cancel(self.dev_handle)
예제 #6
0
 def read(self):
     try:
         if not self.__is_scanning:
             rawapi.sane_start(sane_dev_handle[1])
             self.__is_scanning = True
             self.__must_clean = True
             self.__parameters = \
                     rawapi.sane_get_parameters(sane_dev_handle[1])
             return
         try:
             self.__raw_output.append(rawapi.sane_read(sane_dev_handle[1],
                                                       SANE_READ_BUFSIZE))
         except EOFError:
             raw = b''.join(self.__raw_output)
             self.__imgs.append(ImgUtil.raw_to_img(raw, self.__parameters))
             self.__is_scanning = False
             self.__raw_output = []
             raise
     except StopIteration:
         rawapi.sane_cancel(sane_dev_handle[1])
         self.__must_clean = False
         self.__is_scanning = False
         raise
예제 #7
0
 def test_cancelled_scan(self):
     rawapi.sane_start(self.dev_handle)
     buf = rawapi.sane_read(self.dev_handle, 128 * 1024)
     self.assertTrue(len(buf) > 0)
     rawapi.sane_cancel(self.dev_handle)