This commit is contained in:
parent
de14c33321
commit
8303353a02
1 changed files with 46 additions and 86 deletions
|
@ -8,7 +8,6 @@ import hashlib
|
||||||
import arrow
|
import arrow
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
def logfilename(dt, nulltime=False):
|
def logfilename(dt, nulltime=False):
|
||||||
|
@ -36,7 +35,7 @@ def logappend(fpath,dt,sender,msg):
|
||||||
os.utime(os.path.dirname(fpath), (dt.timestamp, dt.timestamp))
|
os.utime(os.path.dirname(fpath), (dt.timestamp, dt.timestamp))
|
||||||
|
|
||||||
def logcreate(fpath,contact, dt,account,plugin):
|
def logcreate(fpath,contact, dt,account,plugin):
|
||||||
logging.info('creating converted log: %s' % (fpath))
|
logging.debug('creating converted log: %s' % (fpath))
|
||||||
if not os.path.exists(fpath):
|
if not os.path.exists(fpath):
|
||||||
with open(fpath, 'wt') as f:
|
with open(fpath, 'wt') as f:
|
||||||
f.write("Conversation with %s at %s on %s (%s)\n" % (
|
f.write("Conversation with %s at %s on %s (%s)\n" % (
|
||||||
|
@ -143,13 +142,8 @@ def do_trillian(trillianlogs, logpathbase, trilliantz):
|
||||||
contact = os.path.basename(log).replace('.log', '')
|
contact = os.path.basename(log).replace('.log', '')
|
||||||
plugin = os.path.basename(os.path.dirname(os.path.dirname(log))).lower()
|
plugin = os.path.basename(os.path.dirname(os.path.dirname(log))).lower()
|
||||||
|
|
||||||
c = ''
|
with open(log, 'rb') as f:
|
||||||
try:
|
c = f.read().decode('utf8', 'ignore')
|
||||||
with open(log, 'rt') as f:
|
|
||||||
c = f.read()
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
with open(log, 'rt', encoding = "ISO-8859-1") as f:
|
|
||||||
c = f.read()
|
|
||||||
|
|
||||||
for session in SPLIT_SESSIONS.findall(c):
|
for session in SPLIT_SESSIONS.findall(c):
|
||||||
participants, timestamp, session = session
|
participants, timestamp, session = session
|
||||||
|
@ -194,25 +188,7 @@ def do_trillian(trillianlogs, logpathbase, trilliantz):
|
||||||
# creating the filw with the header has to be here to
|
# creating the filw with the header has to be here to
|
||||||
# avoid empty or status-messages only files
|
# avoid empty or status-messages only files
|
||||||
logcreate(fpath, participants[1], dt, account, plugin)
|
logcreate(fpath, participants[1], dt, account, plugin)
|
||||||
# logging.info('creating converted log: %s' % (fpath))
|
|
||||||
# if not os.path.exists(fpath):
|
|
||||||
# with open(fpath, 'wt') as f:
|
|
||||||
# f.write("Conversation with %s at %s on %s (%s)\n" % (
|
|
||||||
# ,
|
|
||||||
# dt.format('ddd dd MMM YYYY hh:mm:ss A ZZZ'),
|
|
||||||
# account,
|
|
||||||
# plugin
|
|
||||||
# ))
|
|
||||||
|
|
||||||
logappend(fpath, mindt, sender, msg)
|
logappend(fpath, mindt, sender, msg)
|
||||||
# with open(fpath, 'at') as f:
|
|
||||||
# f.write("(%s) %s: %s\n" % (
|
|
||||||
# mindt.format('YYYY-MM-DD HH:mm:ss'),
|
|
||||||
# sender,
|
|
||||||
# msg
|
|
||||||
# ))
|
|
||||||
# os.utime(fpath, (mindt.timestamp, mindt.timestamp))
|
|
||||||
# os.utime(os.path.dirname(fpath), (mindt.timestamp, mindt.timestamp))
|
|
||||||
|
|
||||||
if params.get('cleanup'):
|
if params.get('cleanup'):
|
||||||
print('deleting old log: %s' % (log))
|
print('deleting old log: %s' % (log))
|
||||||
|
@ -259,23 +235,7 @@ def do_skype(skypedbpath, logpathbase):
|
||||||
os.makedirs(os.path.dirname(fpath))
|
os.makedirs(os.path.dirname(fpath))
|
||||||
|
|
||||||
logcreate(fpath, r[1], dt, account, 'skype')
|
logcreate(fpath, r[1], dt, account, 'skype')
|
||||||
# if not os.path.exists(fpath):
|
|
||||||
# with open(fpath, 'wt') as f:
|
|
||||||
# f.write("Conversation with %s at %s on %s (skype)\n" % (
|
|
||||||
# r[1],
|
|
||||||
# dt.format('ddd dd MMM YYYY hh:mm:ss A ZZZ'),
|
|
||||||
# account
|
|
||||||
# ))
|
|
||||||
|
|
||||||
logappend(fpath, dt, r[3], r[4])
|
logappend(fpath, dt, r[3], r[4])
|
||||||
# with open(fpath, 'at') as f:
|
|
||||||
# f.write("(%s) %s: %s\n" % (
|
|
||||||
# dt.format('YYYY-MM-DD HH:mm:ss'),
|
|
||||||
# r[3],
|
|
||||||
# r[4]
|
|
||||||
# ))
|
|
||||||
# os.utime(fpath, (dt.timestamp, dt.timestamp))
|
|
||||||
# os.utime(os.path.dirname(fpath), (dt.timestamp, dt.timestamp))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in a new issue