| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import cgi | 5 import cgi |
| 6 import json | 6 import json |
| 7 import os | 7 import os |
| 8 import time | 8 import time |
| 9 import urllib | 9 import urllib |
| 10 | 10 |
| 11 import https |
| 12 |
| 11 | 13 |
| 12 INFINITY = float('inf') | 14 INFINITY = float('inf') |
| 13 | 15 |
| 14 | 16 |
| 15 def NormalizePathLinux(path): | 17 def NormalizePathLinux(path): |
| 16 """Normalizes linux path. | 18 """Normalizes linux path. |
| 17 | 19 |
| 18 Args: | 20 Args: |
| 19 path: A string representing a path. | 21 path: A string representing a path. |
| 20 | 22 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 """Retrieves raw data from URL, tries 10 times. | 91 """Retrieves raw data from URL, tries 10 times. |
| 90 | 92 |
| 91 Args: | 93 Args: |
| 92 url: URL to get data from. | 94 url: URL to get data from. |
| 93 retries: Number of times to retry connection. | 95 retries: Number of times to retry connection. |
| 94 sleep_time: Time in seconds to wait before retrying connection. | 96 sleep_time: Time in seconds to wait before retrying connection. |
| 95 | 97 |
| 96 Returns: | 98 Returns: |
| 97 None if the data retrieval fails, or the raw data. | 99 None if the data retrieval fails, or the raw data. |
| 98 """ | 100 """ |
| 99 data = None | 101 count = 0 |
| 100 for i in range(retries): | 102 while True: |
| 103 count += 1 |
| 101 # Retrieves data from URL. | 104 # Retrieves data from URL. |
| 102 try: | 105 try: |
| 103 data = urllib.urlopen(url) | 106 if url.startswith('https://'): |
| 104 | 107 return https.SendRequest(url) |
| 105 # If retrieval is successful, return the data. | 108 else: |
| 106 if data: | 109 return urllib.urlopen(url).read() |
| 107 return data.read() | |
| 108 | |
| 109 # If retrieval fails, try after sleep_time second. | |
| 110 except IOError: | 110 except IOError: |
| 111 time.sleep(sleep_time) | 111 if count < retries: |
| 112 continue | 112 # If retrieval fails, try after sleep_time second. |
| 113 time.sleep(sleep_time) |
| 114 else: |
| 115 break |
| 113 | 116 |
| 114 # Return None if it fails to read data from URL 'retries' times. | 117 # Return None if it fails to read data from URL 'retries' times. |
| 115 return None | 118 return None |
| 116 | 119 |
| 117 | 120 |
| 118 def FindMinLineDistance(crashed_line_list, changed_line_numbers): | 121 def FindMinLineDistance(crashed_line_list, changed_line_numbers): |
| 119 """Calculates how far the changed line is from one of the crashes. | 122 """Calculates how far the changed line is from one of the crashes. |
| 120 | 123 |
| 121 Finds the minimum distance between the lines that the file crashed on | 124 Finds the minimum distance between the lines that the file crashed on |
| 122 and the lines that the file changed. For example, if the file crashed on | 125 and the lines that the file changed. For example, if the file crashed on |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 intersected_line = changed_line | 279 intersected_line = changed_line |
| 277 | 280 |
| 278 # Avoid adding the same line twice. | 281 # Avoid adding the same line twice. |
| 279 if intersected_line not in line_intersection: | 282 if intersected_line not in line_intersection: |
| 280 line_intersection.append(intersected_line) | 283 line_intersection.append(intersected_line) |
| 281 stack_frame_index_intersection.append(stack_frame_index) | 284 stack_frame_index_intersection.append(stack_frame_index) |
| 282 | 285 |
| 283 break | 286 break |
| 284 | 287 |
| 285 return (line_intersection, stack_frame_index_intersection) | 288 return (line_intersection, stack_frame_index_intersection) |
| OLD | NEW |