Logging + DB connection + add init action

I hope script could be used anywhere in filesystem
This commit is contained in:
2018-07-08 21:15:51 +02:00
parent e421731608
commit 09036fe283
2 changed files with 47 additions and 16 deletions

View File

@@ -7,6 +7,7 @@ import datetime
import logging
from datetime import datetime
from enum import Enum
import sys
class TypeAction(Enum):
CREATE = 'created'
@@ -34,9 +35,15 @@ def handle_action(args, last_action, conn):
for row in cursor.fetchall():
log_id, project_id, task_id, note_id, username, taction, message, created_at = row
logging.debug(row)
formated_date = datetime.strptime(created_at[:26], '%Y-%m-%d %H:%M:%S.%f').strftime('%b %d, %Y %H:%M')
if taction == 'init':
print('{} ({}): {}'.format(formated_date, username, message))
sys.exit(0)
object_type = ''
id_object = ''
formated_date = datetime.strptime(created_at[:26], '%Y-%m-%d %H:%M:%S.%f').strftime('%b %d, %Y %H:%M')
object_type = '' # TODO Enum ?
if (project_id):