Merge ~fourdollars/pc-enablement/+git/oem-scripts:master into ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master

Proposed by Shih-Yuan Lee
Status: Merged
Approved by: Shih-Yuan Lee
Approved revision: 214b2cea5338cdbffea337e3d45b9eb7751f44f6
Merged at revision: 4799f56563e692fbf689bd70a8ad2dee8113e08b
Proposed branch: ~fourdollars/pc-enablement/+git/oem-scripts:master
Merge into: ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master
Diff against target: 87 lines (+35/-35)
1 file modified
oem-meta-packages (+35/-35)
Reviewer Review Type Date Requested Status
Kai-Chuan Hsieh Approve
Review via email: mp+439403@code.launchpad.net
To post a comment you must log in.
Revision history for this message
OEM Taipei Bot (oem-taipei-bot) wrote :

[autopkgtest]
autopkgtest-collect-credentials PASS
autopkgtest-oem-scripts-auto PASS
pkg-somerville-meta PASS
pkg-stella-meta PASS
pkg-sutton-meta PASS
bug-bind PASS
get-private-ppa PASS
jq-lp PASS
launchpad-api PASS
lp-bug PASS
pkg-list PASS
review-merge-proposal PASS
run-autopkgtest PASS
setup-apt-dir PASS
bootstrap-meta PASS
mir-bug PASS
oem-meta-packages PASS
git-url-insteadof-setting PASS
lp-dl-attm PASS
recovery-from-iso.sh PASS

https://oem-share.canonical.com/partners/lyoncore/share/artifacts/oem-scripts/oem-scripts-1.68-214b2ce-in-linux-container-jammy

Revision history for this message
Kai-Chuan Hsieh (kchsieh) wrote :

It can traverse all meta without providing meta parameter, LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/oem-meta-packages b/oem-meta-packages
2index b7ddb0c..f8f4d28 100755
3--- a/oem-meta-packages
4+++ b/oem-meta-packages
5@@ -2054,47 +2054,47 @@ if args.subcommand == "list":
6 print(name)
7 elif args.subcommand == "subscribe":
8 if args.meta:
9- name = args.meta
10- info(f"Checking the subscriptions for {name}...")
11- source = lp.distributions["ubuntu"].getSourcePackage(name=name)
12- if SUBSCRIBER in map(lambda x: x.subscriber.name, source.getSubscriptions()):
13- info(f"ubuntu/{name} has subscribed '{SUBSCRIBER}'.")
14- exit(0)
15- warning(f"ubuntu/{name} didn't subscribe '{SUBSCRIBER}' yet.")
16- if yes_or_ask(
17- args.yes, f"Would you like to subscribe '{SUBSCRIBER}' for ubuntu/{name}?"
18- ):
19- try:
20- # When a person is subscribed to a source package, one actually subscribe all bugs for it.
21- source.addBugSubscription(subscriber=lp.people[SUBSCRIBER])
22- except lazr.restfulclient.errors.Unauthorized as e:
23- error(
24- f"{lp.me.name} does not have permission to subscribe '{SUBSCRIBER}'."
25- )
26- if args.verbose:
27- print(e)
28- exit(1)
29- exit(0)
30- for name in get_oem_meta_packages(cache):
31+ sources_in_set = [args.meta]
32+ else:
33+ ds = lp.distributions["ubuntu"].getSeries(name_or_version=series)
34+ packageset = lp.packagesets.getByName(
35+ distroseries=ds, name="canonical-oem-metapackages"
36+ )
37+ sources_in_set = sorted(set(packageset.getSourcesIncluded()))
38+ valid_member = False
39+ try:
40+ for member in lp.people[SUBSCRIBER].members:
41+ if lp.me == member:
42+ valid_member = True
43+ break
44+ else:
45+ warning(
46+ f"{lp.me.name} does not have the permission to subscribe '{SUBSCRIBER}'."
47+ )
48+ # Note: lp.credentials.access_token will be an instance of launchpadlib.credentials.AnonymousAccessToken.
49+ except lazr.restfulclient.errors.Unauthorized:
50+ warning(f"Anonymous does not have the permission to subscribe '{SUBSCRIBER}'.")
51+ ret = 0
52+ for name in sources_in_set:
53 info(f"Checking the subscriptions for {name}...")
54 source = lp.distributions["ubuntu"].getSourcePackage(name=name)
55 if SUBSCRIBER in map(lambda x: x.subscriber.name, source.getSubscriptions()):
56 info(f"ubuntu/{name} has subscribed '{SUBSCRIBER}'.")
57 continue
58- warning(f"ubuntu/{name} didn't subscribe '{SUBSCRIBER}' yet.")
59- if yes_or_ask(
60- args.yes, f"Would you like to subscribe '{SUBSCRIBER}' for ubuntu/{name}?"
61+ if (
62+ valid_member
63+ and not args.dry_run
64+ and yes_or_ask(
65+ args.yes,
66+ f"Would you like to subscribe '{SUBSCRIBER}' for ubuntu/{name}?",
67+ )
68 ):
69- try:
70- # When a person is subscribed to a source package, one actually subscribe all bugs for it.
71- source.addBugSubscription(subscriber=lp.people[SUBSCRIBER])
72- except lazr.restfulclient.errors.Unauthorized as e:
73- error(
74- f"{lp.me.name} does not have permission to subscribe '{SUBSCRIBER}'."
75- )
76- if args.verbose:
77- print(e)
78- exit(1)
79+ # When a person is subscribed to a source package, one actually subscribe all bugs for it.
80+ source.addBugSubscription(subscriber=lp.people[SUBSCRIBER])
81+ else:
82+ error(f"ubuntu/{name} didn't subscribe '{SUBSCRIBER}' yet.")
83+ ret = 1
84+ exit(ret)
85 elif args.subcommand == "unsubscribe":
86 source = lp.distributions["ubuntu"].getSourcePackage(name=args.pkgName)
87 subscriptions = source.getSubscriptions()

Subscribers

People subscribed via source and target branches