Skip to content
Snippets Groups Projects
Commit d1b53fe5 authored by Mattia Mancini's avatar Mattia Mancini
Browse files

Story SW-300: cleaning up code to adhere to pep standards

parent 51033e6b
No related branches found
No related tags found
2 merge requests!89Monitoring maintenance Epic branch merge,!1Resolve OSB-13 "Monitoringmaintenance "
......@@ -105,9 +105,9 @@ def get_query_string_for_time_limit(from_date, to_date):
else:
date = to_date
query += '&start_time__year__lte=%d' % (date.year)
query += '&start_time__month__lte=%d' % (date.month)
query += '&start_time__day__lte=%d' % (date.day)
query += '&start_time__year__lte=%d' % (date.year,)
query += '&start_time__month__lte=%d' % (date.month,)
query += '&start_time__day__lte=%d' % (date.day,)
except ValueError:
logger.error('format of to date not valid; YYYY-MM-DD es. 2016-15-12')
......@@ -190,17 +190,18 @@ def reformat_values(item):
return str(item)
def print_out_station_test_summary(station_test, id):
def print_out_station_test_summary(station_test, idx):
"""
Prints the summary of the station test
:param station_test: dict containing the results of the station test
:param idx: index of the current station test
:return:
"""
summary_fields = ['station_name', 'station_type', 'start_time', 'end_time', 'performed_checks']
summary_header = ['Name', 'Type', 'Start', 'End', 'Checks']
values = [reformat_values(station_test[item]) for item in summary_fields]
print()
print('Station test #{}'.format(id))
print('Station test #{}'.format(idx))
table_width = 200
terminal = blessings.Terminal()
if terminal.does_styling:
......@@ -275,8 +276,8 @@ def print_out_component_errors(station_test):
tile_errors = error.get('tile_errors', None)
if tile_errors:
for i, tile_error in enumerate(tile_errors):
tile_error_string = 'Tile error #{} on tile id {}'.format(i, tile_error['tile_id'])
for k, tile_error in enumerate(tile_errors):
tile_error_string = 'Tile error #{} on tile id {}'.format(k, tile_error['tile_id'])
print(tile_error_indentation + tile_error_string)
print(tile_error_indentation + '-' * len(tile_error_string))
......@@ -294,7 +295,7 @@ def rtsm_sort_errors(errors):
rcu
time
:param component_errors:
:param errors: RTSM errors to be sorted
:return:
"""
sorted_components = sorted(errors, key=itemgetter('rcu', 'error_type', 'time'))
......@@ -313,11 +314,10 @@ def print_out_rtsm_summary(rtsm_results):
table_width = terminal.width
table = beautifultable.BeautifulTable(max_width=table_width)
header = ['observation_id', 'station_name', 'start_time', 'end_time',
'component_id', 'error_type','start_frequency', 'stop_frequency',
'component_id', 'error_type', 'start_frequency', 'stop_frequency',
'mode', 'percentage']
table.column_headers = ['observation_id', 'station_name', 'start_time', 'end_time',
'component_id', 'error_type','start_frequency', 'stop_frequency',
'mode', 'percentage']
table.column_headers = header
for rtsm_result in sorted(rtsm_results, key=itemgetter('observation_id')):
obs_id = rtsm_result['observation_id']
station_name = rtsm_result['station_name']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment