Beispiel #1
0
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")
Beispiel #2
0
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")
Beispiel #3
0
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")
Beispiel #4
0
    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")
Beispiel #5
0
    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")
Beispiel #6
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.
    """
    eventloop.add_urgent_call(_startup_checker.fix_movies_gone,
                              "fix movies gone",
                              args=(new_movies_directory,))
Beispiel #7
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.
    """
    eventloop.add_urgent_call(_startup_checker.fix_movies_gone,
                              "fix movies gone",
                              args=(new_movies_directory,))
Beispiel #8
0
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")
Beispiel #9
0
 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, ))
Beispiel #10
0
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")
Beispiel #11
0
 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")
Beispiel #12
0
 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")
Beispiel #13
0
 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,))
Beispiel #14
0
 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]
Beispiel #15
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})
Beispiel #16
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})
Beispiel #17
0
    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]
Beispiel #18
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")
Beispiel #19
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")
Beispiel #20
0
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")
Beispiel #21
0
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")
Beispiel #22
0
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")
Beispiel #23
0
 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)
Beispiel #24
0
 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)
Beispiel #25
0
def fix_movies_gone():
    app.config.set(prefs.MOVIES_DIRECTORY,
                   platformcfg.get(prefs.MOVIES_DIRECTORY))
    eventloop.add_urgent_call(finish_backend_startup, "reconnect downloaders")
Beispiel #26
0
def fix_movies_gone():
    app.config.set(prefs.MOVIES_DIRECTORY, platformcfg.get(prefs.MOVIES_DIRECTORY))
    eventloop.add_urgent_call(finish_backend_startup, "reconnect downloaders")
Beispiel #27
0
    # 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")
Beispiel #28
0
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")
Beispiel #29
0
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")
Beispiel #30
0
    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)