This commit is contained in:
Peter Molnar 2018-03-02 13:00:49 +00:00 committed by GitHub
parent de14c33321
commit 8303353a02

View file

@ -8,7 +8,6 @@ import hashlib
import arrow
import argparse
from pprint import pprint
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))
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):
with open(fpath, 'wt') as f:
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', '')
plugin = os.path.basename(os.path.dirname(os.path.dirname(log))).lower()
c = ''
try:
with open(log, 'rt') as f:
c = f.read()
except UnicodeDecodeError:
with open(log, 'rt', encoding = "ISO-8859-1") as f:
c = f.read()
with open(log, 'rb') as f:
c = f.read().decode('utf8', 'ignore')
for session in SPLIT_SESSIONS.findall(c):
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
# avoid empty or status-messages only files
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)
# 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'):
print('deleting old log: %s' % (log))
@ -259,23 +235,7 @@ def do_skype(skypedbpath, logpathbase):
os.makedirs(os.path.dirname(fpath))
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])
# 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__':