mirror of
https://github.com/MikroWizard/mikroman.git
synced 2025-06-21 03:55:39 +02:00
Fixed Firmware download from the Mikrotik website when there are multiple npk available Fixed Mikrowizard system permission error when it is set to None Fixed user device group permissions Some minor UI improvements Fix IP scan for one IP scan / Fix not scanning the last IP in the range Fix manual snippet execution not working when device groups are selected Some minor bug fixes and improvements New: Show background tasks and be able to stop them while running in the background (like an IP scanner) Add support for manual MikroWizard update dashboard/settings page update to version 1.0.5 Enhancement: Show permission error in some pages when the user doesn't have permission for that page/action show better charts/graphs in the dashboard and device interface details show more info on the dashboard about update and version information and license
86 lines
2.4 KiB
Python
86 lines
2.4 KiB
Python
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# db_tasks.py: Models and functions for accsessing db related to mikrowizard internal logs
|
|
# MikroWizard.com , Mikrotik router management solution
|
|
# Author: sepehr.ha@gmail.com
|
|
|
|
from peewee import *
|
|
|
|
from libs.db.db import User,BaseModel
|
|
|
|
import logging
|
|
log = logging.getLogger("db_tasks")
|
|
|
|
class Tasks(BaseModel):
|
|
signal = TextField()
|
|
starttime = DateTimeField()
|
|
endtime = DateTimeField()
|
|
status = BooleanField()
|
|
action = TextField()
|
|
name = TextField()
|
|
class Meta:
|
|
# `indexes` is a tuple of 2-tuples, where the 2-tuples are
|
|
# a tuple of column names to index and a boolean indicating
|
|
# whether the index is unique or not.
|
|
db_table = 'tasks'
|
|
|
|
#Get groups of device
|
|
def update_check_status():
|
|
return (Tasks.select().where(Tasks.signal == 100).get())
|
|
|
|
#Get groups of device
|
|
def update_job_status():
|
|
return (Tasks.select().where(Tasks.signal == 110).get())
|
|
|
|
#Get groups of device
|
|
def backup_job_status():
|
|
return (Tasks.select().where(Tasks.signal == 120).get())
|
|
|
|
#check status of scanner
|
|
def scanner_job_status():
|
|
return (Tasks.select().where(Tasks.signal == 130).get())
|
|
|
|
#check status of downloader
|
|
def downloader_job_status():
|
|
return (Tasks.select().where(Tasks.signal == 140).get())
|
|
|
|
def firmware_service_status():
|
|
return (Tasks.select().where(Tasks.signal == 150).get())
|
|
|
|
def exec_snipet_status():
|
|
return (Tasks.select().where(Tasks.signal == 160).get())
|
|
|
|
def get_running_tasks():
|
|
return (Tasks.select().where(Tasks.status == True))
|
|
|
|
def get_task_by_signal(signal):
|
|
return (Tasks.select().where(Tasks.signal == signal).get())
|
|
|
|
def get_all():
|
|
return (Tasks.select())
|
|
|
|
class TaskResults(BaseModel):
|
|
task_type = TextField()
|
|
result = DateTimeField()
|
|
info = TextField()
|
|
external_id = IntegerField()
|
|
created = DateTimeField()
|
|
|
|
class Meta:
|
|
# `indexes` is a tuple of 2-tuples, where the 2-tuples are
|
|
# a tuple of column names to index and a boolean indicating
|
|
# whether the index is unique or not.
|
|
db_table = 'task_results'
|
|
|
|
def add_task_result(task_type,result,info=None,eid=None):
|
|
tr = TaskResults(task_type=task_type, result=result,info=info,external_id=eid)
|
|
tr.save()
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
if __name__ == '__main__':
|
|
|
|
# quick adhoc tests
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|