diff options
| author | Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com> | 2019-05-17 17:14:07 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-05-21 12:56:34 +0100 |
| commit | a35abe31dc23916fd06afdb3a5e22a81ef3df579 (patch) | |
| tree | a8cb43a4f80b1a5361de360f97f5507f7583ea70 | |
| parent | a1c1f3f7c583267ef9ccc9b24c84568ed0cb47f6 (diff) | |
| download | poky-a35abe31dc23916fd06afdb3a5e22a81ef3df579.tar.gz | |
bitbake: bitbake: fetch2/npm: fix npw view parsing
Fixes [YOCTO #13344]
When parsing manually the 'npm view --json' ouput, an extra closing
brackets in a JSON string can leads the fetcher to fail with a
JSONDecodeError exception.
This commit use the JSON parser to extract:
- The last object in the returned array if there are multiple results.
- The returned object if there is only one result.
(Bitbake rev: 3d319c79981811d3cfd4732885057db4fd5afcc2)
Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | bitbake/lib/bb/fetch2/npm.py | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/bitbake/lib/bb/fetch2/npm.py b/bitbake/lib/bb/fetch2/npm.py index f08bdee739..4427b1bb87 100644 --- a/bitbake/lib/bb/fetch2/npm.py +++ b/bitbake/lib/bb/fetch2/npm.py | |||
| @@ -151,20 +151,11 @@ class Npm(FetchMethod): | |||
| 151 | Parse the output of npm view --json; the last JSON result | 151 | Parse the output of npm view --json; the last JSON result |
| 152 | is assumed to be the one that we're interested in. | 152 | is assumed to be the one that we're interested in. |
| 153 | ''' | 153 | ''' |
| 154 | pdata = None | 154 | pdata = json.loads(output); |
| 155 | outdeps = {} | 155 | try: |
| 156 | datalines = [] | 156 | return pdata[-1] |
| 157 | bracelevel = 0 | 157 | except: |
| 158 | for line in output.splitlines(): | 158 | return pdata |
| 159 | if bracelevel: | ||
| 160 | datalines.append(line) | ||
| 161 | elif '{' in line: | ||
| 162 | datalines = [] | ||
| 163 | datalines.append(line) | ||
| 164 | bracelevel = bracelevel + line.count('{') - line.count('}') | ||
| 165 | if datalines: | ||
| 166 | pdata = json.loads('\n'.join(datalines)) | ||
| 167 | return pdata | ||
| 168 | 159 | ||
| 169 | def _getdependencies(self, pkg, data, version, d, ud, optional=False, fetchedlist=None): | 160 | def _getdependencies(self, pkg, data, version, d, ud, optional=False, fetchedlist=None): |
| 170 | if fetchedlist is None: | 161 | if fetchedlist is None: |
