MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / should_run

Method should_run

actions/connector_utils.py:171–196  ·  view source on GitHub ↗

Check if the action should run based on last run time. Args: ip: IP address of the host Returns: Tuple of (should_run: bool, reason: str)

(self, ip)

Source from the content-addressed store, hash-verified

169 logger.error(f"Could not save timestamps for {self.action_name}: {e}")
170
171 def should_run(self, ip):
172 """
173 Check if the action should run based on last run time.
174
175 Args:
176 ip: IP address of the host
177
178 Returns:
179 Tuple of (should_run: bool, reason: str)
180 """
181 if ip not in self.timestamps:
182 return True, "Never run before"
183
184 try:
185 last_run = datetime.fromisoformat(self.timestamps[ip])
186 time_since_last = datetime.utcnow() - last_run
187 hours_since = time_since_last.total_seconds() / 3600
188
189 if hours_since >= self.interval_hours:
190 return True, f"Last run {hours_since:.1f} hours ago"
191 else:
192 hours_remaining = self.interval_hours - hours_since
193 return False, f"Last run {hours_since:.1f} hours ago, retry in {hours_remaining:.1f} hours"
194 except Exception as e:
195 logger.warning(f"Error parsing timestamp for {ip}: {e}")
196 return True, "Invalid timestamp"
197
198 def mark_run(self, ip):
199 """

Callers 1

executeMethod · 0.80

Calls 1

warningMethod · 0.80

Tested by 1

executeMethod · 0.64