Blame view

src/scheduler/UserManager.py 867 Bytes
bca9a283   Jeremy   Reworked the sche...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from common.models import *
from utils.Logger import *
from decimal import *

class UserManager(Logger):
    REJECTED = "Insufficient quota"

    def __init__(self, user: PyrosUser):
        super().__init__("UserManager", "UserManager")
        self.user = user

    @classmethod
    def determineQuota(cls, sequence: Sequence) -> float:
        return sequence.request.pyros_user.quota

    @classmethod
    def isSufficient(cls, quota: float, sequence: Sequence) -> bool:
e573c1f1   Etienne Pallier   All unit tests no...
18
19
        #print("seq is", sequence.duration)
        #print("quota is", quota)
bca9a283   Jeremy   Reworked the sche...
20
21
22
23
24
25
26
27
28
29
30
        if quota < sequence.duration:
            return False
        return True

    @classmethod
    def determinePriority(cls, sequence: Sequence) -> float:
        return 0

    def decreaseQuota(self, value: Decimal) -> int:
        self.user.quota -= float(value)
        self.user.save()
bca9a283   Jeremy   Reworked the sche...
31
        return 0