mirror of
https://github.com/MikroWizard/mikroman.git
synced 2025-07-13 15:34:34 +02:00
MikroWizard Initial commit | MikroMan Welcome to the world :)
This commit is contained in:
commit
8c49b9a55d
96 changed files with 12274 additions and 0 deletions
73
py/libs/db/db_tasks.py
Normal file
73
py/libs/db/db_tasks.py
Normal file
|
@ -0,0 +1,73 @@
|
|||
#!/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()
|
||||
|
||||
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())
|
||||
|
||||
|
||||
class TaskResults(BaseModel):
|
||||
task_type = TextField()
|
||||
result = DateTimeField()
|
||||
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):
|
||||
tr = TaskResults(task_type=task_type, result=result)
|
||||
tr.save()
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# quick adhoc tests
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue