BF(2.4): omit date patterns containing %f (.subsec) for Python before 2.5

pull/522/head
Yaroslav Halchenko 2013-12-27 02:08:47 -05:00
parent c6a7bc2221
commit 6815190685
1 changed files with 16 additions and 14 deletions

View File

@ -21,7 +21,7 @@ __author__ = "Cyril Jaquier and Fail2Ban Contributors"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL"
import time, logging
import sys, time, logging
from datetemplate import DateStrptime, DateTai64n, DateEpoch, DateISO8601
from threading import Lock
@ -46,6 +46,7 @@ class DateDetector:
def addDefaultTemplate(self):
self.__lock.acquire()
try:
if sys.version_info >= (2, 5): # because of '%.f'
# asctime with subsecond
template = DateStrptime()
template.setName("WEEKDAY MONTH Day Hour:Minute:Second[.subsecond] Year")
@ -101,6 +102,7 @@ class DateDetector:
template.setRegex("\d{2}/\d{2}/\d{4}:\d{2}:\d{2}:\d{2}")
template.setPattern("%m/%d/%Y:%H:%M:%S")
self._appendTemplate(template)
if sys.version_info >= (2, 5): # because of '%.f'
# proftpd 2013-11-16 21:43:03,296
# So like Exim below but with ,subsecond
template = DateStrptime()