summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorThomas Perrot <thomas.perrot@bootlin.com>2025-04-16 12:01:49 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-04-20 10:11:16 +0100
commitcc77fb6cf549d5175d02d15b8cd41786833b9e6d (patch)
tree3f09d8f732ef514530b3b98179d10f08227d0612 /scripts
parent2af4e73f2fbfe1eda013da139054fc090b5d1556 (diff)
downloadpoky-cc77fb6cf549d5175d02d15b8cd41786833b9e6d.tar.gz
send-error-report: improve debugging
- add a debug mode - print the request and the response when an error occurs. (From OE-Core rev: 71635a36c03ea5ac8dcc678d7991676f4b9d0ff5) Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/send-error-report28
1 files changed, 25 insertions, 3 deletions
diff --git a/scripts/send-error-report b/scripts/send-error-report
index efb7e9630f..699ffb797c 100755
--- a/scripts/send-error-report
+++ b/scripts/send-error-report
@@ -6,6 +6,7 @@
6# Copyright (C) 2013 Intel Corporation 6# Copyright (C) 2013 Intel Corporation
7# Author: Andreea Proca <andreea.b.proca@intel.com> 7# Author: Andreea Proca <andreea.b.proca@intel.com>
8# Author: Michael Wood <michael.g.wood@intel.com> 8# Author: Michael Wood <michael.g.wood@intel.com>
9# Author: Thomas Perrot <thomas.perrot@bootlin.com>
9# 10#
10# SPDX-License-Identifier: GPL-2.0-only 11# SPDX-License-Identifier: GPL-2.0-only
11# 12#
@@ -22,7 +23,7 @@ scripts_lib_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'li
22sys.path.insert(0, scripts_lib_path) 23sys.path.insert(0, scripts_lib_path)
23import argparse_oe 24import argparse_oe
24 25
25version = "0.3" 26version = "0.4"
26 27
27log = logging.getLogger("send-error-report") 28log = logging.getLogger("send-error-report")
28logging.basicConfig(format='%(levelname)s: %(message)s') 29logging.basicConfig(format='%(levelname)s: %(message)s')
@@ -140,13 +141,25 @@ def send_data(data, args):
140 url = args.server+"/ClientPost/" 141 url = args.server+"/ClientPost/"
141 142
142 req = urllib.request.Request(url, data=data, headers=headers) 143 req = urllib.request.Request(url, data=data, headers=headers)
144
145 if args.debug:
146 log.debug(f"Request URL: {url}")
147 log.debug(f"Request Headers: {headers}")
148 log.debug(f"Request Data: {data.decode('utf-8')}")
149
143 try: 150 try:
144 response = urllib.request.urlopen(req) 151 response = urllib.request.urlopen(req)
145 except urllib.error.HTTPError as e: 152 except urllib.error.HTTPError as e:
146 logging.error(str(e)) 153 log.error(f"HTTP Error {e.code}: {e.reason}")
154 log.debug(f"Response Content: {e.read().decode('utf-8')}")
147 sys.exit(1) 155 sys.exit(1)
148 156
149 print(response.read().decode('utf-8')) 157 if args.debug:
158 log.debug(f"Response Status: {response.status}")
159 log.debug(f"Response Headers: {response.getheaders()}")
160 log.debug(f"Response Content: {response.read().decode('utf-8')}")
161 else:
162 print(response.read().decode('utf-8'))
150 163
151 164
152def validate_server_url(args): 165def validate_server_url(args):
@@ -201,6 +214,11 @@ if __name__ == '__main__':
201 help="Return the result in json format, silences all other output", 214 help="Return the result in json format, silences all other output",
202 action="store_true") 215 action="store_true")
203 216
217 arg_parse.add_argument("-d",
218 "--debug",
219 help="Enable debug mode to print request/response details",
220 action="store_true")
221
204 args = arg_parse.parse_args() 222 args = arg_parse.parse_args()
205 223
206 args.server = validate_server_url(args) 224 args.server = validate_server_url(args)
@@ -208,6 +226,10 @@ if __name__ == '__main__':
208 if (args.json == False): 226 if (args.json == False):
209 print("Preparing to send errors to: "+args.server) 227 print("Preparing to send errors to: "+args.server)
210 228
229 # Enable debugging if requested
230 if args.debug:
231 log.setLevel(logging.DEBUG)
232
211 data = prepare_data(args) 233 data = prepare_data(args)
212 send_data(data, args) 234 send_data(data, args)
213 235