dev-make-query-performant #16
6
inex.py
6
inex.py
@ -10,6 +10,7 @@ import json
|
|||||||
import requests
|
import requests
|
||||||
import inexEncoder
|
import inexEncoder
|
||||||
import inexSqlquery
|
import inexSqlquery
|
||||||
|
|
||||||
class Inex:
|
class Inex:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initilize config, calls functions from inex-connect.py and inex-logging.py"""
|
"""Initilize config, calls functions from inex-connect.py and inex-logging.py"""
|
||||||
@ -30,6 +31,8 @@ class Inex:
|
|||||||
self.config = self.tl.load(c)
|
self.config = self.tl.load(c)
|
||||||
|
|
||||||
# set config
|
# set config
|
||||||
|
try:
|
||||||
|
if self.config:
|
||||||
self.dbDriver = self.config["database"]["driver"]
|
self.dbDriver = self.config["database"]["driver"]
|
||||||
self.dbServer = self.config["database"]["server"]
|
self.dbServer = self.config["database"]["server"]
|
||||||
self.dbDatabase = self.config["database"]["database"]
|
self.dbDatabase = self.config["database"]["database"]
|
||||||
@ -49,6 +52,9 @@ class Inex:
|
|||||||
self.writeJsonfile = self.config["output"]["dumpTojson"]
|
self.writeJsonfile = self.config["output"]["dumpTojson"]
|
||||||
self.pushToplatform = self.config["output"]["pushToplatform"]
|
self.pushToplatform = self.config["output"]["pushToplatform"]
|
||||||
self.queryOverride = self.config["database"]["overrideEmbeddedquery"]
|
self.queryOverride = self.config["database"]["overrideEmbeddedquery"]
|
||||||
|
except:
|
||||||
|
print("No config.toml. Please use example file and configure appropriately")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
if "dev" in self.selectedPlatform.lower():
|
if "dev" in self.selectedPlatform.lower():
|
||||||
self.platformConfig = self.config["fortraPlatform"]["dev"]
|
self.platformConfig = self.config["fortraPlatform"]["dev"]
|
||||||
|
@ -123,5 +123,7 @@ def dataTemplate(transactionType,**kwargs):
|
|||||||
template = fileDeleted
|
template = fileDeleted
|
||||||
if transactionType == "user_logged_on":
|
if transactionType == "user_logged_on":
|
||||||
template = logon
|
template = logon
|
||||||
|
if transactionType == "other":
|
||||||
|
template = {}
|
||||||
|
|
||||||
return template
|
return template
|
@ -7,7 +7,7 @@ def processData(data, template, **kwargs):
|
|||||||
# print(f'Row: {row}')
|
# print(f'Row: {row}')
|
||||||
if row.get('Command') == None:
|
if row.get('Command') == None:
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
processedData.append(template(identifyUtype(row.get('Command')),\
|
processedData.append(template(identifyUtype(row.get('Command')),\
|
||||||
prd_ext_tenant_id='',\
|
prd_ext_tenant_id='',\
|
||||||
status_code=row.get('ResultID'),\
|
status_code=row.get('ResultID'),\
|
||||||
@ -38,8 +38,13 @@ def processData(data, template, **kwargs):
|
|||||||
user_home_directory=row.get('VirtualFolderName'),\
|
user_home_directory=row.get('VirtualFolderName'),\
|
||||||
description=row.get('Description'),\
|
description=row.get('Description'),\
|
||||||
utype=identifyUtype(row.get('Command'))))
|
utype=identifyUtype(row.get('Command'))))
|
||||||
|
except UnboundLocalError:
|
||||||
|
print(f'Problem row GUID:{row.get("TransactionGUID")} ::: TransactionObject:{row.get("TransactionObject")} Command: {row.get("Command")}')
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
if row.get('TransactionGUID') not in transactionLoginid:
|
if row.get('TransactionGUID') not in transactionLoginid:
|
||||||
|
try:
|
||||||
processedData.append(template(identifyUtype(row.get('TransactionObject')),\
|
processedData.append(template(identifyUtype(row.get('TransactionObject')),\
|
||||||
guid=row.get('TransactionGUID'),\
|
guid=row.get('TransactionGUID'),\
|
||||||
prd_instance_id=kwargs.get('prd_instance_id'),\
|
prd_instance_id=kwargs.get('prd_instance_id'),\
|
||||||
@ -63,6 +68,9 @@ def processData(data, template, **kwargs):
|
|||||||
utype=identifyUtype(row.get('TransactionObject'))\
|
utype=identifyUtype(row.get('TransactionObject'))\
|
||||||
))
|
))
|
||||||
transactionLoginid.append(row.get('TransactionGUID'))
|
transactionLoginid.append(row.get('TransactionGUID'))
|
||||||
|
except UnboundLocalError:
|
||||||
|
print(f'Problem row GUID:{row.get("TransactionGUID")} ::: TransactionObject:{row.get("TransactionObject")} Command: {row.get("Command")}')
|
||||||
|
continue
|
||||||
|
|
||||||
return processedData
|
return processedData
|
||||||
|
|
||||||
@ -89,4 +97,4 @@ def identifyUtype(obj):
|
|||||||
if obj in file_downloaded:
|
if obj in file_downloaded:
|
||||||
return "file_downloaded"
|
return "file_downloaded"
|
||||||
else:
|
else:
|
||||||
return None
|
return "other"
|
Loading…
x
Reference in New Issue
Block a user