当前位置: 首页>>代码示例>>Python>>正文


Python ev.EventLoop类代码示例

本文整理汇总了Python中ubuntui.ev.EventLoop的典型用法代码示例。如果您正苦于以下问题:Python EventLoop类的具体用法?Python EventLoop怎么用?Python EventLoop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EventLoop类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: finish

    def finish(self, step_model, step_widget, done=False):
        """ handles processing step with input data

        Arguments:
        step_model: step_model returned from widget
        done: if True continues on to the summary view
        """
        if done:
            EventLoop.remove_alarms()
            return controllers.use('summary').render(self.results)

        # Set next button focus here now that the step is complete.
        self.view.steps.popleft()
        if len(self.view.steps) > 0:
            next_step = self.view.steps[0]
            next_step.generate_additional_input()
            self.view.step_pile.focus_position = self.view.step_pile.focus_position + 1  # noqa
        else:
            app.log.debug(
                "End of step list setting the view "
                "summary button in focus.")
            index = self.view.current_summary_button_index
            app.log.debug("Next focused button: {}".format(index))
            self.view.step_pile.focus_position = index

        future = async.submit(partial(common.do_step,
                                      step_model,
                                      step_widget,
                                      app.ui.set_footer,
                                      gui=True),
                              partial(self.__handle_exception, 'E002'))
        future.add_done_callback(self.get_result)
开发者ID:graywen24,项目名称:conjure-up,代码行数:32,代码来源:gui.py

示例2: main

def main():
    opts = parse_options(sys.argv[1:])

    config = Config('bundle-placer', opts.__dict__)
    config.save()

    setup_logger(cfg_path=config.cfg_path)
    log = logging.getLogger('bundleplacer')
    log.debug(opts.__dict__)

    log.info("Editing file: {}".format(opts.bundle_filename))

    if opts.maas_ip and opts.maas_cred:
        creds = dict(api_host=opts.maas_ip,
                     api_key=opts.maas_cred)
        maas, maas_state = connect_to_maas(creds)
    else:
        maas_state = FakeMaasState()

    placement_controller = PlacementController(config=config,
                                               maas_state=maas_state)

    mainview = PlacerView(placement_controller, config)
    ui = PlacerUI(mainview)

    def unhandled_input(key):
        if key in ['q', 'Q']:
            raise urwid.ExitMainLoop()
    EventLoop.build_loop(ui, STYLES, unhandled_input=unhandled_input)
    mainview.loop = EventLoop.loop
    mainview.update()
    EventLoop.run()
开发者ID:mikemccracken,项目名称:bundle-placement,代码行数:32,代码来源:cli.py

示例3: main

def main():
    with open(maas_data) as fp:
        maas_machines = json.load(fp)
    machine_view = maas_machines
    ui = MachineUI(machine_view)
    EventLoop.build_loop(ui, STYLES, unhandled_input=unhandled_input)
    EventLoop.run()
开发者ID:Ubuntu-Solutions-Engineering,项目名称:urwid-ubuntu,代码行数:7,代码来源:viewer-maas.py

示例4: update

 def update(self, *args, **kwargs):
     if self.pv is None:
         self.pv = PlacementView(
             display_controller=self,
             placement_controller=self.placement_controller,
             config=self.config,
             do_deploy_cb=self.done_cb)
         self.set_header(
             title="Bundle Editor"
         )
         self.set_body(self.pv)
     self.pv.update()
     EventLoop.set_alarm_in(1, self.update)
开发者ID:battlemidget,项目名称:bundle-placement,代码行数:13,代码来源:placerview.py

示例5: __handle_bootstrap_done

    def __handle_bootstrap_done(self, future):
        app.log.debug("handle bootstrap")
        result = future.result()
        if result.returncode < 0:
            # bootstrap killed via user signal, we're quitting
            return
        if result.returncode > 0:
            err = result.stderr.read().decode()
            app.log.error(err)
            return self.__handle_exception(Exception("error "))

        utils.pollinate(app.session_id, 'J004')
        EventLoop.remove_alarms()
        app.ui.set_footer('Bootstrap complete...')
        self.__post_bootstrap_exec()
开发者ID:battlemidget,项目名称:conjure-up,代码行数:15,代码来源:gui.py

示例6: do_commit

    def do_commit(self, sender):
        """Commit changes to shadow assignments, constraints, and pins"""
        app.metadata_controller.bundle.machines = self._machines

        self.controller.clear_assignments(self.application)
        for juju_machine_id, al in self.shadow_assignments.items():
            for application, atype in al:
                assert application == self.application
                self.controller.add_assignment(self.application,
                                               juju_machine_id, atype)

        for j_m_id, m in self.shadow_pins.items():
            self.controller.set_machine_pin(j_m_id, m)

        self.controller.handle_sub_view_done()
        if self.alarm:
            EventLoop.remove_alarm(self.alarm)
开发者ID:conjure-up,项目名称:conjure-up,代码行数:17,代码来源:app_architecture_view.py

示例7: finish

    def finish(self, needs_lxd_setup=False, lxdnetwork=None, back=False):
        """ Processes the new LXD setup and loads the controller to
        finish bootstrapping the model.

        Arguments:
        back: if true loads previous controller
        needs_lxd_setup: if true prompt user to run lxd init
        """
        if back:
            return controllers.use('clouds').render()

        if needs_lxd_setup:
            EventLoop.remove_alarms()
            EventLoop.exit(1)

        if lxdnetwork is None:
            return app.ui.show_exception_message(
                Exception("Unable to configure LXD network bridge."))

        formatted_network = self.__format_input(lxdnetwork)
        app.log.debug("LXD Config {}".format(formatted_network))

        out = self.__format_conf(formatted_network)

        with NamedTemporaryFile(mode="w", encoding="utf-8",
                                delete=False) as tempf:
            app.log.debug("Saving LXD config to {}".format(tempf.name))
            utils.spew(tempf.name, out)
            sh = utils.run('sudo mv {} /etc/default/lxd-bridge'.format(
                tempf.name), shell=True)
            if sh.returncode > 0:
                return app.ui.show_exception_message(
                    Exception("Problem saving config: {}".format(
                        sh.stderr.decode('utf8'))))

        app.log.debug("Restarting lxd-bridge")
        utils.run("sudo systemctl restart lxd-bridge.service", shell=True)

        utils.pollinate(app.session_id, 'L002')
        controllers.use('newcloud').render(
            cloud='localhost', bootstrap=True)
开发者ID:battlemidget,项目名称:conjure-up,代码行数:41,代码来源:gui.py

示例8: keypress

 def keypress(self, size, key):
     rv = super().keypress(size, key)
     if key in ["tab", "shift tab"]:
         self._swap_focus()
     self.handle_focus_changed()
     if key in ["r"] and self.selected_spell_w is not None:
         _, rows = EventLoop.screen_size()
         cur_spell = self.selected_spell_w.spell
         spellname = cur_spell["name"]
         spelldir = cur_spell["spell-dir"]
         brmv = BundleReadmeView(
             self.app.metadata_controller, spellname, spelldir, self.handle_readme_done, int(rows * 0.75)
         )
         self.app.ui.set_header("Spell Readme")
         self.app.ui.set_body(brmv)
     return rv
开发者ID:conjure-up,项目名称:conjure-up,代码行数:16,代码来源:spellpicker.py

示例9: update

 def update(self, *args, **kwargs):
     self.pv.update()
     EventLoop.set_alarm_in(1, self.update)
开发者ID:Ubuntu-Solutions-Engineering,项目名称:bundle-placement,代码行数:3,代码来源:placerview.py

示例10: update

 def update(self, *args):
     for w in self.all_step_widgets:
         w.update()
     EventLoop.set_alarm_in(1, self.update)
开发者ID:graywen24,项目名称:conjure-up,代码行数:4,代码来源:gui.py

示例11: main

def main():
    with open(juju_data) as fp:
        juju_state = json.load(fp)
    ui = ServiceUI(juju_state)
    EventLoop.build_loop(ui, STYLES, unhandled_input=unhandled_input)
    EventLoop.run()
开发者ID:Ubuntu-Solutions-Engineering,项目名称:urwid-ubuntu,代码行数:6,代码来源:viewer-juju.py

示例12: finish

 def finish(self, *args):
     if self.alarm_handle:
         EventLoop.remove_alarm(self.alarm_handle)
     return controllers.use('deploystatus').render()
开发者ID:conjure-up,项目名称:conjure-up,代码行数:4,代码来源:gui.py

示例13: enqueue_search

 def enqueue_search(self):
     if self.search_delay_alarm:
         EventLoop.remove_alarm(self.search_delay_alarm)
     self.search_delay_alarm = EventLoop.set_alarm_in(0.5,
                                                      self.really_search)
开发者ID:Ubuntu-Solutions-Engineering,项目名称:bundle-placement,代码行数:5,代码来源:charmstore.py

示例14: unhandled_input

 def unhandled_input(self, key):
     if key in ['q', 'Q']:
         EventLoop.exit(0)
开发者ID:pombredanne,项目名称:conjure,代码行数:3,代码来源:app.py

示例15: main


#.........这里部分代码省略.........
            spells_dir, branch=spells_registry_branch)
    else:
        app.log.debug("Refreshing spell registry")
        download_or_sync_registry(
            app.global_config['registry']['repo'],
            spells_dir, update=True, branch=spells_registry_branch)

    spells_index_path = os.path.join(app.config['spells-dir'],
                                     'spells-index.yaml')
    with open(spells_index_path) as fp:
        app.spells_index = yaml.safe_load(fp.read())

    spell_name = spell
    app.endpoint_type = detect_endpoint(opts.spell)

    if app.endpoint_type == EndpointType.LOCAL_SEARCH:
        spells = utils.find_spells_matching(opts.spell)

        if len(spells) == 0:
            utils.error("Can't find a spell matching '{}'".format(opts.spell))
            sys.exit(1)

        # One result means it was a direct match and we can copy it
        # now. Changing the endpoint type then stops us from showing
        # the picker UI. More than one result means we need to show
        # the picker UI and will defer the copy to
        # SpellPickerController.finish(), so nothing to do here.
        if len(spells) == 1:
            app.log.debug("found spell {}".format(spells[0]))
            spell = spells[0]
            utils.set_chosen_spell(spell_name,
                                   os.path.join(opts.cache_dir,
                                                spell['key']))
            download_local(os.path.join(app.config['spells-dir'],
                                        spell['key']),
                           app.config['spell-dir'])
            utils.set_spell_metadata()
            app.endpoint_type = EndpointType.LOCAL_DIR

    # download spell if necessary
    elif app.endpoint_type == EndpointType.LOCAL_DIR:
        if not os.path.isdir(opts.spell):
            utils.warning("Could not find spell {}".format(opts.spell))
            sys.exit(1)

        if not os.path.exists(os.path.join(opts.spell,
                                           "metadata.yaml")):
            utils.warning("'{}' does not appear to be a spell. "
                          "{}/metadata.yaml was not found.".format(
                              opts.spell, opts.spell))
            sys.exit(1)

        spell_name = os.path.basename(os.path.abspath(spell))
        utils.set_chosen_spell(spell_name,
                               path.join(opts.cache_dir, spell_name))
        download_local(opts.spell, app.config['spell-dir'])
        utils.set_spell_metadata()

    elif app.endpoint_type in [EndpointType.VCS, EndpointType.HTTP]:

        utils.set_chosen_spell(spell, path.join(opts.cache_dir, spell))
        remote = get_remote_url(opts.spell)

        if remote is None:
            utils.warning("Can't guess URL matching '{}'".format(opts.spell))
            sys.exit(1)

        download(remote, app.config['spell-dir'], True)
        utils.set_spell_metadata()

    app.env = os.environ.copy()
    app.env['CONJURE_UP_CACHEDIR'] = app.argv.cache_dir
    app.env['CONJURE_UP_SPELL'] = spell_name

    if app.argv.show_env:
        if not app.argv.cloud:
            utils.error("You must specify a cloud for headless mode.")
            sys.exit(1)
        if app.endpoint_type in [None, EndpointType.LOCAL_SEARCH]:
            utils.error("Please specify a spell for headless mode.")
            sys.exit(1)

        show_env()

    if app.argv.cloud:
        if app.endpoint_type in [None, EndpointType.LOCAL_SEARCH]:
            utils.error("Please specify a spell for headless mode.")
            sys.exit(1)

        app.headless = True
        app.ui = None
        app.env['CONJURE_UP_HEADLESS'] = "1"
        _start()

    else:
        app.ui = ConjureUI()
        EventLoop.build_loop(app.ui, STYLES,
                             unhandled_input=unhandled_input)
        EventLoop.set_alarm_in(0.05, _start)
        EventLoop.run()
开发者ID:conjure-up,项目名称:conjure-up,代码行数:101,代码来源:app.py


注:本文中的ubuntui.ev.EventLoop类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。