Пример #1
0
    def __init__(self, stream_update, object_transfer):
        if stream_update is None:
            # Disable upcalls.
            request_feedback = False
        else:
            request_feedback = True

        PyWoodchuck.__init__(self, "Khweeteur", "net.khertan.khweeteur.daemon", request_feedback=request_feedback)

        self.stream_update = stream_update
        self.object_transfer = object_transfer
Пример #2
0
    def __init__(self, stream_update, object_transfer):
        if stream_update is None:
            # Disable upcalls.
            request_feedback = False
        else:
            request_feedback = True

        PyWoodchuck.__init__(self, "Khweeteur", "net.khertan.khweeteur.daemon",
                             request_feedback=request_feedback)

        self.stream_update = stream_update
        self.object_transfer = object_transfer
Пример #3
0
    def __init__(self, model, podcast_update, episode_download):
        if podcast_update is None and episode_download is None:
            # Disable upcalls.
            request_feedback = False
        else:
            request_feedback = True

        PyWoodchuck.__init__(self, "gPodder", "org.gpodder",
                             request_feedback=request_feedback)

        self.model = model
        self.podcast_update = podcast_update
        self.episode_download = episode_download
Пример #4
0
    def __init__(self, model, podcast_update, episode_download):
        if podcast_update is None and episode_download is None:
            # Disable upcalls.
            request_feedback = False
        else:
            request_feedback = True

        PyWoodchuck.__init__(self,
                             "gPodder",
                             "org.gpodder",
                             request_feedback=request_feedback)

        self.model = model
        self.podcast_update = podcast_update
        self.episode_download = episode_download
Пример #5
0
class mywoodchuck(PyWoodchuck):
    def __init__(self, human_readable_name, dbus_service_name,
                 request_feedback):
        # We need to claim the name before we register with Woodchuck.
        #
        # Consider: the reason we started is that Woodchuck might have
        # made an upcall.  The DBus daemon will only queue the message
        # for 25 seconds, after which point it will drop the message
        # on the floor.  Registering with Woodchuck means using DBus.
        # Indeed, it means making a blocking call to Woodchuck.  If
        # Woodchuck is currently running the scheduler (which it
        # likely is if it just made an upcall to us), then we could
        # block long enough that the message is dropped.
        try:
            self.bus_name = dbus.service.BusName(dbus_service_name,
                                                 bus=dbus.SessionBus(),
                                                 do_not_queue=True)
        except dbus.exceptions.NameExistsException, e:
            print_and_log("Already running (Unable to claim %s: %s)."
                          % (dbus_service_name, str(e)))
            sys.exit(1)

        PyWoodchuck.__init__(self, human_readable_name, dbus_service_name,
                             request_feedback)
        if not self.available():
            print_and_log("Woodchuck server not running.")
Пример #6
0
class AptWoodchuck(PyWoodchuck):
    packages_stream_identifier = 'packages'

    def __init__(self, daemon):
        # We need to do three things:
        # - Claim our DBus name.
        # - Connect to Woodchuck
        # - Make sure that Woodchuck knows about all of our streams
        #   and objects.  This really only needs to be done the
        #   first time we are run.  If daemon is False, then after we
        #   register, we quit.

        # Miscellaneous configuration.

        # Whether an update is in progress.
        self.ham_update_check_progress_id = 0

        if daemon:
            # Claim our DBus service name.
            #
            # We do this as soon as possible to avoid missing messges.
            # (DBus queues messages for 25 seconds.  Sometimes, that is
            # just not enough.)
            try:
                self.bus_name = dbus.service.BusName(dbus_service_name,
                                                     bus=dbus.SessionBus(),
                                                     do_not_queue=True)
            except dbus.exceptions.NameExistsException, e:
                print_and_log("Already running (Unable to claim %s: %s)." %
                              (dbus_service_name, str(e)))
                sys.exit(1)

        # Connect to Woodchuck.
        #
        # The human readable name will be shown to the user.  Be
        # careful what you choose: you can't easily change it;
        # PyWoodchuck uses both the human readable name AND the dbus
        # service name to identify itself to Woodchuck.
        PyWoodchuck.__init__(self,
                             human_readable_name="Application Update Manager",
                             dbus_service_name=dbus_service_name,
                             request_feedback=daemon)

        # Check if Woodchuck is really available.  If not, bail.
        if not self.available():
            print_and_log("Unable to contact Woodchuck server.")
            sys.exit(1)

        # Register our streams and objects with Woodchuck.
        #
        # This program uses one stream: the 'package' stream.
        # Updating the stream means doing an 'apt-get update'.  We
        # only register packages for which an update is available:
        # these are bits that the user is very likely interested in;
        # the expected utility of prefetching packages that are not
        # installed is low, and we don't have enough disk space to
        # mirror the whole archive anyway.

        # Be default, we want to do an apt-get update approximately
        # every day.
        freshness = 24 * 60 * 60
        try:
            self.stream_register(
                stream_identifier=self.packages_stream_identifier,
                human_readable_name='Packages',
                freshness=freshness)
        except woodchuck.ObjectExistsError:
            self[self.packages_stream_identifier].freshness = freshness

        if not daemon:
            print_and_log("Registered Woodchuck callbacks.")
            sys.exit(0)

        # Register packages with Woodchuck for which an update is
        # available.
        self.register_available_updates()