time_recoder_main.py 682 B

123456789101112131415161718192021222324252627
  1. from time import sleep, time
  2. from time_recoder.save_recorded_time_in_table import save_recorded_time_in_table
  3. from time_recoder.time_recoder_config import TEST_CASE
  4. def get_current_time_as_timestamp():
  5. return int(time())
  6. def stop_record_time():
  7. if TEST_CASE:
  8. sleep(5)
  9. return True
  10. else:
  11. NotImplementedError
  12. def time_recording_main():
  13. start_time = get_current_time_as_timestamp()
  14. while not stop_record_time():
  15. sleep(1)
  16. else:
  17. worked_time_in_minutes = (get_current_time_as_timestamp() - start_time)/60
  18. save_recorded_time_in_table(worked_time_in_minutes)
  19. if __name__ == '__main__':
  20. time_recording_main()