Changeset 8f41b95 in flowtimer


Ignore:
Timestamp:
08/31/24 11:11:57 (9 months ago)
Author:
Enrico Schwass <ennoausberlin@…>
Branches:
guix
Children:
df0449c
Parents:
813e855
Message:

logger added - phases left counting fixed

Signed-off-by: Enrico Schwass <ennoausberlin@…>

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • flowtimer/RecurringPhaseSequence.py

    r813e855 r8f41b95  
    3737        self.current_phase = phases[0]
    3838        self.initial_repetitions = repetitions
    39         self.passes_left = repetitions
     39        self.passes_left = repetitions - 1
    4040
    4141    def to_json(self):
     
    8080
    8181    def is_final_round(self):
     82        print("Final round", self.passes_left)
    8283        return self.passes_left == 0
    8384
     
    107108        else:
    108109            if self.is_final_round():
     110                print("Abort on final round")
    109111                self.abort()
    110112                return
    111113            else:
    112114                self.passes_left -= 1
     115                print("Skip", self.passes_left)
    113116                self.current_phase.reset()
    114117                self.current_phase = self.phases[0]
     
    125128            if self.passes_left < 1:
    126129                self._state = "completed"
     130                print("Passes left", self.passes_left)
    127131            else:
    128132                self.current_phase.reset()
  • flowtimer/Schedule.py

    r813e855 r8f41b95  
    114114        self._state = "aborted"
    115115
     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
    116122    def current_block_is_final(self):
    117123        index = self.blocks.index(self.current_block)
     
    150156            self.abort()
    151157            return
    152         index = self.blocks.index(self.current_block)
    153         self.current_block = self.blocks[index+1]
     158        self.advance_to_next_block()
    154159        return
    155160
     
    167172        return []
    168173
    169     def current_phase(self):
    170         if self.current_block.is_sequence():
    171             return self.current_block.current_phase
    172         else:
    173             return self.current_block
    174 
    175174    def tick(self, ticks):
    176175        if not self.is_completed():
  • flowtimer/__init__.py

    r813e855 r8f41b95  
     1import logging
     2import logging.config
     3import os
     4from 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
     9log_dir = Path(os.environ.get('FLOWTIMER_LOG_DIR', '/tmp/'))
     10
     11log_path = log_dir / 'flowtimer.log'
     12
     13if 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)
     20else:
     21    logging.basicConfig(filename=str(log_path), encoding='utf-8', level=logging.DEBUG)
     22
     23logger = logging.getLogger(__name__)
     24
     25logger.setLevel(os.environ.get('FLOWTIMER_LOG_LEVEL', logger.getEffectiveLevel()))
  • tests/test_recurring_phase_sequence.py

    r813e855 r8f41b95  
    2424        assert data['_state'] == "initial"
    2525        assert data['initial_repetitions'] == 3
    26         assert data['passes_left'] == 3
     26        assert data['passes_left'] == 2
    2727        assert len(data['phases']) == 3
    2828
     
    3030        assert recurring_phase_sequence.state() == "initial"
    3131        assert recurring_phase_sequence.current_phase.title == "Tasking"
    32         assert recurring_phase_sequence.passes_left == 3
     32        assert recurring_phase_sequence.passes_left == 2
    3333
    3434    def test_current_phase_number(self, recurring_phase_sequence):
     
    7070        recurring_phase_sequence.tick(6)
    7171        assert recurring_phase_sequence.current_phase.title == "Work"
    72         assert recurring_phase_sequence.passes_left == 3
     72        assert recurring_phase_sequence.passes_left == 2
    7373
    7474        recurring_phase_sequence.tick(45)
    7575        assert recurring_phase_sequence.current_phase.title == "Break"
    76         assert recurring_phase_sequence.passes_left == 3
     76        assert recurring_phase_sequence.passes_left == 2
    7777
    7878        recurring_phase_sequence.tick(15)
    7979        assert recurring_phase_sequence.current_phase.title == "Tasking"
    80         assert recurring_phase_sequence.passes_left == 2
     80        assert recurring_phase_sequence.passes_left == 1
    8181
    8282    def test_unrolled(self, recurring_phase_sequence):
Note: See TracChangeset for help on using the changeset viewer.