Initialize the timestamp tracker. Args: action_name: Name of the action (e.g., 'lynis_pentest') datadir: Data directory for storing tracking files interval_hours: Minimum hours between executions
(self, action_name, datadir, interval_hours=24)
| 134 | """Helper class to track action timestamps and enforce minimum intervals.""" |
| 135 | |
| 136 | def __init__(self, action_name, datadir, interval_hours=24): |
| 137 | """ |
| 138 | Initialize the timestamp tracker. |
| 139 | |
| 140 | Args: |
| 141 | action_name: Name of the action (e.g., 'lynis_pentest') |
| 142 | datadir: Data directory for storing tracking files |
| 143 | interval_hours: Minimum hours between executions |
| 144 | """ |
| 145 | self.action_name = action_name |
| 146 | self.interval_hours = interval_hours |
| 147 | self.db_file = os.path.join(datadir, f'{action_name}_timestamps.json') |
| 148 | self.timestamps = {} |
| 149 | self._load_db() |
| 150 | |
| 151 | def _load_db(self): |
| 152 | """Load the database of timestamps.""" |