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

2511.1.5 by Michael Terry
pep8-ify debian and UpdateManagerText
1
# -*- Mode: Python; indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
2
2122.1.2 by Brian Murray
really add apport hook
3
'''apport package hook for update-manager
4
5
(c) 2011 Canonical Ltd.
6
Author: Brian Murray <brian@ubuntu.com>
7
'''
8
2653 by Brian Murray
* In the apport hook ask if the bug is about upgrading from one release to
9
import os
2308 by Brian Murray
debian/source_update-manager.py: include AptDaemon messages from syslog to
10
import re
2741 by Brian Murray
source_update-manager.py: collect information about the state of HWE
11
import subprocess
2303 by Michael Vogt
* pyflake fixes, remove some dead code
12
from apport.hookutils import (
2308 by Brian Murray
debian/source_update-manager.py: include AptDaemon messages from syslog to
13
    attach_gsettings_package, attach_root_command_outputs,
2741 by Brian Murray
source_update-manager.py: collect information about the state of HWE
14
    attach_file_if_exists, command_available,
15
    recent_syslog)
16
17
18
def run_hwe_command(option):
19
    command = ['hwe-support-status', option]
20
    sp = subprocess.Popen(command, stdout=subprocess.PIPE,
21
                          stderr=subprocess.STDOUT,
22
                          stdin=None)
23
    out = sp.communicate()[0]
24
    if sp.returncode == 0:
25
        res = out.strip()
26
    # exit code is 10 on unsupported HWE
27
    elif sp.returncode == 10:
28
        res = out.strip()
29
    else:
2841.1.1 by Balint Reczey
Ignore PEP 8 W503 instead of E502 and drop many added backslashes
30
        res = (b'Error: command ' + str(command).encode()
31
               + b' failed with exit code '
2840.1.1 by Balint Reczey
Fix PEP 8 warnings
32
               + str(sp.returncode).encode() + b': ' + out)
2741 by Brian Murray
source_update-manager.py: collect information about the state of HWE
33
    return res
2122.1.2 by Brian Murray
really add apport hook
34
35
2223.1.1 by Brian Murray
debian/source-update_manager.py: ask the reporter if their issue is
36
def add_info(report, ui):
2122.1.2 by Brian Murray
really add apport hook
37
2653 by Brian Murray
* In the apport hook ask if the bug is about upgrading from one release to
38
    problem_type = report.get("ProblemType", None)
39
    if problem_type == "Bug":
2655 by Brian Murray
debian/source_update_manager.py: Fix too long line (pep8 error).
40
        response = ui.yesno("Is the issue you are reporting one you \
41
encountered when upgrading Ubuntu from one release to another?")
2667 by Brian Murray
source_update_manager.py: set response to None if the problem type is not
42
    else:
43
        response = None
2653 by Brian Murray
* In the apport hook ask if the bug is about upgrading from one release to
44
    if response:
45
        os.execlp('apport-bug', 'apport-bug', 'ubuntu-release-upgrader')
46
    else:
2893 by Brian Murray
releasing package update-manager version 1:20.10.1
47
        package = report.get("Package", None)
2891 by Brian Murray
In the apport hook don't assume the bug is being reported about the
48
        if package:
49
            package = package.split(' ')[0]
50
        if package == 'update-manager':
51
            attach_gsettings_package(report, 'update-manager')
2653 by Brian Murray
* In the apport hook ask if the bug is about upgrading from one release to
52
        attach_file_if_exists(report, '/var/log/apt/history.log',
53
                              'DpkgHistoryLog.txt')
54
        attach_file_if_exists(report, '/var/log/apt/term.log',
55
                              'DpkgTerminalLog.txt')
56
        attach_root_command_outputs(
57
            report,
58
            {'CurrentDmesg.txt':
59
                'dmesg | comm -13 --nocheck-order /var/log/dmesg -'})
2741 by Brian Murray
source_update-manager.py: collect information about the state of HWE
60
        if command_available('hwe-support-status'):
61
            # not using apport's command_output because it doesn't expect a
62
            # return code of 10
2744 by Brian Murray
source_update-manager.py: only collect HWE information if it exists.
63
            unsupported = run_hwe_command('--show-all-unsupported')
64
            if unsupported:
65
                report['HWEunsupported'] = unsupported
2775 by Brian Murray
Fix a bunch of pep8 related errors.
66
                report['HWEreplacements'] = \
67
                    run_hwe_command('--show-replacements')
2653 by Brian Murray
* In the apport hook ask if the bug is about upgrading from one release to
68
        report["Aptdaemon"] = recent_syslog(re.compile("AptDaemon"))