本文整理匯總了Python中spreads.workflow.Workflow.capture方法的典型用法代碼示例。如果您正苦於以下問題:Python Workflow.capture方法的具體用法?Python Workflow.capture怎麽用?Python Workflow.capture使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類spreads.workflow.Workflow
的用法示例。
在下文中一共展示了Workflow.capture方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: capture
# 需要導入模塊: from spreads.workflow import Workflow [as 別名]
# 或者: from spreads.workflow.Workflow import capture [as 別名]
def capture(config):
path = config['path'].get()
workflow = Workflow(config=config, path=path)
if len(workflow.devices) != 2:
raise DeviceException("Please connect and turn on two"
" pre-configured devices! ({0} were"
" found)".format(len(workflow.devices)))
print(colorize("Found {0} devices!".format(len(workflow.devices)),
colorama.Fore.GREEN))
if any(not x.target_page for x in workflow.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()
# Start capture loop
shot_count = 0
pages_per_hour = 0
capture_keys = workflow.config['capture']['capture_keys'].as_str_seq()
print("({0}) capture | (r) retake last shot | (f) finish "
.format("/".join(capture_keys)))
while True:
retake = False
char = getch().lower()
if char == 'f':
break
elif char == 'r':
retake = True
elif char not in capture_keys:
continue
workflow.capture(retake=retake)
shot_count += len(workflow.devices)
pages_per_hour = (3600/(time.time() -
workflow.capture_start))*shot_count
status = ("\rShot {0: >3} pages [{1: >4.0f}/h] "
.format(unicode(shot_count), pages_per_hour))
sys.stdout.write(status)
sys.stdout.flush()
workflow.finish_capture()
if workflow.capture_start is None:
return
sys.stdout.write("\rShot {0} pages in {1:.1f} minutes, average speed was"
" {2:.0f} pages per hour\n"
.format(colorize(str(shot_count), colorama.Fore.GREEN),
(time.time() - workflow.capture_start)/60,
pages_per_hour))
sys.stdout.flush()