def total_time_spent_by(self, who, is_employee): who = 'E' + who if is_employee else 'G' + who s = Storage(self.name, self.token, True, True) if s.error: print(0) return s.verify_log() room_numbers, rooms, person_names, persons, current_timestamp = s.get_stats() if not who in person_names: print(0) return person = person_names[who] if person.is_employee != is_employee: libgeneric.print_error_and_exit("invalid") total_time = person.time_in_gallery if person.gallery_timestamp >= 0: total_time += (current_timestamp - person.gallery_timestamp) print(total_time)
def state(self): s = Storage(self.name, self.token, True) s.verify_log() room_numbers, rooms, person_names, persons, _ = s.get_stats() if persons: res = [p.name[1:] for p in persons if p.gallery_timestamp >= 0 and p.is_employee] res.sort() print(','.join(res)) res = [p.name[1:] for p in persons if p.gallery_timestamp >= 0 and p.is_employee == False] res.sort() print(','.join(res)) else: print() room_dir = {} for room in rooms: room_dir[room.number] = [] for person in persons: if person.room >= 0: room_dir[rooms[person.room].number].append(person.name[1:]) rooms_and_attendees = [] for number, people in room_dir.items(): people.sort() rooms_and_attendees.append( (number, ','.join(people)) ) rooms_and_attendees.sort(key=lambda e : e[0]) for rooms in rooms_and_attendees: if rooms[1] != '': print(str(rooms[0]) + ": " + rooms[1])