MCPcopy
hub / github.com/smittix/intercept / start_mode

Method start_mode

intercept_agent.py:716–755  ·  view source on GitHub ↗

Start a mode with given parameters.

(self, mode: str, params: dict)

Source from the content-addressed store, hash-verified

714 return None
715
716 def start_mode(self, mode: str, params: dict) -> dict:
717 """Start a mode with given parameters."""
718 if mode in self.running_modes:
719 return {'status': 'error', 'message': f'{mode} already running'}
720
721 caps = self.detect_capabilities()
722 if not caps['modes'].get(mode, False):
723 return {'status': 'error', 'message': f'{mode} not available (missing tools)'}
724
725 # Check SDR device conflicts for SDR-based modes
726 if mode in self.SDR_MODES:
727 device = params.get('device', 0)
728 try:
729 device = int(device)
730 except (ValueError, TypeError):
731 device = 0
732 in_use_by = self.get_sdr_in_use(device)
733 if in_use_by:
734 return {
735 'status': 'error',
736 'message': f'SDR device {device} is in use by {in_use_by}. Stop {in_use_by} first or use a different device.'
737 }
738
739 # Initialize lock if needed
740 if mode not in self.locks:
741 self.locks[mode] = threading.Lock()
742
743 with self.locks[mode]:
744 try:
745 # Mode-specific start logic
746 result = self._start_mode_internal(mode, params)
747 if result.get('status') == 'started':
748 self.running_modes[mode] = {
749 'started_at': datetime.now(timezone.utc).isoformat(),
750 'params': params,
751 }
752 return result
753 except Exception as e:
754 logger.exception(f"Error starting {mode}")
755 return {'status': 'error', 'message': str(e)}
756
757 def stop_mode(self, mode: str) -> dict:
758 """Stop a running mode."""

Calls 4

detect_capabilitiesMethod · 0.95
get_sdr_in_useMethod · 0.95
_start_mode_internalMethod · 0.95
getMethod · 0.80