def get_columns_from_tuple(db_tuple, counter): """ load the columns (list of strings) from a db_tuple """ db_data = DBData() log_id = db_tuple[0] log_date = db_tuple[1].strftime('%Y-%m-%d') db_data.description = db_tuple[2] db_data.feedback = '' db_data.type = '' db_data.wind_speed = db_tuple[3] db_data.rating = db_tuple[4] db_data.video_url = db_tuple[5] db_data_gen = get_generated_db_data_from_log(log_id, con, cur) if db_data_gen is None: return None # bring it into displayable form ver_sw = db_data_gen.ver_sw if len(ver_sw) > 10: ver_sw = ver_sw[:6] if len(db_data_gen.ver_sw_release) > 0: try: release_split = db_data_gen.ver_sw_release.split() release_type = int(release_split[1]) if release_type == 255: # it's a release ver_sw = release_split[0] except: pass airframe_data = get_airframe_data(db_data_gen.sys_autostart_id) if airframe_data is None: airframe = db_data_gen.sys_autostart_id else: airframe = airframe_data['name'] flight_modes = ', '.join([ flight_modes_table[x][0] for x in db_data_gen.flight_modes if x in flight_modes_table ]) m, s = divmod(db_data_gen.duration_s, 60) h, m = divmod(m, 60) duration_str = '{:d}:{:02d}:{:02d}'.format(h, m, s) # make sure to break long descriptions w/o spaces (otherwise they # mess up the layout) description = html_long_word_force_break(db_data.description) return [ counter, '<a href="plot_app?log=' + log_id + '">' + log_date + '</a>', description, db_data_gen.mav_type, airframe, db_data_gen.sys_hw, ver_sw, duration_str, db_data.rating_str(), db_data_gen.num_logged_errors, flight_modes ]
def get_columns_from_tuple(db_tuple, counter): """ load the columns (list of strings) from a db_tuple """ db_data = DBData() log_id = db_tuple[0] log_date = db_tuple[1].strftime('%Y-%m-%d') db_data.description = db_tuple[2] db_data.feedback = '' db_data.type = '' db_data.wind_speed = db_tuple[3] db_data.rating = db_tuple[4] db_data.video_url = db_tuple[5] db_data_gen = get_generated_db_data_from_log(log_id, con, cur) if db_data_gen is None: return None # bring it into displayable form ver_sw = db_data_gen.ver_sw if len(ver_sw) > 10: ver_sw = ver_sw[:6] if len(db_data_gen.ver_sw_release) > 0: try: release_split = db_data_gen.ver_sw_release.split() release_type = int(release_split[1]) if release_type == 255: # it's a release ver_sw = release_split[0] except: pass airframe_data = get_airframe_data(db_data_gen.sys_autostart_id) if airframe_data is None: airframe = db_data_gen.sys_autostart_id else: airframe = airframe_data['name'] flight_modes = ', '.join([ flight_modes_table[x][0] for x in db_data_gen.flight_modes if x in flight_modes_table ]) m, s = divmod(db_data_gen.duration_s, 60) h, m = divmod(m, 60) duration_str = '{:d}:{:02d}:{:02d}'.format(h, m, s) # make sure to break long descriptions w/o spaces (otherwise they # mess up the layout) description = html_long_word_force_break(db_data.description) search_only_columns = [] if db_data_gen.ver_sw is not None: search_only_columns.append(db_data_gen.ver_sw) if db_data_gen.ver_sw_release is not None: search_only_columns.append(db_data_gen.ver_sw_release) if db_data_gen.vehicle_uuid is not None: search_only_columns.append(db_data_gen.vehicle_uuid) image_col = '<div class="no_map_overview"> Not rendered / No GPS </div>' image_filename = os.path.join(get_overview_img_filepath(), log_id + '.png') if os.path.exists(image_filename): image_col = '<img class="map_overview" src="/overview_img/' image_col += log_id + '.png" alt="Overview Image Load Failed" height=50/>' return Columns([ counter, '<a href="plot_app?log=' + log_id + '">' + log_date + '</a>', image_col, description, db_data_gen.mav_type, airframe, db_data_gen.sys_hw, ver_sw, duration_str, db_data.rating_str(), db_data_gen.num_logged_errors, flight_modes ], search_only_columns)