summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJaeyoon Jung <jaeyoon.jung@lge.com>2025-04-14 11:41:10 +0900
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-04-17 11:03:22 +0100
commit4edf8615a68949b87dde6c90f5602a1127d6c2d7 (patch)
tree0c5ccb94783f700fbb679f882fbb6a7a2fa80104 /scripts
parent35807e8f634ce86bc77b3461cb0deb466c08a9d2 (diff)
downloadpoky-4edf8615a68949b87dde6c90f5602a1127d6c2d7.tar.gz
send-error-report: Respect URL scheme in server name if exists
If a server name with -s or --server flag contains the URL scheme such as http:// or https:// it takes precedence over --no-ssl flag. This will allow us to use the same command line option for different servers with http:// and https:// schemes mixed. (From OE-Core rev: e8ce179cf5d82b41bdf7f05013c1b6d58001c336) Signed-off-by: Jaeyoon Jung <jaeyoon.jung@lge.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/send-error-report30
1 files changed, 23 insertions, 7 deletions
diff --git a/scripts/send-error-report b/scripts/send-error-report
index cfbcaa52cb..f8bf51a491 100755
--- a/scripts/send-error-report
+++ b/scripts/send-error-report
@@ -65,7 +65,7 @@ def edit_content(json_file_path):
65 65
66def prepare_data(args): 66def prepare_data(args):
67 # attempt to get the max_log_size from the server's settings 67 # attempt to get the max_log_size from the server's settings
68 max_log_size = getPayloadLimit(args.protocol+args.server+"/ClientPost/JSON") 68 max_log_size = getPayloadLimit(args.server+"/ClientPost/JSON")
69 69
70 if not os.path.isfile(args.error_file): 70 if not os.path.isfile(args.error_file):
71 log.error("No data file found.") 71 log.error("No data file found.")
@@ -135,9 +135,9 @@ def send_data(data, args):
135 headers={'Content-type': 'application/json', 'User-Agent': "send-error-report/"+version} 135 headers={'Content-type': 'application/json', 'User-Agent': "send-error-report/"+version}
136 136
137 if args.json: 137 if args.json:
138 url = args.protocol+args.server+"/ClientPost/JSON/" 138 url = args.server+"/ClientPost/JSON/"
139 else: 139 else:
140 url = args.protocol+args.server+"/ClientPost/" 140 url = args.server+"/ClientPost/"
141 141
142 req = urllib.request.Request(url, data=data, headers=headers) 142 req = urllib.request.Request(url, data=data, headers=headers)
143 try: 143 try:
@@ -149,6 +149,23 @@ def send_data(data, args):
149 print(response.read().decode('utf-8')) 149 print(response.read().decode('utf-8'))
150 150
151 151
152def determine_server_url(args):
153 # Get the error report server from an argument
154 server = args.server or 'errors.yoctoproject.org'
155
156 # The scheme contained in the given URL takes precedence over --no-ssl flag
157 scheme = args.protocol
158 if server.startswith('http://'):
159 server = server[len('http://'):]
160 scheme = 'http://'
161 elif server.startswith('https://'):
162 server = server[len('https://'):]
163 scheme = 'https://'
164
165 # Construct the final URL
166 return f"{scheme}{server}"
167
168
152if __name__ == '__main__': 169if __name__ == '__main__':
153 arg_parse = argparse_oe.ArgumentParser(description="This scripts will send an error report to your specified error-report-web server.") 170 arg_parse = argparse_oe.ArgumentParser(description="This scripts will send an error report to your specified error-report-web server.")
154 171
@@ -164,8 +181,7 @@ if __name__ == '__main__':
164 arg_parse.add_argument("-s", 181 arg_parse.add_argument("-s",
165 "--server", 182 "--server",
166 help="Server to send error report to", 183 help="Server to send error report to",
167 type=str, 184 type=str)
168 default="errors.yoctoproject.org")
169 185
170 arg_parse.add_argument("-e", 186 arg_parse.add_argument("-e",
171 "--email", 187 "--email",
@@ -195,10 +211,10 @@ if __name__ == '__main__':
195 dest="protocol", 211 dest="protocol",
196 action="store_const", const="http://", default="https://") 212 action="store_const", const="http://", default="https://")
197 213
198
199
200 args = arg_parse.parse_args() 214 args = arg_parse.parse_args()
201 215
216 args.server = determine_server_url(args)
217
202 if (args.json == False): 218 if (args.json == False):
203 print("Preparing to send errors to: "+args.server) 219 print("Preparing to send errors to: "+args.server)
204 220