diff options
-rwxr-xr-x | scripts/send-error-report | 30 |
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 | ||
66 | def prepare_data(args): | 66 | def 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 | ||
152 | def 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 | |||
152 | if __name__ == '__main__': | 169 | if __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 | ||