def get_property(person, key): assert isinstance(person, Person) if key == _('Start'): result = race().find_person_result(person) if result: return time_to_hhmmss(result.get_start_time()) else: return time_to_hhmmss(person.start_time) elif key == _('Finish'): result = race().find_person_result(person) if result: return time_to_hhmmss(result.get_finish_time()) elif key == _('Result'): result = race().find_person_result(person) if result: return result.get_result() elif key == _('Credit'): result = race().find_person_result(person) if result: return time_to_hhmmss(result.get_credit_time()) else: return '00:00:00' elif key == _('Penalty time'): result = race().find_person_result(person) if result: return time_to_hhmmss(result.get_penalty_time()) else: return '00:00:00' elif key == _('Penalty legs'): result = race().find_person_result(person) if result and result.penalty_laps: return str(result.penalty_laps) elif key == _('Card number'): if person.card_number: return str(person.card_number) elif key == _('Group'): if person.group: return person.group.name elif key == _('Team'): if person.organization: return person.organization.name elif key == _('Qualification'): return person.qual.get_title() elif key == _('Bib'): return str(person.bib) elif key == _('Comment'): return str(person.comment) return ''
def backup_data(card_data): text = 'start\n{}\n{}\n{}\n'.format( card_data['card_number'], time_to_hhmmss(card_data['start']) if card_data['start'] else '', time_to_hhmmss(card_data['finish']) if card_data['finish'] else '', ) text += 'split_start\n' for i in range(len(card_data['punches'])): text += '{} {}\n'.format(card_data['punches'][i][0], time_to_hhmmss(card_data['punches'][i][1])) text += 'split_end\n' text += 'end\n' BackupProcess(text).start()
def get_values_from_object(self, result): i = result person = i.person group = '' team = '' first_name = '' last_name = '' bib = result.get_bib() rented_card = '' if person: is_rented_card = person.is_rented_card or RentCards().exists( i.card_number) first_name = person.name last_name = person.surname if person.group: group = person.group.name if person.organization: team = person.organization.name rented_card = _('Rented card') if is_rented_card else _( 'Rented stub') start = '' if i.get_start_time(): time_accuracy = self.race.get_setting('time_accuracy', 0) start = i.get_start_time().to_str(time_accuracy) finish = '' if i.get_finish_time(): time_accuracy = self.race.get_setting('time_accuracy', 0) finish = i.get_finish_time().to_str(time_accuracy) return [ last_name, first_name, group, team, bib, i.card_number, start, finish, i.get_result(), i.status.get_title(), time_to_hhmmss(i.get_credit_time()), time_to_hhmmss(i.get_penalty_time()), i.penalty_laps, i.get_place(), str(i.system_type), rented_card ]
def send(self, finish): if finish and isinstance(finish, WDBFinish): man = self.current_wdb.find_man_by_number(finish.number) assert isinstance(man, WDBMan) ret = self.url ret += ONLINE_NUMBER + "=" + str(finish.number) ret += "&" + ONLINE_RESULT + "=" + time_to_hhmmss(int_to_otime(man.result)) ret += "&" + ONLINE_FLAG + "=" + str(man.status) ret += "&" + ONLINE_TIME + "=" + str(OTime.now().to_sec() * 100) # WO-compatible time in sec * 100 if self.send_splits: splits = self.get_splits(self.current_wdb, man) ret += "&" + ONLINE_SPLIT + "=" + splits logging.info(ret) res = requests.get(ret)
def get_values_from_object(self, obj): ret = [] person = obj is_rented_card = person.is_rented_card or RentCards().exists( person.card_number) ret.append(person.surname) ret.append(person.name) ret.append(person.sex.get_title()) if person.qual: ret.append(person.qual.get_title()) else: ret.append('') if person.group: ret.append(person.group.name) else: ret.append('') if person.organization: ret.append(person.organization.name) else: ret.append('') ret.append(person.get_year()) ret.append(person.bib) if person.start_time: ret.append(time_to_hhmmss(person.start_time)) else: ret.append('') ret.append(person.start_group) ret.append(person.card_number) ret.append(_('Rented card') if is_rented_card else _('Rented stub')) ret.append(person.comment) ret.append(str(person.world_code) if person.world_code else '') ret.append(str(person.national_code) if person.national_code else '') out_of_comp_status = '' if person.is_out_of_competition: out_of_comp_status = _('o/c') ret.append(out_of_comp_status) ret.append(person.result_count) return ret
text_array = bytes(conn[0:34]).decode().split() bib = text_array[0] result = int_to_time(int(text_array[1])) status = text_array[2] start = int_to_time(int(text_array[4])) byteorder = 'little' punch_qty = int.from_bytes(conn[136:140], byteorder) card_start = int_to_time(int.from_bytes(conn[144:148], byteorder)) card_finish = int_to_time(int.from_bytes(conn[152:156], byteorder)) init_offset = 172 punches = [] for i in range(punch_qty): cp = int.from_bytes(conn[init_offset + i * 8:init_offset + i * 8 + 1], byteorder) time = int_to_time( int.from_bytes( conn[init_offset + i * 8 + 4:init_offset + i * 8 + 8], byteorder)) punches.append((cp, time_to_hhmmss(time))) print("bib=" + bib + " result=" + time_to_hhmmss(result) + " punches=") print(punches) # sendto - responce udp_socket.sendto(b'message received by the server', addr) # udp_socket.close()
def show_splits(self, index): self.resize_event() assert (isinstance(index, QModelIndex)) result = race().results[index.row()] assert isinstance(result, Result) self.result_card_details.clear() self.result_card_finish_edit.setText('') self.result_card_start_edit.setText('') self.result_course_details.clear() self.result_course_details.setLineWrapMode(QTextEdit.NoWrap) self.result_course_name_edit.setText('') self.result_course_length_edit.setText('') if result.is_manual(): return course = None if result.person: course = race().find_course(result) control_codes = [] is_highlight = True if course: assert isinstance(course, Course) is_highlight = not course.is_unknown() for control in course.controls: control_codes.append(str(control.code)) code = '' index = 1 time_accuracy = race().get_setting('time_accuracy', 0) for split in result.splits: str_fmt = '{index:02d} {code} {time} {diff}' if not split.is_correct: str_fmt = '-- {code} {time}' s = str_fmt.format( index=index, code=('(' + str(split.code) + ') ')[:5], time=split.time.to_str(time_accuracy), diff=split.leg_time.to_str(time_accuracy), leg_place=split.leg_place, speed=split.speed, ) if split.is_correct: index += 1 if split.code == code: s = '<span style="background: red">{}</span>'.format(s) if is_highlight and len( control_codes) and split.code not in control_codes: s = '<span style="background: yellow">{}</span>'.format(s) self.result_card_details.append(s) code = split.code self.result_card_finish_edit.setText( time_to_hhmmss(result.get_finish_time())) self.result_card_start_edit.setText( time_to_hhmmss(result.get_start_time())) split_codes = [] for split in result.splits: split_codes.append(split.code) if course: index = 1 for control in course.controls: assert control, CourseControl s = '{index:02d} ({code}) {length}'.format( index=index, code=control.code, length=control.length if control.length else '') if is_highlight and str(control.code) not in split_codes: s = '<span style="background: yellow">{}</span>'.format(s) self.result_course_details.append(s) index += 1 self.result_course_name_edit.setText(course.name) self.result_course_length_edit.setText(str(course.length))