File: //usr/local/CyberCP/aiScanner/management/commands/__pycache__/run_scheduled_scans.cpython-310.pyc
o
��hYQ � @ sL d dl mZ d dlmZ d dlmZmZ d dlZd dlZG dd� de�ZdS )� )�BaseCommand)�timezone)�datetime� timedeltaNc @ s` e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zdd� Zdd� Z
dS )�CommandzRun scheduled AI security scansc C sD |j dddd� |j dtdd� |j ddd d� |j d
ddd� d S )Nz--daemon�
store_truez8Run as daemon, checking for scheduled scans every minute)�action�helpz --scan-id�#Run a specific scheduled scan by ID)�typer z --verbosez3Show detailed information about all scheduled scansz--forcezCForce run all active scheduled scans immediately, ignoring schedule)�add_argument�int)�self�parser� r �G/usr/local/CyberCP/aiScanner/management/commands/run_scheduled_scans.py�
add_arguments s( ���
�zCommand.add_argumentsc O s� |� dd�| _|� dd�| _|d r| j�d� | �� d S |d r7| j�d|d � d�� | �|d � d S |d rG| j�d � | �� d S | j�d
� | �� d S )N�verboseF�force�daemonz!Starting scheduled scan daemon...�scan_idzRunning scheduled scan ID z...z+Force running all active scheduled scans...z&Checking for scheduled scans to run...) �getr r �stdout�write�
run_daemon�run_scheduled_scan_by_id�force_run_all_scans�check_and_run_scans)r �args�optionsr r r �handle! s zCommand.handlec
C s� z| j �dt�� �d�� d�� | �� t�d� W nA ty+ | j �d� Y dS t y\ } z&| j
�dt|�� �� dd lm
} |�d
t|�� �� t�d� W Y d}~nd}~ww q)z.Run as daemon, checking for scans every minuteTz
[�%Y-%m-%d %H:%M:%S UTCz!] Checking for scheduled scans...�<