Merge ~sylvain-pineau/plainbox-provider-resource:more_snapd_fixes into plainbox-provider-resource:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 77d80b1cad05977cd5e89acaa805434a84894c25
Merged at revision: 304ab5c12cfe0ebc20ea0519f8c0aec7add7b829
Proposed branch: ~sylvain-pineau/plainbox-provider-resource:more_snapd_fixes
Merge into: plainbox-provider-resource:master
Diff against target: 34 lines (+10/-4)
1 file modified
bin/snapd_resource (+10/-4)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+335008@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

tested on a system w/o snapd rest API

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/snapd_resource b/bin/snapd_resource
2index 3dd513d..749af75 100755
3--- a/bin/snapd_resource
4+++ b/bin/snapd_resource
5@@ -33,9 +33,12 @@ class SnapdQuery(Command):
6 try:
7 r = self._session.get(SNAPD_BASE_URL + path)
8 except requests.exceptions.RequestException as e:
9- # snapd might not be installed, silently exit 0
10+ # snapd might not be installed, silently return an empty Response
11 if 'FileNotFoundError' in traceback.format_exc():
12- sys.exit(0)
13+ r = requests.Response()
14+ r.status_code = 200
15+ r._content = b'{"result":""}'
16+ r.headers['X-Ubuntu-Assertions-Count'] = 0
17 else:
18 raise
19 if r.status_code != requests.codes.ok:
20@@ -48,9 +51,12 @@ class SnapdQuery(Command):
21 try:
22 res = self._session.post(SNAPD_BASE_URL + path, data=data)
23 except requests.exceptions.RequestException as e:
24- # snapd might not be installed, silently exit 0
25+ # snapd might not be installed, silently return an empty Response
26 if 'FileNotFoundError' in traceback.format_exc():
27- sys.exit(0)
28+ r = requests.Response()
29+ r.status_code = 200
30+ r._content = b'{"result":""}'
31+ r.headers['X-Ubuntu-Assertions-Count'] = 0
32 else:
33 raise
34 if not res.ok:

Subscribers

People subscribed via source and target branches