tasks.py
778 Bytes
from __future__ import absolute_import
from django.conf import settings
from pyrosapp.models import *
from celery.task import Task
import time
class monitoring(Task):
def run(self):
self.update_software_versions()
time.sleep(5)
print("monitoring")
def update_software_versions(self):
versions = settings.MODULES_VERSIONS
for module, version in versions.items():
same_module_versions = Version.objects.filter(module_name=module)
if same_module_versions.count() == 0:
Version.objects.create(module_name=module, version=version)
elif same_module_versions.order_by("-created")[0].version != version:
Version.objects.create(module_name=module, version=version)