~bdrung/apport:pending-patches

Last commit made on 2023-04-28
Get this branch:
git clone -b pending-patches https://git.launchpad.net/~bdrung/apport
Only Benjamin Drung can upload to this branch. If you are Benjamin Drung please log in for upload directions.

Branch merges

Branch information

Name:
pending-patches
Repository:
lp:~bdrung/apport

Recent commits

e194f16... by Benjamin Drung

apport-kde: Use translations support from Qt 5

`Properties._string` in Qt 5 already calls
`QtWidgets.QApplication.translate` nowadays.

TODO: Check if translation really works for the dialog buttons!

Signed-off-by: Benjamin Drung <email address hidden>

22d3c7b... by Benjamin Drung

Use pidof from psutil

Signed-off-by: Benjamin Drung <email address hidden>

a0172a1... by Benjamin Drung

WIP: Use __file__ instead of sys.argv[0]

Signed-off-by: Benjamin Drung <email address hidden>

c6e905b... by Benjamin Drung

fix(tests): Fix false positives for test_run_crash_anonymity

The test `test_run_crash_anonymity` can fail if the user or host name is
short:

```
======================================================================
FAIL: test_run_crash_anonymity (tests.integration.test_ui.T)
run_crash() anonymization
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.10/unittest/mock.py", line 1369, in patched
    return func(*newargs, **newkeywargs)
  File "/<<PKGBUILDDIR>>/tests/integration/test_ui.py", line 1650, in test_run_crash_anonymity
    self.assertNotIn(
AssertionError: 'kin' unexpectedly found in 'ProblemType: Crash\nArchitecture: amd64\n[...]'
```

The string `kin` can be found in the report (for example in the tag
`kinetic`). So only search for full words in the report if the string is
short (less than five characters and not the string `ubuntu`).

Signed-off-by: Benjamin Drung <email address hidden>

289994d... by Benjamin Drung

fix: Use ProblemReport for running generic hook manually

Running the generic general hook manually fails:

```
$ python3 data/general-hooks/generic.py
Traceback (most recent call last):
  File "/home/bdrung/projects/apport/apport/data/general-hooks/generic.py", line 129, in <module>
    add_info(r, None)
  File "/home/bdrung/projects/apport/apport/data/general-hooks/generic.py", line 123, in add_info
    if report["ProblemType"] == "Crash":
       ~~~~~~^^^^^^^^^^^^^^^
KeyError: 'ProblemType'
```

Use an instance of `ProblemReport` like Apport would use.

Signed-off-by: Benjamin Drung <email address hidden>

81fad6c... by Benjamin Drung

fix: Fix raising OSError if _command_output() runs into a timeout

mypy complains:

```
apport/report.py:179: error: On Python 3 formatting "b'abc'" with "{}" produces "b'abc'", not "abc"; use "{!r}" if this is desired behavior [str-bytes-safe]
apport/report.py:180: error: Item "None" of "Optional[bytes]" has no attribute "rstrip" [union-attr]
```

The mypy complains can be converted into a test case that fail:

```
ERROR: test_command_output_timeout_no_output (tests.integration.test_report.T.test_command_output_timeout_no_output)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/bdrung/projects/apport/apport/apport/report.py", line 169, in _command_output
    sp = subprocess.run(
         ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 550, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1207, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 2060, in _communicate
    self._check_timeout(endtime, orig_timeout, stdout, stderr)
  File "/usr/lib/python3.11/subprocess.py", line 1251, in _check_timeout
    raise TimeoutExpired(
subprocess.TimeoutExpired: Command '['sleep', '3600']' timed out after 0.1 seconds

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/bdrung/projects/apport/apport/tests/integration/test_report.py", line 1938, in test_command_output_timeout_no_output
    apport.report._command_output(["sleep", "3600"], timeout=0.1)
  File "/home/bdrung/projects/apport/apport/apport/report.py", line 182, in _command_output
    f" after {error.timeout} seconds: {error.stdout.rstrip()}"
                                       ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'rstrip'
```

Signed-off-by: Benjamin Drung <email address hidden>

d9d6f21... by Benjamin Drung

refactor(apport): Drop using proc_pid_fd from is_same_ns

Instead of using `proc_pid_fd` in `is_same_ns()` just specify the path
to the cgroup file. The other code in the function does that already.

Signed-off-by: Benjamin Drung <email address hidden>

354a822... by Benjamin Drung

refactor: Move pylint's invalid-name overrides to affected files

Move pylint's invalid-name overrides to affected files to allow getting
this alert for new cases. Address the pylint complains for files that
only have a few complains.

Signed-off-by: Benjamin Drung <email address hidden>

90ae21c... by Benjamin Drung

refactor(gtk/kde): Add assertions to make mypy happy

mypy complains:

```
gtk/apport-gtk:238: error: "None" has no attribute "get" [attr-defined]
gtk/apport-gtk:280: error: Value of type "None" is not indexable [index]
gtk/apport-gtk:413: error: Unsupported right operand type for in ("None") [operator]
gtk/apport-gtk:414: error: Value of type "None" is not indexable [index]
kde/apport-kde:130: error: "QObject" has no attribute "setRange" [attr-defined]
kde/apport-kde:131: error: "QObject" has no attribute "setValue" [attr-defined]
kde/apport-kde:133: error: "QObject" has no attribute "setRange" [attr-defined]
kde/apport-kde:134: error: "QObject" has no attribute "setValue" [attr-defined]
kde/apport-kde:413: error: Incompatible types in assignment (expression has type "ReportDialog", variable has type "None") [assignment]
kde/apport-kde:417: error: "None" has no attribute "exec_" [attr-defined]
kde/apport-kde:426: error: "None" has no attribute "continue_button" [attr-defined]
kde/apport-kde:429: error: "None" has no attribute "send_error_report" [attr-defined]
kde/apport-kde:431: error: "None" has no attribute "ignore_future_problems" [attr-defined]
kde/apport-kde:516: error: "None" has no attribute "set" [attr-defined]
kde/apport-kde:518: error: "None" has no attribute "set" [attr-defined]
```

Add assertions to ensure that the variables are not `None`.

Signed-off-by: Benjamin Drung <email address hidden>

e452ee1... by Benjamin Drung

refactor(apport-cli): Move saving the report into a separate function

Move saving the problem report in a temporary directory into a separate
function. Assert that `self.report` is not `None` to make mypy happy.

Signed-off-by: Benjamin Drung <email address hidden>