Merge lp:~renanrodrigo/update-manager/ss into lp:update-manager

Proposed by Renan Rodrigo
Status: Merged
Merged at revision: 2951
Proposed branch: lp:~renanrodrigo/update-manager/ss
Merge into: lp:update-manager
Diff against target: 86 lines (+13/-36)
1 file modified
ubuntu-security-status (+13/-36)
To merge this branch: bzr merge lp:~renanrodrigo/update-manager/ss
Reviewer Review Type Date Requested Status
Brian Murray Approve
Lucas Albuquerque Medeiros de Moura (community) Approve
Review via email: mp+430698@code.launchpad.net

Commit message

ubuntu-security-status: Don't show ESM Apps information when the service is disabled, and prefer 'pro security-status' when it is available.

Description of the change

Due to changes in the Pro launch strategy, the tooling should not advertise ESM-Apps even when it goes out of beta. If ubuntu-advantage-tools has made 'pro' available to the system, delegate the 'ubuntu-security-status' call to 'pro security-status' to make sure it reflects the Pro Client output.

To post a comment you must log in.
Revision history for this message
Lucas Albuquerque Medeiros de Moura (lamoura) :
lp:~renanrodrigo/update-manager/ss updated
2951. By Renan Rodrigo

Prefer redirecting ubuntu-security-status to pro security-status if it exists

Revision history for this message
Renan Rodrigo (renanrodrigo) wrote :

Thanks Lucas for the review, I updated the code to the safer version.

Revision history for this message
Lucas Albuquerque Medeiros de Moura (lamoura) :
review: Approve
Revision history for this message
Brian Murray (brian-murray) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu-security-status'
2--- ubuntu-security-status 2022-01-18 16:17:47 +0000
3+++ ubuntu-security-status 2022-09-29 02:29:13 +0000
4@@ -7,13 +7,13 @@
5 import os
6 import sys
7 import gettext
8+import shutil
9 import subprocess
10
11 from UpdateManager.Core.utils import get_dist
12
13 from datetime import datetime
14 from textwrap import wrap
15-from uaclient.entitlements import ESMAppsEntitlement
16 from urllib.error import URLError, HTTPError
17 from urllib.request import urlopen
18
19@@ -197,6 +197,12 @@
20
21
22 if __name__ == "__main__":
23+ # Prefer redirecting to 'pro security-status' if it exists
24+ if shutil.which("/usr/bin/pro"):
25+ print("This command has been replaced with 'pro security-status'.")
26+ subprocess.run(["/usr/bin/pro", "security-status"])
27+ sys.exit(0)
28+
29 # gettext
30 APP = "update-manager"
31 DIR = "/usr/share/locale"
32@@ -508,15 +514,11 @@
33 ("{:>{width}}".format(len(pkgstats.pkgs_mr),
34 width=width),
35 receive_text, eol_esm.month, eol_esm.year))
36- if lts and pkgstats.pkgs_um and (
37- is_ua_service_enabled("esm-apps") or not ESMAppsEntitlement.is_beta
38- ):
39- receive_text = "could receive"
40- if esm_apps_enabled:
41- if len(pkgstats.pkgs_um) == 1:
42- receive_text = "is receiving"
43- else:
44- receive_text = "are receiving"
45+ if lts and pkgstats.pkgs_um and is_ua_service_enabled("esm-apps"):
46+ if len(pkgstats.pkgs_um) == 1:
47+ receive_text = "is receiving"
48+ else:
49+ receive_text = "are receiving"
50 print("%s %s security updates with ESM Apps "
51 "until %d/%d" %
52 ("{:>{width}}".format(len(pkgstats.pkgs_um),
53@@ -571,32 +573,7 @@
54 print_wrapped(msg)
55 if ua_attached:
56 print("\nEnable ESM Infra with: ua enable esm-infra")
57- if lts and pkgstats.pkgs_um:
58- if (
59- not esm_apps_enabled and
60- not ESMAppsEntitlement.is_beta
61- ):
62- pkgs_updated_in_esma = pkgstats.pkgs_updated_in_esma
63- print("")
64- msg = gettext.dngettext(
65- "update-manager",
66- "Enable Extended Security "
67- "Maintenance (ESM Apps) to "
68- "get %i security update (so far) ",
69- "Enable Extended Security "
70- "Maintenance (ESM Apps) to "
71- "get %i security updates (so far) ",
72- len(pkgs_updated_in_esma)) % len(pkgs_updated_in_esma)
73- msg += gettext.dngettext(
74- "update-manager",
75- "and enable coverage of %i "
76- "package.",
77- "and enable coverage of %i "
78- "packages.",
79- len(pkgstats.pkgs_um)) % len(pkgstats.pkgs_um)
80- print_wrapped(msg)
81- if ua_attached:
82- print("\nEnable ESM Apps with: ua enable esm-apps")
83+
84 if lts and not ua_attached:
85 print("\nThis machine is not attached to an Ubuntu Advantage "
86 "subscription.\nSee https://ubuntu.com/advantage")

Subscribers

People subscribed via source and target branches

to status/vote changes: