Fixed & remove "auto_add_time" etc..

This commit is contained in:
Adolfo Gómez García 2018-03-02 05:25:42 +01:00
parent 5f74c7fca8
commit b56b3ef6d8
7 changed files with 58 additions and 13 deletions

View File

@ -43,7 +43,7 @@ import threading
import time
import logging
__updated__ = '2017-04-17'
__updated__ = '2018-03-02'
logger = logging.getLogger(__name__)
@ -55,6 +55,7 @@ class JobThread(threading.Thread):
Ensures that the job is executed in a controlled way (any exception will be catch & processed)
Ensures that the scheduler db entry is released after run
'''
def __init__(self, jobInstance, dbJob):
super(JobThread, self).__init__()
self._jobInstance = jobInstance

View File

@ -39,7 +39,9 @@ from django.core.files.storage import Storage
from django.conf import settings
from six.moves.urllib import parse as urlparse # @UnresolvedImport
from uds.models.DBFile import DBFile
from uds.models import DBFile
from uds.models import getSqlDatetime
from .tools import DictAsObj
import six
@ -131,9 +133,11 @@ class FileStorage(Storage):
try:
f = self._dbFileForReadWrite(name)
except DBFile.DoesNotExist:
f = DBFile.objects.create(owner=self.owner, name=name)
now = getSqlDatetime()
f = DBFile.objects.create(owner=self.owner, name=name, created=now, modified=now)
f.data = content.read()
f.modified = getSqlDatetime()
f.save()
# Store on cache also

View File

@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.9 on 2018-03-02 05:25
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('uds', '0025_deployedservice_ignores_unused'),
]
operations = [
migrations.AlterField(
model_name='dbfile',
name='created',
field=models.DateTimeField(),
),
migrations.AlterField(
model_name='dbfile',
name='modified',
field=models.DateTimeField(),
),
migrations.AlterField(
model_name='delayedtask',
name='insert_date',
field=models.DateTimeField(),
),
migrations.AlterField(
model_name='scheduler',
name='last_execution',
field=models.DateTimeField(db_index=True),
),
migrations.AlterField(
model_name='userservice',
name='state_date',
field=models.DateTimeField(db_index=True),
),
]

View File

@ -34,7 +34,7 @@
from __future__ import unicode_literals
__updated__ = '2017-11-15'
__updated__ = '2018-03-02'
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@ -53,8 +53,8 @@ class DBFile(UUIDModel):
name = models.CharField(max_length=255, primary_key=True)
content = models.TextField(blank=True)
size = models.IntegerField(default=0)
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
created = models.DateTimeField()
modified = models.DateTimeField()
@property
def data(self):

View File

@ -33,7 +33,7 @@
from __future__ import unicode_literals
__updated__ = '2014-04-24'
__updated__ = '2018-03-02'
from django.db import models
@ -55,7 +55,7 @@ class DelayedTask(models.Model):
type = models.CharField(max_length=128)
tag = models.CharField(max_length=64, db_index=True) # A tag for letting us locate delayed publications...
instance = models.TextField()
insert_date = models.DateTimeField(auto_now_add=True)
insert_date = models.DateTimeField()
execution_delay = models.PositiveIntegerField()
execution_time = models.DateTimeField(db_index=True)

View File

@ -33,7 +33,7 @@
from __future__ import unicode_literals
__updated__ = '2015-10-05'
__updated__ = '2018-03-02'
from django.db import models
from django.db.models import signals
@ -70,7 +70,7 @@ class Scheduler(models.Model):
name = models.CharField(max_length=64, unique=True)
frecuency = models.PositiveIntegerField(default=DAY)
last_execution = models.DateTimeField(auto_now_add=True, db_index=True)
last_execution = models.DateTimeField(db_index=True)
next_execution = models.DateTimeField(default=NEVER, db_index=True)
owner_server = models.CharField(max_length=64, db_index=True, default='')
state = models.CharField(max_length=1, default=State.FOR_EXECUTE, db_index=True)
@ -81,7 +81,6 @@ class Scheduler(models.Model):
'''
app_label = 'uds'
def getEnvironment(self):
'''
Returns an environment valid for the record this object represents
@ -112,5 +111,6 @@ class Scheduler(models.Model):
def __unicode__(self):
return u"Scheduled task {0}, every {1}, last execution at {2}, state = {3}".format(self.name, self.frecuency, self.last_execution, self.state)
# Connects a pre deletion signal to Scheduler
signals.pre_delete.connect(Scheduler.beforeDelete, sender=Scheduler)

View File

@ -55,7 +55,7 @@ from uds.models.Util import getSqlDatetime
import logging
__updated__ = '2017-11-29'
__updated__ = '2018-03-02'
logger = logging.getLogger(__name__)
@ -77,7 +77,7 @@ class UserService(UUIDModel):
# We need to keep separated two differents os states so service operations (move beween caches, recover service) do not affects os manager state
state = models.CharField(max_length=1, default=State.PREPARING, db_index=True) # We set index so filters at cache level executes faster
os_state = models.CharField(max_length=1, default=State.PREPARING) # The valid values for this field are PREPARE and USABLE
state_date = models.DateTimeField(auto_now_add=True, db_index=True)
state_date = models.DateTimeField(db_index=True)
creation_date = models.DateTimeField(db_index=True)
data = models.TextField(default='')
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='userServices', null=True, blank=True, default=None)