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")
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")
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")
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")
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")
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,))
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,))
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")
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, ))
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 run -- calling handler.") _first_time_handler(callback) return eventloop.add_urgent_call(check_movies_gone, "check movies gone")
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")
def workspaceDidWake_(self, notification): def restartPausedDownloaders(self=self): dlCount = len(self.pausedDownloaders) if dlCount > 0: logging.debug("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")
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,))
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]
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})
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})
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]
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")
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")
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")
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")
def check_movies_gone(): """Checks to see if the movies directory is gone. """ # callback is what the frontend will call if the user asks us to continue callback = lambda: eventloop.add_urgent_call(fix_movies_gone, "fix movies gone") 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) 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. _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 # make sure that the directory is populated if we've downloaded stuff to # it if is_movies_directory_gone(): logging.info("Movies directory is gone -- calling handler.") _movies_directory_gone_handler(callback) return eventloop.add_urgent_call(finish_backend_startup, "reconnect downloaders")
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)
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.debug("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)
def fix_movies_gone(): app.config.set(prefs.MOVIES_DIRECTORY, platformcfg.get(prefs.MOVIES_DIRECTORY)) eventloop.add_urgent_call(finish_backend_startup, "reconnect downloaders")
def fix_movies_gone(): app.config.set(prefs.MOVIES_DIRECTORY, platformcfg.get(prefs.MOVIES_DIRECTORY)) eventloop.add_urgent_call(finish_backend_startup, "reconnect downloaders")
# 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() itemsource.setup_handlers() downloader.init_controller() # Call this late, after the message handlers have been installed. app.sharing_tracker = sharing.SharingTracker() app.sharing_manager = sharing.SharingManager() app.transcode_manager = transcode.TranscodeManager() 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")
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")
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")
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)