def main(): """The main function""" # Setup logger and live socket codenames = [ 'work_estimate', 'work_left', 'work_left_minus_started', 'work_completed', 'work_total' ] logger = ContinuousDataSaver( 'dateplots_hall', credentials_hall.username, credentials_hall.password, codenames ) logger.start() livesocket = LiveSocket('workday', codenames) livesocket.start() try: while True: # Get board status card_counts, times, high_scores = get_board_status() print('Card counts') pprint(card_counts) print('\nTimes') pprint(times) print('\nHigh Scores') pprint(high_scores) # format highscore highscore_str = 'High Score\n----------' if high_scores: largest_name = max(len(name) for name, value in high_scores) for name, value in high_scores: highscore_str += '\n{{: <{}}}: {{:.2f}}'.format(largest_name).format(name, value) # Total work 80 and 10 people total_work = 66.33 estimate = max(total_work - since_9am() * 10, 0) batch = { 'work_estimate': estimate, 'work_left': times['ToDo'] + times['In Progress'], 'work_left_minus_started': times['ToDo'], 'work_completed': times['Done'], 'work_total': sum(times.values()), 'work_highscore': highscore_str, } # Send to live socket and database print('\n##########\nbatch') pprint(batch) livesocket.set_batch_now(batch) batch.pop('work_highscore') for codename, value in batch.items(): logger.save_point_now(codename, value) print('Sent', datetime.datetime.now()) sleep(600) except KeyboardInterrupt: livesocket.stop() logger.stop()
ls = LiveSocket('test socket on 71', ['sine1', 'sine2', 'status', 'cosine1', 'cosine2'], internal_data_pull_socket_port=7999) start = time() count = 0 while True: count += 1 now = time() # Set sines data = { 'sine1': sin(now), 'sine2': sin(now + pi), } ls.set_batch_now(data) # Set cosines if time() - start > 6.28: start = time() ls.reset(['cosine1', 'cosine2']) x = time() - start data = { 'cosine1': [x, cos(x)], 'cosine2': [x, cos(x + pi)], } ls.set_batch(data) if count % 2 == 0: ls.set_point_now('status', 'OK')
def main(): """The main function""" # Setup logger and live socket codenames = [ 'work_estimate', 'work_left', 'work_left_minus_started', 'work_completed', 'work_total' ] logger = ContinuousDataSaver( 'dateplots_hall', credentials_hall.username, credentials_hall.password, codenames ) logger.start() livesocket = LiveSocket('workday', codenames) livesocket.start() try: while True: # Get board status card_counts, times, high_scores = get_board_status() print('Card counts') pprint(card_counts) print('\nTimes') pprint(times) print('\nHigh Scores') pprint(high_scores) # format highscore highscore_str = 'High Score\n----------' if high_scores: largest_name = max(len(name) for name, value in high_scores) for name, value in high_scores: highscore_str += '\n{{: <{}}}: {{:.2f}}'.\ format(largest_name).format(name, value) # Total work 80 and 10 people total_work = 66.33 estimate = max(total_work - since_9am() * 10, 0) batch = { 'work_estimate': estimate, 'work_left': times['ToDo'] + times['In Progress'], 'work_left_minus_started': times['ToDo'], 'work_completed': times['Done'], 'work_total': sum(times.values()), 'work_highscore': highscore_str, } # Send to live socket and database print('\n##########\nbatch') pprint(batch) livesocket.set_batch_now(batch) batch.pop('work_highscore') for codename, value in batch.items(): logger.save_point_now(codename, value) print('Sent', datetime.datetime.now()) sleep(600) except KeyboardInterrupt: livesocket.stop() logger.stop()
['sine1', 'sine2', 'status', 'cosine1', 'cosine2'], internal_data_pull_socket_port=7999) start = time() count = 0 while True: count += 1 now = time() # Set sines data = { 'sine1': sin(now), 'sine2': sin(now + pi), } ls.set_batch_now(data) # Set cosines if time() - start > 6.28: start = time() ls.reset(['cosine1', 'cosine2']) x = time() - start data = { 'cosine1': [x, cos(x)], 'cosine2': [x, cos(x + pi)], } ls.set_batch(data) if count % 2 == 0: ls.set_point_now('status', 'OK') else: