threshold_days = 4 #give here the days

import sqlite3
import math
from datetime import datetime, timedelta
import sys
import os

def alert(arg):
    sys.stderr.write("%d%d%d" % (arg, arg, arg))

def convert_JD_to_DT(JD):
    BASE_JD = 1721424.5
    user_JD = JD
    date = datetime.fromordinal(int(math.floor(user_JD - BASE_JD)))
    return date

if os.path.exists(r"C:\ProgramData\COMODO\Firewall Pro\cislogs.sdb"):
    con = sqlite3.connect(r"C:\ProgramData\COMODO\Firewall Pro\cislogs.sdb")
    cursor = con.cursor()
    cursor.execute("SELECT LogDate FROM Jobs WHERE Name='Full Scan' ORDER BY ID DESC LIMIT 1;")
    Julian_Date_Time = cursor.fetchall()

    if Julian_Date_Time:
        Last_runtime_dt = convert_JD_to_DT(Julian_Date_Time[0][0])
        check = Last_runtime_dt.date() + timedelta(days=threshold_days)
        today = datetime.today().date()
        if check<today:
            alert(1)
            print("full scan hasn't been ran for more than the given threshold_days. last runtime of full scan - %s"%(str(Last_runtime_dt)))
        else:
            alert(0)
    else:
        print("cislogs has no information about full scan. please check whether full scan has ever ran on this system")
else:
    print("cislogs is not found on this system. can't get information about last runtime of full scan. please check whether comodo client security installed on this system")