Merge ~ycheng-twn/pc-enablement/+git/oem-scripts:0001_launchpad_api_handy into ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master

Proposed by Yuan-Chen Cheng
Status: Merged
Merged at revision: 6d29cd035e7885fbf087394b440007fe4987b24c
Proposed branch: ~ycheng-twn/pc-enablement/+git/oem-scripts:0001_launchpad_api_handy
Merge into: ~oem-solutions-engineers/pc-enablement/+git/oem-scripts:master
Diff against target: 76 lines (+38/-1)
2 files modified
debian/changelog (+6/-0)
launchpad-api (+32/-1)
Reviewer Review Type Date Requested Status
Shih-Yuan Lee Approve
Review via email: mp+404278@code.launchpad.net

Commit message

launchpad-api: refine message and add handy test

To post a comment you must log in.
Revision history for this message
Yuan-Chen Cheng (ycheng-twn) wrote :

+ cat output/oem-scripts-0.99-1f89055-in-docker-focal-summary.log
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
oem-meta-packages PASS
pkg-list PASS
review-merge-proposal PASS
run-autopkgtest PASS
setup-apt-dir PASS
mir-bug SKIP exit status 77 and marked as skippable
git-url-insteadof-setting PASS
recovery-from-iso.sh PASS
mir-bug-verification PASS

Revision history for this message
Shih-Yuan Lee (fourdollars) wrote :

Please use "Here Documents" instead.

review: Needs Fixing
Revision history for this message
Shih-Yuan Lee (fourdollars) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index a693a9a..378680c 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,9 @@
6+oem-scripts (0.99) UNRELEASED; urgency=medium
7+
8+ * launchpad-api: refine message and add handy test.
9+
10+ -- Yuan-Chen Cheng <yc.cheng@canonical.com> Fri, 04 Jun 2021 13:00:53 +0800
11+
12 oem-scripts (0.98) focal; urgency=medium
13
14 * Black all Python files.
15diff --git a/launchpad-api b/launchpad-api
16index d812b8f..aa4001e 100755
17--- a/launchpad-api
18+++ b/launchpad-api
19@@ -23,6 +23,33 @@ fi
20 LAUNCHPAD_URL="${LAUNCHPAD_URL:=https://launchpad.net}"
21 LAUNCHPAD_API="${LAUNCHPAD_API:=https://api.launchpad.net/}"
22
23+usage_auth_failed()
24+{
25+ >&2 cat <<EOF
26+=== Failure as accessing the web service.
27+
28+It could be command error OR your authentication token is removed or expired.
29+If you think it's the authentication issue, you can try to backup/remove
30+the config.ini, get authentication token and try again.
31+
32+Ex:
33+
34+ $ mv ~/.config/oem-scripts/config.ini ~/.config/oem-scripts/config.ini.backup
35+ $ launchpad-api get devel/people/+me
36+ $ # try your command after reset token by using above commands.
37+
38+EOF
39+}
40+
41+usage()
42+{
43+ >&2 cat <<EOF
44+=== Useage:
45+ $ launchpad-api get devel/people/+me # same as "launchpad-api test"
46+ $ launchpad-api get devel/people/+me ws.op==getArchiveSubscriptionURLs
47+EOF
48+}
49+
50 get_token()
51 {
52 [ "x$debug" = "x1" ] && echo "oauth_consumer_key=${oauth_consumer_key}"
53@@ -97,7 +124,7 @@ get_api()
54 oauth_timestamp=="$(date +%s)" \
55 oauth_token=="${oauth_token}" \
56 oauth_version=="1.0" \
57- "$@"
58+ "$@" || ( usage_auth_failed ; usage )
59 }
60
61 patch_api()
62@@ -162,10 +189,14 @@ case "$1" in
63 shift
64 post_api "$@"
65 ;;
66+ ("test")
67+ get_api devel/people/+me
68+ ;;
69 ("debug")
70 debug=1
71 get_api devel/people/+me
72 ;;
73 (*)
74+ usage
75 ;;
76 esac

Subscribers

People subscribed via source and target branches