コード例 #1
0
ファイル: cli.py プロジェクト: Gunirus/spreads
def main():
    # Set to ERROR so we can see errors during plugin loading.
    logging.basicConfig(loglevel=logging.ERROR)

    # Lazy-load configuration
    config = confit.LazyConfig('spreads', __name__)
    config.read()
    setup_plugin_config(config)

    parser = setup_parser(config)
    args = parser.parse_args()
    # Set configuration from parsed arguments
    set_config_from_args(config, args)

    loglevel = config['loglevel'].as_choice({
        'none':     logging.NOTSET,
        'info':     logging.INFO,
        'debug':    logging.DEBUG,
        'warning':  logging.WARNING,
        'error':    logging.ERROR,
        'critical': logging.CRITICAL,
    })

    # Set up logger
    logger = logging.getLogger()
    if logger.handlers:
        for handler in logger.handlers:
            logger.removeHandler(handler)
    handler = ColourStreamHandler()
    handler.setLevel(loglevel)
    handler.setFormatter(logging.Formatter("%(name)s: %(message)s"))
    logger.addHandler(handler)
    logger.setLevel(logging.INFO)

    args.subcommand(config)
コード例 #2
0
ファイル: cli.py プロジェクト: Gunirus/spreads
def configure(config):
    config["driver"] = _select_driver()
    config["plugins"] = _select_plugins(config["plugins"].get())

    setup_plugin_config(config)
    _setup_processing_pipeline(config)

    cfg_path = os.path.join(config.config_dir(), confit.CONFIG_FILENAME)
    setup_plugin_config(config)

    driver = get_driver(config["driver"].get()).driver

    # We only need to set the device target_page if the driver supports
    # shooting with two devices
    if DeviceFeatures.IS_CAMERA in driver.features:
        answer = raw_input(
            "Do you want to configure the target_page of your devices?\n"
            "(Required for shooting with two devices) [y/n]: ")
        answer = True if answer.lower() == 'y' else False
        if answer:
            print("Setting target page on cameras")
            for target_page in ('odd', 'even'):
                _set_device_target_page(config, target_page)

        answer = raw_input("Do you want to setup the focus for your cameras? "
                           "[y/n]: ")
        answer = True if answer.lower() == 'y' else False
        if answer:
            print("Please turn on one of your capture devices.\n"
                  "Press any key to continue")
            getch()
            devs = get_devices(config)
            print("Please put a book with as little whitespace as possible"
                  "under your cameras.\nPress any button to continue")
            getch()
            focus = devs[0]._acquire_focus()
            config['device']['focus_distance'] = focus
    print("Writing configuration file to '{0}'".format(cfg_path))
    config.dump(filename=cfg_path)
コード例 #3
0
ファイル: gui_test.py プロジェクト: Gunirus/spreads
    def setUp(self):
        try:
            self.app = QApplication([])
        except RuntimeError:
            # TODO: Somehow our app gets created multiple times, so we just
            #       ignore that here...
            pass
        self.config = confit.Configuration('test_gui')
        self.config['plugins'] = [u'tesseract', u'scantailor']
        self.config['driver'] = u'dummy'
        self.workflow = workflow.Workflow(config=self.config,
                                          path='/tmp/foobar')
        plugin.setup_plugin_config(self.config)

        tess.AVAILABLE_LANGS = ["en"]
        # TODO: Cams ought to be 'odd' and 'even'!
        self.cams = [Mock(), Mock()]
        workflow.get_devices = Mock(return_value=self.cams)
        # Mock out message boxes
        gui.QtGui.QMessageBox = Mock()
        gui.QtGui.QMessageBox.exec_.return_value = True
        self.wizard = gui.SpreadsWizard(self.config)
        self.wizard.show()