def commit(self, pkgs_install, pkgs_upgrade, close_on_done):
     """Commit a list of package adds and removes"""
     try:
         apt_pkg.pkgsystem_unlock()
     except SystemError:
         pass
     try:
         reinstall = remove = purge = downgrade = []
         trans = yield self.client.commit_packages(pkgs_install,
                                                   reinstall,
                                                   remove,
                                                   purge,
                                                   pkgs_upgrade,
                                                   downgrade,
                                                   defer=True)
         trans.connect("progress-changed", self._on_progress_changed)
         yield self._run_in_dialog(trans, self.ACTION_INSTALL)
     except errors.NotAuthorizedError as e:
         self._action_done(self.ACTION_INSTALL, False, False, str(e), None)
     except dbus.DBusException as e:
         if e.get_dbus_name() != "org.freedesktop.DBus.Error.NoReply":
             raise
         self._action_done(self.ACTION_INSTALL, False, False, None, None)
     except Exception as e:
         self._action_done(self.ACTION_INSTALL, True, False, None, None)
         raise
Example #2
0
 def start_update(self):
     #print "startUpdate"
     apt_pkg.pkgsystem_unlock()
     self.action.set_markup("<i>" + _("Installing dependencies...") +
                            "</i>")
     self.progress.set_fraction(0.0)
     self.progress.set_text("")
Example #3
0
 def try_acquire_lock(self):
     " check if we can lock the apt database "
     try:
         apt_pkg.pkgsystem_lock()
     except SystemError:
         self.error_header = _("Only one software management tool is allowed to"
                    " run at the same time")
         self.error_body = _("Please close the other application e.g. 'Update "
                  "Manager', 'aptitude' or 'Synaptic' first.")
         return False
     apt_pkg.pkgsystem_unlock()
     return True
 def update_cache(self, window_id, lock):
     """start synaptic to update the package cache"""
     try:
         apt_pkg.pkgsystem_unlock()
     except SystemError:
         pass
     cmd = ["/usr/sbin/synaptic", "--hide-main-window",
            "--non-interactive",
            "--parent-window-id", "%s" % (window_id),
            "--update-at-startup"]
     subprocess.call(cmd)
     lock.release()
 def update(self):
     """Refresh the package list"""
     try:
         apt_pkg.pkgsystem_unlock()
     except SystemError:
         pass
     try:
         trans = yield self.client.update_cache(defer=True)
         yield self._run_in_dialog(trans, self.UPDATE)
     except errors.NotAuthorizedError:
         self.emit("action-done", self.UPDATE, False, False)
     except:
         self.emit("action-done", self.UPDATE, True, False)
         raise
Example #6
0
 def try_acquire_lock(self):
     " check if we can lock the apt database "
     try:
         apt_pkg.pkgsystem_lock()
     except SystemError:
         self.error_header = _(
             "Only one software management tool is allowed to"
             " run at the same time")
         self.error_body = _(
             "Please close the other application e.g. 'Update "
             "Manager', 'aptitude' or 'Synaptic' first.")
         return False
     apt_pkg.pkgsystem_unlock()
     return True
 def update(self):
     """Refresh the package list"""
     try:
         apt_pkg.pkgsystem_unlock()
     except SystemError:
         pass
     try:
         trans = yield self.client.update_cache(defer=True)
         yield self._run_in_dialog(trans, self.UPDATE)
     except errors.NotAuthorizedError as e:
         self._action_done(self.UPDATE, False, False, str(e), None)
     except:
         self.action_done(self.UPDATE, True, False, None, None)
         raise
 def _run_synaptic(self, action, opt, tempf):
     """Execute synaptic."""
     try:
         apt_pkg.pkgsystem_unlock()
     except SystemError:
         pass
     cmd = ["/usr/bin/gksu", 
            "--desktop", "/usr/share/applications/update-manager.desktop", 
            "--", "/usr/sbin/synaptic", "--hide-main-window",  
            "--non-interactive", "--parent-window-id",
            "%s" % self.window_main.window.xid ]
     cmd.extend(opt)
     flags = GObject.SPAWN_DO_NOT_REAP_CHILD
     (pid, stdin, stdout, stderr) = GObject.spawn_async(cmd, flags=flags)
     GObject.child_watch_add(pid, self._on_synaptic_exit, (action, tempf))
Example #9
0
 def _run_synaptic(self, action, opt, tempf):
     """Execute synaptic."""
     try:
         apt_pkg.pkgsystem_unlock()
     except SystemError:
         pass
     cmd = ["/usr/bin/pkexec", "/usr/sbin/synaptic", "--hide-main-window",
            "--non-interactive", "--parent-window-id",
            "%s" % self.window_main.get_window().get_xid() ]
     cmd.extend(opt)
     flags = GObject.SPAWN_DO_NOT_REAP_CHILD
     (pid, stdin, stdout, stderr) = GObject.spawn_async(cmd, flags=flags)
     # Keep a reference to the data tuple passed to
     # GObject.child_watch_add to avoid attempts to destroy it without a
     # thread context: https://bugs.launchpad.net/bugs/724687
     self.child_data = (action, tempf)
     GObject.child_watch_add(pid, self._on_synaptic_exit, self.child_data)
Example #10
0
 def show_settings(self):
     try:
         apt_pkg.pkgsystem_unlock()
     except SystemError:
         pass
     cmd = ["/usr/bin/software-properties-gtk",
            "--open-tab", "2",
            "--toplevel", "%s" % self.get_window().get_xid()
            ]
     self._look_busy()
     try:
         p = subprocess.Popen(cmd)
     except OSError:
         pass
     else:
         while p.poll() is None:
             while Gtk.events_pending():
                 Gtk.main_iteration()
             time.sleep(0.05)
     finally:
         self.start_available()
 def _run_synaptic(self, action, opt, tempf):
     """Execute synaptic."""
     try:
         apt_pkg.pkgsystem_unlock()
     except SystemError:
         pass
     win = self.window_main.get_window()
     try:
         xid = win.get_xid()
     except AttributeError:
         xid = 0
     cmd = ["/usr/bin/pkexec", "/usr/sbin/synaptic", "--hide-main-window",
            "--non-interactive", "--parent-window-id",
            "%s" % xid]
     cmd.extend(opt)
     flags = GObject.SPAWN_DO_NOT_REAP_CHILD
     (pid, stdin, stdout, stderr) = GObject.spawn_async(cmd, flags=flags)
     # Keep a reference to the data tuple passed to
     # GObject.child_watch_add to avoid attempts to destroy it without a
     # thread context: https://bugs.launchpad.net/bugs/724687
     self.child_data = (action, tempf)
     GObject.child_watch_add(pid, self._on_synaptic_exit, self.child_data)
 def commit(self, pkgs_install, pkgs_upgrade, close_on_done):
     """Commit a list of package adds and removes"""
     try:
         apt_pkg.pkgsystem_unlock()
     except SystemError:
         pass
     try:
         reinstall = remove = purge = downgrade = []
         trans = yield self.client.commit_packages(
             pkgs_install, reinstall, remove, purge, pkgs_upgrade, 
             downgrade, defer=True)
         trans.connect("progress-changed", self._on_progress_changed)
         yield self._run_in_dialog(trans, self.INSTALL)
     except errors.NotAuthorizedError as e:
         self.emit("action-done", self.INSTALL, False, False)
     except dbus.DBusException as e:
         if e.get_dbus_name() != "org.freedesktop.DBus.Error.NoReply":
             raise
         self.emit("action-done", self.INSTALL, False, False)
     except Exception as e:
         self.emit("action-done", self.INSTALL, True, False)
         raise
Example #13
0
 def on_button_settings_clicked(self, widget):
     #print("on_button_settings_clicked")
     try:
         apt_pkg.pkgsystem_unlock()
     except SystemError:
         pass
     cmd = ["/usr/bin/software-properties-gtk",
            "--open-tab", "2",
            # FIXME: once get_xid() is available via introspections, add
            #        this back
            #"--toplevel", "%s" % self.window_main.get_window().get_xid()
            ]
     self.window_main.set_sensitive(False)
     p = subprocess.Popen(cmd)
     while p.poll() is None:
         while Gtk.events_pending():
             Gtk.main_iteration()
         time.sleep(0.05)
     apt_pkg.init_config()
     self.window_main.refresh_cache()
     self.fillstore()
     self.update_close_button()
     self.window_main.set_sensitive(True)
Example #14
0
 def _unlock(self):
     self.logger.verbose("Unlocking the global pkgsystem.")
     apt_pkg.pkgsystem_unlock()
     self.locked = False
Example #15
0
    lock = "/tmp/test.lck"

    apt_pkg.init()

    # system-lock
    apt_pkg.pkgsystem_lock()

    pid = os.fork()
    if pid == 0:
        try:
            apt_pkg.pkgsystem_lock()
        except SystemError as s:
            print "Can't get lock: (error text:\n%s)" % s
        sys.exit(0)

    apt_pkg.pkgsystem_unlock()

    # low-level lock
    fd = apt_pkg.get_lock(lock, True)
    print "Lockfile fd: %s" % fd

    # try to get lock without error flag
    pid = os.fork()
    if pid == 0:
        # child
        fd = apt_pkg.get_lock(lock, False)
        print "Lockfile fd (child): %s" % fd
        sys.exit(0)

    # try to get lock with error flag
    pid = os.fork()
Example #16
0
    lock = "/tmp/test.lck"

    apt_pkg.init()

    # system-lock
    apt_pkg.pkgsystem_lock()

    pid = os.fork()
    if pid == 0:
        try:
            apt_pkg.pkgsystem_lock()
        except SystemError as s:
            print("Can't get lock: (error text:\n%s)" % s)
        sys.exit(0)

    apt_pkg.pkgsystem_unlock()

    # low-level lock
    fd = apt_pkg.get_lock(lock, True)
    print("Lockfile fd: %s" % fd)

    # try to get lock without error flag
    pid = os.fork()
    if pid == 0:
        # child
        fd = apt_pkg.get_lock(lock, False)
        print("Lockfile fd (child): %s" % fd)
        sys.exit(0)

    # try to get lock with error flag
    pid = os.fork()
Example #17
0
 def start_update(self):
     #print "startUpdate"
     apt_pkg.pkgsystem_unlock()
     self.action.set_markup("<i>"+_("Installing dependencies...")+"</i>")
     self.progress.set_fraction(0.0)
     self.progress.set_text("")
Example #18
0
 def start_update(self):
     apt_pkg.pkgsystem_unlock()
     self.action.setText(_("Installing dependencies..."))
     self.progress.setValue(0)
Example #19
0
 def start_update(self):
     apt_pkg.pkgsystem_unlock()
     self.action.setText(_("Installing dependencies..."))
     self.progress.setValue(0)