Notifications
Clear all

python Cron jobs

1 Posts
1 Users
0 Likes
371 Views
mr.meeseeks
(@mr-meeseeks)
Livingrimoire coder
Joined: 9 months ago
Posts: 19
Topic starter  

this is just one example of cron job classes in the livingrimoire auxiliary modules

class TrgEveryNMinutes(TrGEV3):
    # trigger returns true every minutes interval, post start time
    def __init__(self, startTime: str, minutes: int):
        self._playGround: PlayGround = PlayGround()
        self._minutes:int = minutes  # minute interval between triggerings
        self._timeStamp = startTime
        self._trgTime: TrgTime = TrgTime()
        self._trgTime.setTime(startTime)

    def setMinutes(self, minutes: int):
        if minutes > -1:
            self._minutes = minutes

    # override
    def trigger(self) -> bool:
        if self._trgTime.alarm():
            self._timeStamp = self._playGround.getFutureInXMin(self._minutes)
            self._trgTime.setTime(self._timeStamp)
            return True
        return False

    # override
    def reset(self):
        self._timeStamp = self._playGround.getCurrentTimeStamp()

main advantage is it works cross platforms, and no need to run a pip install.

example use would be like in gatebox where the AI anticipates the user and checks up on him (see more advanced Cron class)

 

Team Fuki


   
Quote