本文整理汇总了Python中ubuntui.ev.EventLoop.set_alarm_in方法的典型用法代码示例。如果您正苦于以下问题:Python EventLoop.set_alarm_in方法的具体用法?Python EventLoop.set_alarm_in怎么用?Python EventLoop.set_alarm_in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ubuntui.ev.EventLoop
的用法示例。
在下文中一共展示了EventLoop.set_alarm_in方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
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)
示例2: start
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
def start(self):
EventLoop.build_loop(self.common['ui'], STYLES,
unhandled_input=self.unhandled_input)
EventLoop.set_alarm_in(0.05, self._start)
EventLoop.run()
示例3: __refresh
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
def __refresh(self, *args):
self.view.refresh_nodes()
EventLoop.set_alarm_in(1, self.__refresh)
示例4: update
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
def update(self, *args, **kwargs):
self.pv.update()
EventLoop.set_alarm_in(1, self.update)
示例5: update
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
def update(self, *args):
for w in self.all_step_widgets:
w.update()
EventLoop.set_alarm_in(1, self.update)
示例6: __refresh
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
def __refresh(self, *args):
self.view.redraw_kitt()
self.alarm_handle = EventLoop.set_alarm_in(
1,
self.__refresh)
示例7: main
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
#.........这里部分代码省略.........
if not os.path.exists(global_config_filename):
# fallback to source tree location
global_config_filename = os.path.join(os.path.dirname(__file__),
"../etc/conjure-up.conf")
if not os.path.exists(global_config_filename):
utils.error("Could not find {}.".format(global_config_filename))
sys.exit(1)
with open(global_config_filename) as fp:
global_conf = yaml.safe_load(fp.read())
app.global_config = global_conf
spells_dir = app.argv.spells_dir
if not os.path.exists(spells_dir):
spells_dir = os.path.join(os.path.dirname(__file__),
"../spells")
app.config['spells-dir'] = spells_dir
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:
print("found spell {}".format(spells[0]))
utils.set_chosen_spell(spell_name,
os.path.join(opts.cache_dir,
spell_name))
download_local(os.path.join(app.config['spells-dir'],
spell_name),
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)
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()
if app.argv.status_only:
if not juju.model_available():
utils.error("Attempted to access the status screen without "
"an available Juju model.\n"
"Please select a model using 'juju switch' or "
"create a new controller using 'juju bootstrap'.")
sys.exit(1)
app.env = os.environ.copy()
app.env['CONJURE_UP_SPELL'] = spell_name
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()
示例8: main
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
#.........这里部分代码省略.........
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()
示例9: enqueue_search
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
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)
示例10: update
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
def update(self, *args):
self.update_now()
self.alarm = EventLoop.set_alarm_in(1, self.update)
示例11: __refresh
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
def __refresh(*args):
this.view.refresh_nodes()
EventLoop.set_alarm_in(1, __refresh)
示例12: main
# 需要导入模块: from ubuntui.ev import EventLoop [as 别名]
# 或者: from ubuntui.ev.EventLoop import set_alarm_in [as 别名]
#.........这里部分代码省略.........
app.ui = ConjureUI()
if spell in global_conf['curated_spells']:
install_curated_spell(spell)
spell_dir = os.environ.get('XDG_CACHE_HOME', os.path.join(
os.path.expanduser('~'),
'.cache/conjure-up'))
if app.fetcher == "charmstore-search":
app.bundles = load_charmstore_results(spell, global_conf['blessed'])
app.config = {'metadata': None,
'spell-dir': spell_dir,
'spell': spell}
# Set a general description of spell
definition = None
if path.isfile('/usr/share/conjure-up/keyword-definitions.yaml'):
with open('/usr/share/conjure-up/keyword-definitions.yaml') as fp:
definitions = yaml.safe_load(fp.read())
definition = definitions.get(spell, None)
if definition is None:
try:
definition = next(
bundle['Meta']['bundle-metadata']['Description']
for bundle in app.bundles if 'Description'
in bundle['Meta']['bundle-metadata'])
except StopIteration:
app.log.error("Could not find a suitable description "
"for spell: {}".format(spell))
if definition is not None:
app.config['description'] = definition
else:
utils.warning(
"Failed to find a description for spell: {}, "
"and is a bug that should be filed.".format(spell))
else:
# Check cache dir for spells
spell_dir = path.join(spell_dir, spell)
metadata_path = path.join(spell_dir,
'conjure/metadata.json')
remote = get_remote_url(opts.spell)
purge_top_level = True
if remote is not None:
if app.fetcher == "charmstore-search" or \
app.fetcher == "charmstore-direct":
purge_top_level = False
download(remote, spell_dir, purge_top_level)
else:
utils.warning("Could not find spell: {}".format(spell))
sys.exit(1)
with open(metadata_path) as fp:
metadata = json.load(fp)
app.config = {'metadata': metadata,
'spell-dir': spell_dir,
'spell': spell}
# Need to provide app.bundles dictionary even for single
# spells in the GUI
app.bundles = [
{
'Meta': {
'extra-info/conjure': metadata
}
}
]
if hasattr(app.argv, 'cloud'):
if app.fetcher != "charmstore-search":
app.headless = True
app.ui = None
else:
utils.error("Unable run a keyword search in headless mode, "
"please provide a single bundle path.")
sys.exit(1)
app.env = os.environ.copy()
app.env['CONJURE_UP_SPELL'] = spell
if app.argv.status_only:
if not juju.available():
utils.error("Attempted to access the status screen of "
"a non-bootstrapped Juju environment. "
"Please bootstrap an environment first.")
sys.exit(1)
if app.headless:
app.env['CONJURE_UP_HEADLESS'] = "1"
_start()
else:
EventLoop.build_loop(app.ui, STYLES,
unhandled_input=unhandled_input)
EventLoop.set_alarm_in(0.05, _start)
EventLoop.run()