Example #1
0
 def setToolsInTime(self):
     """Get all OOT (Out of Time) tools in this wave and checks if this Interval makes them in time. 
     If it is the case, set them in time.
     """
     if Utils.fitNowTime(self.dated, self.datef):
         tools = Tool.fetchObjects({"wave": self.wave, "status": "OOT"})
         for tool in tools:
             tool.setInTime()
Example #2
0
 def isLaunchableNow(self):
     """Returns True if the tool matches criteria to be launched 
     (current time matches one of interval object assigned to this wave)
     Returns:
         bool
     """
     intervals = Interval.fetchObjects({"wave": self.wave})
     for intervalModel in intervals:
         if Utils.fitNowTime(intervalModel.dated, intervalModel.datef):
             return True
     return False
Example #3
0
    def searchForAddressCompatibleWithTime(cls):
        """
        Return a list of wave which have at least one interval fitting the actual time.

        Returns:
            A set of wave name
        """
        waves_to_launch = set()
        intervals = Interval.fetchObjects({})
        for intervalModel in intervals:
            if Utils.fitNowTime(intervalModel.dated, intervalModel.datef):
                waves_to_launch.add(intervalModel.wave)
        return waves_to_launch
Example #4
0
def getWaveTimeLimit(waveName):
    """
    Return the latest time limit in which this tool fits. The tool should timeout after that limit

    Returns:
        Return the latest time limit in which this tool fits.
    """
    intervals = Interval.fetchObjects({"wave": waveName})
    furthestTimeLimit = datetime.now()
    for intervalModel in intervals:
        if Utils.fitNowTime(intervalModel.dated, intervalModel.datef):
            endingDate = intervalModel.getEndingDate()
            if endingDate is not None:
                if endingDate > furthestTimeLimit:
                    furthestTimeLimit = endingDate
    return furthestTimeLimit
Example #5
0
 def delete(self):
     """
     Delete the Interval represented by this model in database.
     """
     mongoInstance = MongoCalendar.getInstance()
     mongoInstance.delete(
         "intervals", {"_id": self._id})
     parent_wave = mongoInstance.find("waves", {"wave": self.wave}, False)
     self._id = None
     if parent_wave is None:
         return
     mongoInstance.notify(mongoInstance.calendarName,
                          "waves", parent_wave["_id"], "update", "")
     other_intervals = Interval.fetchObjects({"wave": self.wave})
     no_interval_in_time = True
     for other_interval in other_intervals:
         if Utils.fitNowTime(other_interval.dated, other_interval.datef):
             no_interval_in_time = False
             break
     if no_interval_in_time:
         tools = Tool.fetchObjects({"wave": self.wave})
         for tool in tools:
             tool.setOutOfTime()