Requirements, Hashbang and Dateparser

This commit is contained in:
Valentin Boettcher 2018-02-18 22:02:24 +01:00
parent 6b6621e351
commit 40f2d67b1e
3 changed files with 415802 additions and 0 deletions

10
parseLogs.py Normal file → Executable file
View file

@ -1,7 +1,10 @@
#!/usr/bin/env python3
import sys import sys
import datetime import datetime
import argparse import argparse
import logParser import logParser
import dateparser
from math import inf from math import inf
argparser = argparse.ArgumentParser(description='Parse the FHEM logfiles into a Database.') argparser = argparse.ArgumentParser(description='Parse the FHEM logfiles into a Database.')
@ -17,10 +20,17 @@ mintime, maxtime = 0, inf
if args.timeSpan: if args.timeSpan:
times = args.timeSpan[0].split('..') times = args.timeSpan[0].split('..')
if len(times) < 1 or len(times) > 2: if len(times) < 1 or len(times) > 2:
print('Invalid Timespan!') print('Invalid Timespan!')
exit(1) exit(1)
elif len(times) == 2: elif len(times) == 2:
try:
times[0] = dateparser.parse(times[0]).timestamp()
times[1] = dateparser.parse(times[1]).timestamp()
except:
pass
if times[0] == '': if times[0] == '':
maxtime = int(times[1]) maxtime = int(times[1])
else: else:

2
requirements.txt Normal file
View file

@ -0,0 +1,2 @@
sqlalchemy
dateparser

415790
test.log Normal file

File diff suppressed because it is too large Load diff