本文整理汇总了Python中miro.eventloop.add_urgent_call函数的典型用法代码示例。如果您正苦于以下问题:Python add_urgent_call函数的具体用法?Python add_urgent_call怎么用?Python add_urgent_call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_urgent_call函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _movies_directory_gone_handler
def _movies_directory_gone_handler(callback):
"""Default _movies_directory_gone_handler. The frontend should
override this using the ``install_movies_directory_gone_handler``
function.
"""
logging.error("Movies directory is gone -- no handler installed!")
eventloop.add_urgent_call(callback, "continuing startup")
示例2: check_movies_gone
def check_movies_gone():
"""Checks to see if the movies directory is gone.
"""
callback = lambda: eventloop.add_urgent_call(fix_movies_gone,
"fix movies gone")
if is_movies_directory_gone():
logging.info("Movies directory is gone -- calling handler.")
_movies_directory_gone_handler(callback)
return
movies_dir = fileutil.expand_filename(app.config.get(prefs.MOVIES_DIRECTORY))
# if the directory doesn't exist, create it.
if not os.path.exists(movies_dir):
try:
os.makedirs(movies_dir)
except OSError:
logging.info("Movies directory can't be created -- calling handler")
# FIXME - this isn't technically correct, but it's probably
# close enough that a user can fix the issue and Miro can
# run happily.
_movies_directory_gone_handler(callback)
return
# make sure the directory is writeable
if not os.access(movies_dir, os.W_OK):
_movies_directory_gone_handler(callback)
return
eventloop.add_urgent_call(finish_backend_startup, "reconnect downloaders")
示例3: first_time_handler
def first_time_handler(callback):
"""Default handler for first-time startup
install_first_time_handler() replaces this method with the
frontend-specific one.
"""
logging.error("First time -- no handler installed.")
eventloop.add_urgent_call(callback, "continuing startup")
示例4: fix_movies_gone
def fix_movies_gone(new_movies_directory):
"""Called by the movies directory gone handler to fix the issue.
:param new_movies_directory: new path for the movies directory, or None if
we should continue with the current directory.
"""
eventloop.add_urgent_call(_startup_checker.fix_movies_gone,
"fix movies gone",
args=(new_movies_directory,))
示例5: check_firsttime
def check_firsttime():
"""Run the first time wizard if need be.
"""
callback = lambda: eventloop.add_urgent_call(check_movies_gone, "check movies gone")
if is_first_time():
logging.info("First time -- calling handler.")
_first_time_handler(callback)
return
eventloop.add_urgent_call(check_movies_gone, "check movies gone")
示例6: run_callback
def run_callback(self, choice):
"""Run the callback for this dialog. Choice should be the
button that the user clicked, or None if the user closed the
window without makeing a selection.
"""
self.choice = choice
self.event.set()
if self.callback is not None:
eventloop.add_urgent_call(self.callback,
"%s callback" % self.__class__,
args=(self,))
示例7: workspaceDidWake_
def workspaceDidWake_(self, notification):
def restartPausedDownloaders(self=self):
dlCount = len(self.pausedDownloaders)
if dlCount > 0:
logging.info("System is awake from sleep, resuming %s download(s)." % dlCount)
try:
for dl in self.pausedDownloaders:
dl.start()
finally:
self.pausedDownloaders = list()
eventloop.add_urgent_call(lambda:restartPausedDownloaders(), "Resuming downloaders after sleep")
示例8: decorated
def decorated(*args, **kwargs):
return_hack = []
event = threading.Event()
def runThenSet():
try:
return_hack.append(func(*args, **kwargs))
finally:
event.set()
eventloop.add_urgent_call(runThenSet, 'run in event loop')
event.wait()
if return_hack:
return return_hack[0]
示例9: fix_movies_gone
def fix_movies_gone(new_movies_directory):
"""Called by the movies directory gone handler to fix the issue.
:param new_movies_directory: new path for the movies directory, or None if
we should continue with the current directory.
"""
if new_movies_directory is not None:
app.config.set(prefs.MOVIES_DIRECTORY, new_movies_directory)
# do another check to make sure the selected directory works. Here we
# skip the unmounted check, since it's not exact and the user is giving us
# a directory.
eventloop.add_urgent_call(check_movies_gone, "check movies gone",
kwargs={'check_unmounted': False})
示例10: _movies_directory_gone_handler
def _movies_directory_gone_handler(message, movies_dir, allow_continue=False):
"""Default _movies_directory_gone_handler. The frontend should
override this using the ``install_movies_directory_gone_handler``
function.
_movies_directory_gone_handler should display the message to the user, and
present them with the following options:
- quit
- change movies directory
- continue with current directory (if allow_continue is True)
After the user picks, the frontend should call either
app.controller.shutdown() or startup.fix_movies_gone()
"""
logging.error("Movies directory is gone -- no handler installed!")
eventloop.add_urgent_call(callback, "continuing startup")
示例11: check_movies_gone
def check_movies_gone(check_unmounted=True):
"""Checks to see if the movies directory is gone.
"""
movies_dir = fileutil.expand_filename(app.config.get(
prefs.MOVIES_DIRECTORY))
movies_dir = filename_to_unicode(movies_dir)
# if the directory doesn't exist, create it.
if (not os.path.exists(movies_dir) and
should_create_movies_directory(movies_dir)):
try:
fileutil.makedirs(movies_dir)
except OSError:
logging.info("Movies directory can't be created -- calling handler")
# FIXME - this isn't technically correct, but it's probably
# close enough that a user can fix the issue and Miro can
# run happily.
msg = _("Permissions error: %(appname)s couldn't "
"create the folder.",
{"appname": app.config.get(prefs.SHORT_APP_NAME)})
_movies_directory_gone_handler(msg, movies_dir)
return
# make sure the directory is writeable
if not os.access(movies_dir, os.W_OK):
logging.info("Can't write to movies directory -- calling handler")
msg = _("Permissions error: %(appname)s can't "
"write to the folder.",
{"appname": app.config.get(prefs.SHORT_APP_NAME)})
_movies_directory_gone_handler(msg, movies_dir)
return
# make sure that the directory is populated if we've downloaded stuff to
# it
if check_unmounted and check_movies_directory_unmounted():
logging.info("Movies directory is gone -- calling handler.")
msg = _("The folder contains no files: "
"is it on a drive that's disconnected?")
_movies_directory_gone_handler(msg, movies_dir, allow_continue=True)
return
eventloop.add_urgent_call(finish_backend_startup, "reconnect downloaders")
示例12: workspaceWillSleep_
def workspaceWillSleep_(self, notification):
def pauseRunningDownloaders(self=self):
self.pausedDownloaders = list()
for dl in downloader.RemoteDownloader.make_view():
if dl.get_state() == 'downloading':
self.pausedDownloaders.append(dl)
dlCount = len(self.pausedDownloaders)
if dlCount > 0:
logging.info("System is going to sleep, suspending %d download(s)." % dlCount)
for dl in self.pausedDownloaders:
dl.pause()
dc = eventloop.add_urgent_call(lambda:pauseRunningDownloaders(), "Suspending downloaders for sleep")
# Until we can get proper delayed call completion notification, we're
# just going to wait a few seconds here :)
time.sleep(3)
示例13: fix_movies_gone
def fix_movies_gone():
app.config.set(prefs.MOVIES_DIRECTORY, platformcfg.get(prefs.MOVIES_DIRECTORY))
eventloop.add_urgent_call(finish_backend_startup, "reconnect downloaders")
示例14: _first_time_handler
def _first_time_handler(callback):
"""Default _first_time_handler. The frontend should override this
using the ``install_first_time_handler`` function.
"""
logging.error("First time -- no handler installed.")
eventloop.add_urgent_call(callback, "continuing startup")
示例15: setup_global_feeds
conversions.conversion_manager.startup()
app.device_manager = devices.DeviceManager()
app.device_tracker = devicetracker.DeviceTracker()
searchengines.create_engines()
setup_global_feeds()
# call fix_database_inconsistencies() ASAP after the manual feed is set up
fix_database_inconsistencies()
logging.info("setup tabs...")
setup_tabs()
logging.info("setup theme...")
setup_theme()
install_message_handler()
downloader.init_controller()
eventloop.add_urgent_call(check_firsttime, "check first time")
def fix_database_inconsistencies():
item.fix_non_container_parents()
item.move_orphaned_items()
playlist.fix_missing_item_ids()
folder.fix_playlist_missing_item_ids()
@startup_function
def check_firsttime():
"""Run the first time wizard if need be.
"""
callback = lambda: eventloop.add_urgent_call(check_movies_gone, "check movies gone")
if is_first_time():
logging.info("First time -- calling handler.")
_first_time_handler(callback)