mirror of
https://github.com/vale981/FHEM-Log-Parser
synced 2025-03-04 09:01:38 -05:00
Requirements, Hashbang and Dateparser
This commit is contained in:
parent
6b6621e351
commit
40f2d67b1e
3 changed files with 415802 additions and 0 deletions
10
parseLogs.py
Normal file → Executable file
10
parseLogs.py
Normal file → Executable file
|
@ -1,7 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import datetime
|
||||
import argparse
|
||||
import logParser
|
||||
import dateparser
|
||||
from math import inf
|
||||
|
||||
argparser = argparse.ArgumentParser(description='Parse the FHEM logfiles into a Database.')
|
||||
|
@ -17,10 +20,17 @@ mintime, maxtime = 0, inf
|
|||
if args.timeSpan:
|
||||
times = args.timeSpan[0].split('..')
|
||||
|
||||
|
||||
if len(times) < 1 or len(times) > 2:
|
||||
print('Invalid Timespan!')
|
||||
exit(1)
|
||||
elif len(times) == 2:
|
||||
try:
|
||||
times[0] = dateparser.parse(times[0]).timestamp()
|
||||
times[1] = dateparser.parse(times[1]).timestamp()
|
||||
except:
|
||||
pass
|
||||
|
||||
if times[0] == '':
|
||||
maxtime = int(times[1])
|
||||
else:
|
||||
|
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
sqlalchemy
|
||||
dateparser
|
Loading…
Add table
Reference in a new issue