コード例 #1
0
    def test_event_time(self):
        text = Utils.load_file("test/unit/resources/vspp.log")

        self.assertEquals(Utils.parse_datetime('2017-06-21 13:47:00,480'),
                          self.__udf.process(text)[0][0])
        self.assertEquals(Utils.parse_datetime('2017-06-21 13:47:50,606'),
                          self.__udf.process(text)[1][0])
コード例 #2
0
 def process(text):
     try:
         lines = filter(lambda text_line: text_line != "", text.split('\n'))
         durations = []
         for line in lines:
             startMatch = VsppUDF.__startRegex.match(line)
             if startMatch:
                 start = Utils.parse_datetime(startMatch.group(1))
             endMatch = VsppUDF.__endRegex.match(line)
             if endMatch:
                 delta = Utils.parse_datetime(endMatch.group(1)) - start
                 durations.append((start, delta.seconds))
         sizes = [
             int(size) for size in re.findall(VsppUDF.__sizeRegex, line)
         ]
         return map(
             lambda ((eventTime, duration), size):
             (eventTime, size / (duration * VsppUDF.megabyte)),
             zip(durations, sizes))
     except ZeroDivisionError:
         return []
コード例 #3
0
 def test_parse(self):
     self.assertEquals(
         datetime.strptime("2017-07-04 09:17:32,210", default_date_format),
         Utils.parse_datetime("2017-07-04 09:17:32,210"))