def test_capture_noparallel(self): spreads.config['parallel_capture'] = False flow.capture(self.cams) # TODO: Find a way to verify that the cameras were indeed triggered # in sequence and not in parallel for cam in self.cams: assert cam.capture.call_count == 1
def trigger_loop(): is_posix = sys.platform != 'win32' old_count = len(workflow.pages) if is_posix: import select old_settings = termios.tcgetattr(sys.stdin) data_available = lambda: (select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], [])) read_char = lambda: sys.stdin.read(1) else: data_available = msvcrt.kbhit read_char = msvcrt.getch try: if is_posix: tty.setcbreak(sys.stdin.fileno()) while True: time.sleep(0.01) if len(workflow.pages) != old_count: old_count = len(workflow.pages) refresh_stats() if not data_available(): continue char = read_char() if char in tuple(capture_keys) + ('r', ): workflow.capture(retake=(char == 'r')) refresh_stats() elif char == 'f': break finally: if is_posix: termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings)
def test_capture(self): flow.capture(self.cams) for cam in self.cams: assert cam.capture.call_count == 1 for plug in self.plugins: assert plug.obj.capture.call_count == 1 assert plug.obj.capture.call_args_list == [call(self.cams)]
def test_capture_flip_target_pages(workflow): workflow.config['device']['parallel_capture'] = False workflow.config['device']['flip_target_pages'] = True workflow.prepare_capture() workflow.capture() # TODO: Verify workflow.finish_capture()
def test_capture_flip_target_pages(workflow): workflow.config["device"]["parallel_capture"] = False workflow.config["device"]["flip_target_pages"] = True workflow.prepare_capture() workflow.capture() # TODO: Verify workflow.finish_capture()
def _trigger_loop(): """ Waits for input on stdin and launches appropriate actions. """ is_posix = sys.platform != 'win32' old_count = len(workflow.pages) if is_posix: import select old_settings = termios.tcgetattr(sys.stdin) data_available = lambda: (select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], [])) read_char = lambda: sys.stdin.read(1) else: data_available = msvcrt.kbhit read_char = msvcrt.getch try: if is_posix: tty.setcbreak(sys.stdin.fileno()) while True: time.sleep(0.01) if len(workflow.pages) != old_count: old_count = len(workflow.pages) _refresh_stats() if not data_available(): continue char = read_char() if char in tuple(capture_keys) + ('r', ): # Capture or retake workflow.capture(retake=(char == 'r')) _refresh_stats() elif char == 'f': # Finish capturing break finally: if is_posix: termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings)
def test_capture(workflow): workflow.config['device']['parallel_capture'] = True workflow.config['device']['flip_target_pages'] = False for dev in workflow.devices: dev.delay = 0.25 workflow.capture() assert workflow.pages_shot == 2 assert (workflow.images[1].stat().st_ctime - workflow.images[0].stat().st_ctime) < 0.25
def test_capture_noparallel(workflow): workflow.config['device']['parallel_capture'] = False workflow.config['device']['flip_target_pages'] = False for dev in workflow.devices: dev.delay = 0.25 workflow.capture() assert workflow.pages_shot == 2 assert round(workflow.images[1].stat().st_ctime - workflow.images[0].stat().st_ctime, 2) >= 0.25
def test_capture_noparallel(workflow): workflow.config["device"]["parallel_capture"] = False workflow.config["device"]["flip_target_pages"] = False for dev in workflow.devices: dev.delay = 0.25 workflow.prepare_capture() workflow.capture() assert len(workflow.pages) == 2 assert round(workflow.pages[1].raw_image.stat().st_ctime - workflow.pages[0].raw_image.stat().st_ctime, 2) >= 0.25 workflow.finish_capture()
def test_capture(workflow): workflow.config['device']['parallel_capture'] = True workflow.config['device']['flip_target_pages'] = False for dev in workflow.devices: dev.delay = 1.0 # subsecond checks fails on some filesystems workflow.prepare_capture() workflow.capture() assert len(workflow.pages) == 2 assert (workflow.pages[1].raw_image.stat().st_ctime - workflow.pages[0].raw_image.stat().st_ctime) < 1.0 workflow.finish_capture()
def test_capture_noparallel(workflow): workflow.config['device']['parallel_capture'] = False workflow.config['device']['flip_target_pages'] = False for dev in workflow.devices: dev.delay = 0.25 workflow.prepare_capture() workflow.capture() assert len(workflow.pages) == 2 assert round(workflow.pages[1].raw_image.stat().st_ctime - workflow.pages[0].raw_image.stat().st_ctime, 2) >= 0.25 workflow.finish_capture()
def test_capture_noparallel(workflow): workflow.config['device']['parallel_capture'] = False workflow.config['device']['flip_target_pages'] = False for dev in workflow.devices: dev.delay = 1.0 # subsecond checks fails on some filesystems workflow.prepare_capture() workflow.capture() assert len(workflow.pages) == 2 assert round(workflow.pages[1].raw_image.stat().st_ctime - workflow.pages[0].raw_image.stat().st_ctime, 2) >= 1.0 workflow.finish_capture()
def _trigger_loop(): """ Waits for input on stdin and launches appropriate actions. """ is_posix = sys.platform != 'win32' old_count = len(workflow.pages) if is_posix: import select old_settings = termios.tcgetattr(sys.stdin) def data_available(): return (select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], [])) def read_char(): return sys.stdin.read(1) else: data_available = msvcrt.kbhit read_char = msvcrt.getch try: if is_posix: tty.setcbreak(sys.stdin.fileno()) while True: time.sleep(0.01) if len(workflow.pages) != old_count: old_count = len(workflow.pages) _refresh_stats() if not data_available(): continue char = read_char() if char in tuple(capture_keys) + ('r', ): # Capture or retake workflow.capture(retake=(char == 'r')) _refresh_stats() elif char == 'f': # Finish capturing break finally: if is_posix: termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings)
def capture(args=None, devices=None): if not devices: devices = get_devices() if len(devices) != 2: raise DeviceException("Please connect and turn on two" " pre-configured devices! ({0} were" " found)".format(len(devices))) print(colorama.Fore.GREEN + "Found {0} devices!".format(len(devices))) if any(not x.orientation for x in devices): raise DeviceException("At least one of the devices has not been" " properly configured, please re-run the" " program with the \'configure\' option!") # Set up for capturing print("Setting up devices for capturing.") workflow.prepare_capture(devices) # Start capture loop print(colorama.Fore.BLUE + "Press 'b' to capture.") shot_count = 0 start_time = time.time() pages_per_hour = 0 capture_keys = config['capture']['capture_keys'].as_str_seq() while True: if not getch().lower() in capture_keys: break workflow.capture(devices) shot_count += len(devices) pages_per_hour = (3600/(time.time() - start_time))*shot_count status = ("\rShot {0} pages [{1:.0f}/h]" .format(colorama.Fore.GREEN + unicode(shot_count), pages_per_hour)) sys.stdout.write(status) sys.stdout.flush() workflow.finish_capture(devices) sys.stdout.write("\rShot {0} pages in {1:.1f} minutes, average speed was" " {2:.0f} pages per hour" .format(colorama.Fore.GREEN + str(shot_count), (time.time() - start_time)/60, pages_per_hour)) sys.stdout.flush()
def test_capture_flip_target_pages(workflow): workflow.config['device']['parallel_capture'] = False workflow.config['device']['flip_target_pages'] = True workflow.capture()