~ubuntu-core-dev/update-manager/main

« back to all changes in this revision

Viewing changes to UpdateManager/backend/InstallBackendSynaptic.py

  • Committer: Benjamin Drung
  • Date: 2023-02-13 12:45:23 UTC
  • Revision ID: benjamin.drung@canonical.com-20230213124523-4f1nv2fyvsdl35jb
Fix pycodestyle complains by formatting Python code with black

```
black -C -l 79 .
```

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
from gettext import gettext as _
8
8
 
9
9
import gi
 
10
 
10
11
gi.require_version("Gtk", "3.0")
11
12
from gi.repository import GObject
 
13
 
12
14
# Extra GdkX11 import for pygobject bug #673396
13
15
# https://bugzilla.gnome.org/show_bug.cgi?id=673396
14
16
from gi.repository import GdkX11
 
17
 
15
18
GdkX11  # pyflakes
16
19
 
17
20
from UpdateManager.backend import InstallBackend
18
21
 
19
22
 
20
23
class InstallBackendSynaptic(InstallBackend):
21
 
    """ Install backend based on synaptic """
 
24
    """Install backend based on synaptic"""
22
25
 
23
26
    def update(self):
24
27
        opt = ["--update-at-startup"]
25
28
        tempf = None
26
29
        self._run_synaptic(self.ACTION_UPDATE, opt, tempf)
27
30
 
28
 
    def commit(self, pkgs_install, pkgs_upgrade, pkgs_remove,
29
 
               close_on_done=False):
 
31
    def commit(
 
32
        self, pkgs_install, pkgs_upgrade, pkgs_remove, close_on_done=False
 
33
    ):
30
34
        # close when update was successful (its ok to use a Synaptic::
31
35
        # option here, it will not get auto-saved, because synaptic does
32
36
        # not save options in non-interactive mode)
56
60
            xid = win.get_xid()
57
61
        except AttributeError:
58
62
            xid = 0
59
 
        cmd = ["/usr/bin/pkexec", "/usr/sbin/synaptic", "--hide-main-window",
60
 
               "--non-interactive", "--parent-window-id",
61
 
               "%s" % xid]
 
63
        cmd = [
 
64
            "/usr/bin/pkexec",
 
65
            "/usr/sbin/synaptic",
 
66
            "--hide-main-window",
 
67
            "--non-interactive",
 
68
            "--parent-window-id",
 
69
            "%s" % xid,
 
70
        ]
62
71
        cmd.extend(opt)
63
72
        flags = GObject.SPAWN_DO_NOT_REAP_CHILD
64
73
        (pid, stdin, stdout, stderr) = GObject.spawn_async(cmd, flags=flags)
72
81
        action, tempf = data
73
82
        if tempf:
74
83
            tempf.close()
75
 
        self._action_done(action,
76
 
                          authorized=True,
77
 
                          success=os.WEXITSTATUS(condition) == 0,
78
 
                          error_string=None, error_desc=None)
 
84
        self._action_done(
 
85
            action,
 
86
            authorized=True,
 
87
            success=os.WEXITSTATUS(condition) == 0,
 
88
            error_string=None,
 
89
            error_desc=None,
 
90
        )