コード例 #1
0
ファイル: builder.py プロジェクト: netixx/mininet-NetProbes
 def loadEvents(self):
     for event in self.events:
         events.replaceParams(event, self.cliParams)
         e = NetEvent()
         e.target = str(event["target"])
         # variations are handed directly and use the same syntax as the TCLink option
         e.variations = event['variations']
         if hasTCLinkProperties(e.variations):
             self.setOption('link', TCLink)
         expectedTimeFormat = "(\d+)ms"
         # parse durations
         if event.has_key("repeat") and event["repeat"] != "none":
             rm = re.match(expectedTimeFormat, event['repeat'])
             if rm is not None:
                 e.repeat = float(rm.group(1)) / 1000.0
         if event.has_key("duration"):
             rm = re.match(expectedTimeFormat, event["duration"])
             if rm is not None:
                 e.duration = float(rm.group(1)) / 1000.0
                 if e.repeat is not None and e.duration > e.repeat:
                     raise RuntimeError("Duration of the event is greater that the repeat time")
         if event.has_key('nrepeat'):
             e.nrepeat = int(event['nrepeat'])
         # register event for scheduling
         EventsManager.sheduleEvent(e)
コード例 #2
0
 def loadEvents(self):
     for event in self.events:
         events.replaceParams(event, self.cliParams)
         e = NetEvent()
         e.target = str(event["target"])
         # variations are handed directly and use the same syntax as the TCLink option
         e.variations = event['variations']
         if hasTCLinkProperties(e.variations):
             self.setOption('link', TCLink)
         expectedTimeFormat = "(\d+)ms"
         # parse durations
         if event.has_key("repeat") and event["repeat"] != "none":
             rm = re.match(expectedTimeFormat, event['repeat'])
             if rm is not None:
                 e.repeat = float(rm.group(1)) / 1000.0
         if event.has_key("duration"):
             rm = re.match(expectedTimeFormat, event["duration"])
             if rm is not None:
                 e.duration = float(rm.group(1)) / 1000.0
                 if e.repeat is not None and e.duration > e.repeat:
                     raise RuntimeError(
                         "Duration of the event is greater that the repeat time"
                     )
         if event.has_key('nrepeat'):
             e.nrepeat = int(event['nrepeat'])
         # register event for scheduling
         EventsManager.sheduleEvent(e)