diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2021-02-09 09:50:21 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-02-10 23:48:16 +0000 |
commit | 75f87db413f3659fee18eff389b7b339b01cce15 (patch) | |
tree | e733135549b516c72c4f34172b6bbf865377fc76 /bitbake/lib/layerindexlib/restapi.py | |
parent | 7283a0b3b6ca49d0d2e13593333a580ef10439a8 (diff) | |
download | poky-75f87db413f3659fee18eff389b7b339b01cce15.tar.gz |
bitbake: logging: Make bitbake logger compatible with python logger
The bitbake logger overrode the definition of the debug() logging call
to include a debug level, but this causes problems with code that may
be using standard python logging, since the extra argument is
interpreted differently.
Instead, change the bitbake loggers debug() call to match the python
logger call and add a debug2() and debug3() API to replace calls that
were logging to a different debug level.
[RP: Small fix to ensure bb.debug calls bbdebug()]
(Bitbake rev: f68682a79d83e6399eb403f30a1f113516575f51)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/layerindexlib/restapi.py')
-rw-r--r-- | bitbake/lib/layerindexlib/restapi.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/bitbake/lib/layerindexlib/restapi.py b/bitbake/lib/layerindexlib/restapi.py index 7023f42f20..26a1c9674e 100644 --- a/bitbake/lib/layerindexlib/restapi.py +++ b/bitbake/lib/layerindexlib/restapi.py | |||
@@ -82,7 +82,7 @@ class RestApiPlugin(layerindexlib.plugin.IndexPlugin): | |||
82 | 82 | ||
83 | 83 | ||
84 | def load_cache(path, index, branches=[]): | 84 | def load_cache(path, index, branches=[]): |
85 | logger.debug(1, 'Loading json file %s' % path) | 85 | logger.debug('Loading json file %s' % path) |
86 | with open(path, 'rt', encoding='utf-8') as f: | 86 | with open(path, 'rt', encoding='utf-8') as f: |
87 | pindex = json.load(f) | 87 | pindex = json.load(f) |
88 | 88 | ||
@@ -102,7 +102,7 @@ class RestApiPlugin(layerindexlib.plugin.IndexPlugin): | |||
102 | if newpBranch: | 102 | if newpBranch: |
103 | index.add_raw_element('branches', layerindexlib.Branch, newpBranch) | 103 | index.add_raw_element('branches', layerindexlib.Branch, newpBranch) |
104 | else: | 104 | else: |
105 | logger.debug(1, 'No matching branches (%s) in index file(s)' % branches) | 105 | logger.debug('No matching branches (%s) in index file(s)' % branches) |
106 | # No matching branches.. return nothing... | 106 | # No matching branches.. return nothing... |
107 | return | 107 | return |
108 | 108 | ||
@@ -120,7 +120,7 @@ class RestApiPlugin(layerindexlib.plugin.IndexPlugin): | |||
120 | load_cache(up.path, index, branches) | 120 | load_cache(up.path, index, branches) |
121 | return index | 121 | return index |
122 | 122 | ||
123 | logger.debug(1, 'Loading from dir %s...' % (up.path)) | 123 | logger.debug('Loading from dir %s...' % (up.path)) |
124 | for (dirpath, _, filenames) in os.walk(up.path): | 124 | for (dirpath, _, filenames) in os.walk(up.path): |
125 | for filename in filenames: | 125 | for filename in filenames: |
126 | if not filename.endswith('.json'): | 126 | if not filename.endswith('.json'): |
@@ -144,7 +144,7 @@ class RestApiPlugin(layerindexlib.plugin.IndexPlugin): | |||
144 | def _get_json_response(apiurl=None, username=None, password=None, retry=True): | 144 | def _get_json_response(apiurl=None, username=None, password=None, retry=True): |
145 | assert apiurl is not None | 145 | assert apiurl is not None |
146 | 146 | ||
147 | logger.debug(1, "fetching %s" % apiurl) | 147 | logger.debug("fetching %s" % apiurl) |
148 | 148 | ||
149 | up = urlparse(apiurl) | 149 | up = urlparse(apiurl) |
150 | 150 | ||
@@ -163,9 +163,9 @@ class RestApiPlugin(layerindexlib.plugin.IndexPlugin): | |||
163 | parsed = json.loads(res.read().decode('utf-8')) | 163 | parsed = json.loads(res.read().decode('utf-8')) |
164 | except ConnectionResetError: | 164 | except ConnectionResetError: |
165 | if retry: | 165 | if retry: |
166 | logger.debug(1, "%s: Connection reset by peer. Retrying..." % url) | 166 | logger.debug("%s: Connection reset by peer. Retrying..." % url) |
167 | parsed = _get_json_response(apiurl=up_stripped.geturl(), username=username, password=password, retry=False) | 167 | parsed = _get_json_response(apiurl=up_stripped.geturl(), username=username, password=password, retry=False) |
168 | logger.debug(1, "%s: retry successful.") | 168 | logger.debug("%s: retry successful.") |
169 | else: | 169 | else: |
170 | raise layerindexlib.LayerIndexFetchError('%s: Connection reset by peer. Is there a firewall blocking your connection?' % apiurl) | 170 | raise layerindexlib.LayerIndexFetchError('%s: Connection reset by peer. Is there a firewall blocking your connection?' % apiurl) |
171 | 171 | ||
@@ -207,25 +207,25 @@ class RestApiPlugin(layerindexlib.plugin.IndexPlugin): | |||
207 | if "*" not in branches: | 207 | if "*" not in branches: |
208 | filter = "?filter=name:%s" % "OR".join(branches) | 208 | filter = "?filter=name:%s" % "OR".join(branches) |
209 | 209 | ||
210 | logger.debug(1, "Loading %s from %s" % (branches, index.apilinks['branches'])) | 210 | logger.debug("Loading %s from %s" % (branches, index.apilinks['branches'])) |
211 | 211 | ||
212 | # The link won't include username/password, so pull it from the original url | 212 | # The link won't include username/password, so pull it from the original url |
213 | pindex['branches'] = _get_json_response(index.apilinks['branches'] + filter, | 213 | pindex['branches'] = _get_json_response(index.apilinks['branches'] + filter, |
214 | username=up.username, password=up.password) | 214 | username=up.username, password=up.password) |
215 | if not pindex['branches']: | 215 | if not pindex['branches']: |
216 | logger.debug(1, "No valid branches (%s) found at url %s." % (branch, url)) | 216 | logger.debug("No valid branches (%s) found at url %s." % (branch, url)) |
217 | return index | 217 | return index |
218 | index.add_raw_element("branches", layerindexlib.Branch, pindex['branches']) | 218 | index.add_raw_element("branches", layerindexlib.Branch, pindex['branches']) |
219 | 219 | ||
220 | # Load all of the layerItems (these can not be easily filtered) | 220 | # Load all of the layerItems (these can not be easily filtered) |
221 | logger.debug(1, "Loading %s from %s" % ('layerItems', index.apilinks['layerItems'])) | 221 | logger.debug("Loading %s from %s" % ('layerItems', index.apilinks['layerItems'])) |
222 | 222 | ||
223 | 223 | ||
224 | # The link won't include username/password, so pull it from the original url | 224 | # The link won't include username/password, so pull it from the original url |
225 | pindex['layerItems'] = _get_json_response(index.apilinks['layerItems'], | 225 | pindex['layerItems'] = _get_json_response(index.apilinks['layerItems'], |
226 | username=up.username, password=up.password) | 226 | username=up.username, password=up.password) |
227 | if not pindex['layerItems']: | 227 | if not pindex['layerItems']: |
228 | logger.debug(1, "No layers were found at url %s." % (url)) | 228 | logger.debug("No layers were found at url %s." % (url)) |
229 | return index | 229 | return index |
230 | index.add_raw_element("layerItems", layerindexlib.LayerItem, pindex['layerItems']) | 230 | index.add_raw_element("layerItems", layerindexlib.LayerItem, pindex['layerItems']) |
231 | 231 | ||
@@ -235,13 +235,13 @@ class RestApiPlugin(layerindexlib.plugin.IndexPlugin): | |||
235 | for branch in index.branches: | 235 | for branch in index.branches: |
236 | filter = "?filter=branch__name:%s" % index.branches[branch].name | 236 | filter = "?filter=branch__name:%s" % index.branches[branch].name |
237 | 237 | ||
238 | logger.debug(1, "Loading %s from %s" % ('layerBranches', index.apilinks['layerBranches'])) | 238 | logger.debug("Loading %s from %s" % ('layerBranches', index.apilinks['layerBranches'])) |
239 | 239 | ||
240 | # The link won't include username/password, so pull it from the original url | 240 | # The link won't include username/password, so pull it from the original url |
241 | pindex['layerBranches'] = _get_json_response(index.apilinks['layerBranches'] + filter, | 241 | pindex['layerBranches'] = _get_json_response(index.apilinks['layerBranches'] + filter, |
242 | username=up.username, password=up.password) | 242 | username=up.username, password=up.password) |
243 | if not pindex['layerBranches']: | 243 | if not pindex['layerBranches']: |
244 | logger.debug(1, "No valid layer branches (%s) found at url %s." % (branches or "*", url)) | 244 | logger.debug("No valid layer branches (%s) found at url %s." % (branches or "*", url)) |
245 | return index | 245 | return index |
246 | index.add_raw_element("layerBranches", layerindexlib.LayerBranch, pindex['layerBranches']) | 246 | index.add_raw_element("layerBranches", layerindexlib.LayerBranch, pindex['layerBranches']) |
247 | 247 | ||
@@ -256,7 +256,7 @@ class RestApiPlugin(layerindexlib.plugin.IndexPlugin): | |||
256 | ("distros", layerindexlib.Distro)]: | 256 | ("distros", layerindexlib.Distro)]: |
257 | if lName not in load: | 257 | if lName not in load: |
258 | continue | 258 | continue |
259 | logger.debug(1, "Loading %s from %s" % (lName, index.apilinks[lName])) | 259 | logger.debug("Loading %s from %s" % (lName, index.apilinks[lName])) |
260 | 260 | ||
261 | # The link won't include username/password, so pull it from the original url | 261 | # The link won't include username/password, so pull it from the original url |
262 | pindex[lName] = _get_json_response(index.apilinks[lName] + filter, | 262 | pindex[lName] = _get_json_response(index.apilinks[lName] + filter, |
@@ -283,7 +283,7 @@ class RestApiPlugin(layerindexlib.plugin.IndexPlugin): | |||
283 | if up.scheme != 'file': | 283 | if up.scheme != 'file': |
284 | raise layerindexlib.plugin.LayerIndexPluginUrlError(self.type, url) | 284 | raise layerindexlib.plugin.LayerIndexPluginUrlError(self.type, url) |
285 | 285 | ||
286 | logger.debug(1, "Storing to %s..." % up.path) | 286 | logger.debug("Storing to %s..." % up.path) |
287 | 287 | ||
288 | try: | 288 | try: |
289 | layerbranches = index.layerBranches | 289 | layerbranches = index.layerBranches |
@@ -299,12 +299,12 @@ class RestApiPlugin(layerindexlib.plugin.IndexPlugin): | |||
299 | if getattr(index, objects)[obj].layerbranch_id == layerbranchid: | 299 | if getattr(index, objects)[obj].layerbranch_id == layerbranchid: |
300 | filtered.append(getattr(index, objects)[obj]._data) | 300 | filtered.append(getattr(index, objects)[obj]._data) |
301 | except AttributeError: | 301 | except AttributeError: |
302 | logger.debug(1, 'No obj.layerbranch_id: %s' % objects) | 302 | logger.debug('No obj.layerbranch_id: %s' % objects) |
303 | # No simple filter method, just include it... | 303 | # No simple filter method, just include it... |
304 | try: | 304 | try: |
305 | filtered.append(getattr(index, objects)[obj]._data) | 305 | filtered.append(getattr(index, objects)[obj]._data) |
306 | except AttributeError: | 306 | except AttributeError: |
307 | logger.debug(1, 'No obj._data: %s %s' % (objects, type(obj))) | 307 | logger.debug('No obj._data: %s %s' % (objects, type(obj))) |
308 | filtered.append(obj) | 308 | filtered.append(obj) |
309 | return filtered | 309 | return filtered |
310 | 310 | ||