Skip to content

Commit d9f85fb

Browse files
luvwinniebkueng
authored andcommitted
Change app/Dockerfile to use ubuntu:focal, ignore some special cases following the pylint warning guide to fix CI/CD pylint test.
1 parent 27c9573 commit d9f85fb

13 files changed

+24
-29
lines changed

app/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:18.04
1+
FROM ubuntu:focal
22

33
COPY requirements.txt requirements.txt
44

app/plot_app/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import configparser
33
import os
44

5-
#pylint: disable=bad-whitespace, invalid-name
5+
#pylint: disable=invalid-name
66

77
# load the config
88
_conf = configparser.ConfigParser()

app/plot_app/helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def load_ulog_file(file_name):
318318
# catch all other exceptions and turn them into an ULogException
319319
except Exception as error:
320320
traceback.print_exception(*sys.exc_info())
321-
raise ULogException()
321+
raise ULogException() from error
322322

323323
# filter messages with timestamp = 0 (these are invalid).
324324
# The better way is not to publish such messages in the first place, and fix

app/plot_app/pid_analysis_plots.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _resample(time_array, data, desired_time):
116116
[time_controls[0], time_controls[-1]])
117117

118118
p = data_plot.bokeh_plot
119-
p.patch(time_controls, thrust, line_width=0, fill_color='#555555',
119+
p.patch(time_controls, thrust, line_width=0, fill_color='#555555', # pylint: disable=too-many-function-args
120120
fill_alpha=0.4, alpha=0, legend_label='Thrust [0, {:}]'.format(thrust_max))
121121

122122
data_plot.change_dataset(rate_topic_name)

app/plot_app/plotting.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ def __init__(self, data, config, data_name, x_axis_label=None,
732732
y_axis_label=None, title=None, plot_height='normal',
733733
equal_aspect=True):
734734

735-
super(DataPlot2D, self).__init__(data, config, data_name,
735+
super().__init__(data, config, data_name,
736736
x_axis_label=x_axis_label,
737737
y_axis_label=y_axis_label,
738738
title=title, plot_height=plot_height)
@@ -796,7 +796,7 @@ def __init__(self, data, config, data_name, x_axis_label=None,
796796
y_axis_label=None, title=None, plot_height='small',
797797
x_range=None, y_range=None, topic_instance=0):
798798

799-
super(DataPlotSpec, self).__init__(data, config, data_name, x_axis_label=x_axis_label,
799+
super().__init__(data, config, data_name, x_axis_label=x_axis_label,
800800
y_axis_label=y_axis_label, title=title, plot_height=plot_height,
801801
x_range=x_range, y_range=y_range, topic_instance=topic_instance)
802802

@@ -898,7 +898,7 @@ def __init__(self, data, config, data_name,
898898
title=None, plot_height='small',
899899
x_range=None, y_range=None, topic_instance=0):
900900

901-
super(DataPlotFFT, self).__init__(data, config, data_name, x_axis_label='Hz',
901+
super().__init__(data, config, data_name, x_axis_label='Hz',
902902
y_axis_label='Amplitude * 1000', title=title, plot_height=plot_height,
903903
x_range=x_range, y_range=y_range, topic_instance=topic_instance)
904904
self._use_time_formatter = False
@@ -955,12 +955,11 @@ def add_graph(self, field_names, colors, legends):
955955
step_size = int(len(fft_plot_values) / max_num_data_points)
956956
fft_plot_values = fft_plot_values[::step_size]
957957
freqs_plot = freqs_plot[::step_size]
958-
self._p.line(freqs_plot, fft_plot_values,
959-
line_color=color, line_width=2, legend_label=legend,
960-
alpha=0.8)
958+
self._p.line(freqs_plot, fft_plot_values, # pylint: disable=too-many-function-args
959+
line_color=color, line_width=2, legend_label=legend, alpha=0.8)
961960
# plot the mean lines above the fft graphs
962961
for fft_values, mean_fft_value, legend, color in plot_data:
963-
self._p.line([mean_start_freq, np.max(freqs)],
962+
self._p.line([mean_start_freq, np.max(freqs)], # pylint: disable=too-many-function-args
964963
[mean_fft_value, mean_fft_value],
965964
line_color=color, line_width=2, legend_label=legend)
966965

app/plot_app/statistics_plots.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ def _plot_public_data_statistics(self, all_data, version_attr_name,
543543
x = data_hours['x']
544544
x2 = np.hstack((x[::-1], x))
545545
for i in range(len(all_data)):
546-
area.patch(x2, stacked_patches[i], color=colors[i],
546+
area.patch(x2, stacked_patches[i], color=colors[i], # pylint: disable=too-many-function-args
547547
legend_label=label_cb(all_data[i], False), alpha=0.8, line_color=None)
548548

549549
if area.legend:

app/plot_app/templates/browse.html

-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ <h3>Browse public Log Files</h3>
5050
<script type="text/javascript">
5151

5252
$(document).ready(function() {
53-
console.log("test");
5453
$('#logs_table').DataTable({
5554
{% if initial_search %}
5655
"search": {
@@ -85,7 +84,6 @@ <h3>Browse public Log Files</h3>
8584
"ajax": "browse_data_retrieval",
8685
});
8786
var table = $('#logs_table').DataTable();
88-
console.log("table!",table);
8987
table.on('xhr', function () {
9088

9189
try {
@@ -100,7 +98,6 @@ <h3>Browse public Log Files</h3>
10098
}
10199
window.history.replaceState(null, null, url);
102100
} catch (e) {
103-
console.log("Failed")
104101
}
105102
});
106103

app/tornado_handlers/browse.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ def get_columns_from_tuple(db_tuple, counter):
211211
if columns is None:
212212
continue
213213

214-
if any([search_str in str(column).lower() for column in \
215-
(columns.columns, columns.search_only_columns)]):
214+
if any(search_str in str(column).lower() for column in \
215+
(columns.columns, columns.search_only_columns)):
216216
if data_start <= filtered_counter < data_start + data_length:
217217
json_output['data'].append(columns.columns)
218218
filtered_counter += 1
@@ -244,7 +244,6 @@ def get(self, *args, **kwargs):
244244
template_args = {}
245245

246246
search_str = self.get_argument('search', '').lower()
247-
print("Browse!")
248247
if len(search_str) > 0:
249248
template_args['initial_search'] = json.dumps(search_str)
250249

app/tornado_handlers/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CustomHTTPError(tornado.web.HTTPError):
2929
""" simple class for HTTP exceptions with a custom error message """
3030
def __init__(self, status_code, error_message=None):
3131
self.error_message = error_message
32-
super(CustomHTTPError, self).__init__(status_code, error_message)
32+
super().__init__(status_code, error_message)
3333

3434
class TornadoRequestHandlerBase(tornado.web.RequestHandler):
3535
"""

app/tornado_handlers/download.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ def kml_colors(flight_mode):
108108
style=style,
109109
camera_trigger_topic_name='camera_capture')
110110
shutil.move(temp_file_name, kml_file_name)
111-
except:
111+
except Exception as e:
112112
print('Error creating KML file', sys.exc_info()[0], sys.exc_info()[1])
113-
raise CustomHTTPError(400, 'No Position Data in log')
113+
raise CustomHTTPError(400, 'No Position Data in log') from e
114114

115115

116116
kml_dl_file_name = get_original_filename('track.kml', '.kml')

app/tornado_handlers/multipart_streamer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def __init__(self, streamer, headers, tmp_dir=None):
143143
the temporary file to a different location. If you do not call the
144144
move() method, then the file will be deleted when release() is called.
145145
"""
146-
super(TemporaryFileStreamedPart, self).__init__(streamer, headers)
146+
super().__init__(streamer, headers)
147147
self.is_moved = False
148148
self.is_finalized = False
149149
self.f_out = tempfile.NamedTemporaryFile(dir=tmp_dir, delete=False)
@@ -161,7 +161,7 @@ def finalize(self):
161161
self.f_out.flush()
162162
self.is_finalized = True
163163
finally:
164-
super(TemporaryFileStreamedPart, self).finalize()
164+
super().finalize()
165165

166166
def move(self, file_path):
167167
"""Move the temporary file to a new location.
@@ -189,7 +189,7 @@ def release(self):
189189
self.f_out.close()
190190
os.unlink(self.f_out.name)
191191
finally:
192-
super(TemporaryFileStreamedPart, self).release()
192+
super().release()
193193

194194
def get_payload(self):
195195
"""Load part data from disk and return it.

app/tornado_handlers/three_d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get(self, *args, **kwargs):
4646
400,
4747
'The log does not contain all required topics<br />'
4848
'(vehicle_gps_position, vehicle_global_position, '
49-
'vehicle_attitude)')
49+
'vehicle_attitude)') from error
5050

5151
# manual control setpoint is optional
5252
manual_control_setpoint = None

app/tornado_handlers/upload.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,14 @@ def post(self, *args, **kwargs):
302302
except CustomHTTPError:
303303
raise
304304

305-
except ULogException:
305+
except ULogException as e:
306306
raise CustomHTTPError(
307307
400,
308-
'Failed to parse the file. It is most likely corrupt.')
309-
except:
308+
'Failed to parse the file. It is most likely corrupt.') from e
309+
except Exception as e:
310310
print('Error when handling POST data', sys.exc_info()[0],
311311
sys.exc_info()[1])
312-
raise CustomHTTPError(500)
312+
raise CustomHTTPError(500) from e
313313

314314
finally:
315315
self.multipart_streamer.release_parts()

0 commit comments

Comments
 (0)