Changeset 8f41b95 in flowtimer
- Timestamp:
- 08/31/24 11:11:57 (9 months ago)
- Branches:
- guix
- Children:
- df0449c
- Parents:
- 813e855
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
flowtimer/RecurringPhaseSequence.py
r813e855 r8f41b95 37 37 self.current_phase = phases[0] 38 38 self.initial_repetitions = repetitions 39 self.passes_left = repetitions 39 self.passes_left = repetitions - 1 40 40 41 41 def to_json(self): … … 80 80 81 81 def is_final_round(self): 82 print("Final round", self.passes_left) 82 83 return self.passes_left == 0 83 84 … … 107 108 else: 108 109 if self.is_final_round(): 110 print("Abort on final round") 109 111 self.abort() 110 112 return 111 113 else: 112 114 self.passes_left -= 1 115 print("Skip", self.passes_left) 113 116 self.current_phase.reset() 114 117 self.current_phase = self.phases[0] … … 125 128 if self.passes_left < 1: 126 129 self._state = "completed" 130 print("Passes left", self.passes_left) 127 131 else: 128 132 self.current_phase.reset() -
flowtimer/Schedule.py
r813e855 r8f41b95 114 114 self._state = "aborted" 115 115 116 def current_phase(self): 117 if self.current_block.is_sequence(): 118 return self.current_block.current_phase 119 else: 120 return self.current_block 121 116 122 def current_block_is_final(self): 117 123 index = self.blocks.index(self.current_block) … … 150 156 self.abort() 151 157 return 152 index = self.blocks.index(self.current_block) 153 self.current_block = self.blocks[index+1] 158 self.advance_to_next_block() 154 159 return 155 160 … … 167 172 return [] 168 173 169 def current_phase(self):170 if self.current_block.is_sequence():171 return self.current_block.current_phase172 else:173 return self.current_block174 175 174 def tick(self, ticks): 176 175 if not self.is_completed(): -
flowtimer/__init__.py
r813e855 r8f41b95 1 import logging 2 import logging.config 3 import os 4 from pathlib import Path 5 6 # FIXME: change the default log path to /var/log/flowtimer/flowtimer.log when system configuration created this dir 7 # with the appropriate rights 8 9 log_dir = Path(os.environ.get('FLOWTIMER_LOG_DIR', '/tmp/')) 10 11 log_path = log_dir / 'flowtimer.log' 12 13 if not log_path.exists(): 14 try: 15 log_path.touch() 16 except PermissionError: 17 conf_file = Path(__file__).parent / 'flowtimer_logging.conf' 18 print("Conf file", conf_file) 19 logging.config.fileConfig(conf_file) 20 else: 21 logging.basicConfig(filename=str(log_path), encoding='utf-8', level=logging.DEBUG) 22 23 logger = logging.getLogger(__name__) 24 25 logger.setLevel(os.environ.get('FLOWTIMER_LOG_LEVEL', logger.getEffectiveLevel())) -
tests/test_recurring_phase_sequence.py
r813e855 r8f41b95 24 24 assert data['_state'] == "initial" 25 25 assert data['initial_repetitions'] == 3 26 assert data['passes_left'] == 326 assert data['passes_left'] == 2 27 27 assert len(data['phases']) == 3 28 28 … … 30 30 assert recurring_phase_sequence.state() == "initial" 31 31 assert recurring_phase_sequence.current_phase.title == "Tasking" 32 assert recurring_phase_sequence.passes_left == 332 assert recurring_phase_sequence.passes_left == 2 33 33 34 34 def test_current_phase_number(self, recurring_phase_sequence): … … 70 70 recurring_phase_sequence.tick(6) 71 71 assert recurring_phase_sequence.current_phase.title == "Work" 72 assert recurring_phase_sequence.passes_left == 372 assert recurring_phase_sequence.passes_left == 2 73 73 74 74 recurring_phase_sequence.tick(45) 75 75 assert recurring_phase_sequence.current_phase.title == "Break" 76 assert recurring_phase_sequence.passes_left == 376 assert recurring_phase_sequence.passes_left == 2 77 77 78 78 recurring_phase_sequence.tick(15) 79 79 assert recurring_phase_sequence.current_phase.title == "Tasking" 80 assert recurring_phase_sequence.passes_left == 280 assert recurring_phase_sequence.passes_left == 1 81 81 82 82 def test_unrolled(self, recurring_phase_sequence):
Note:
See TracChangeset
for help on using the changeset viewer.