diff --git a/inexConnect.py b/inexConnect.py index e653ece..3eefad6 100644 --- a/inexConnect.py +++ b/inexConnect.py @@ -62,6 +62,7 @@ class fortraEFC: def pushPayload(self): fortraEFC.readToken(self) + print(self.tokenData) try: url = f'{self.platformConfig["efc_url"]}/api/v1/unity/data/{self.platformConfig["tenant_id"]}/machine_event' pushPayloadResponse = self.r.post(url, headers={'Authorization': f'bearer {self.tokenData["access_token"]}'},\ diff --git a/inexDataProcessing.py b/inexDataProcessing.py index 8b1e4d0..b0b7699 100644 --- a/inexDataProcessing.py +++ b/inexDataProcessing.py @@ -1,10 +1,15 @@ def processData(data, template, **kwargs): - + """Translates data from sql query to the appropriate place in the respective template. + Accepts data, which is the sql query output, the template function, and finally + additional data to insert into the template.""" processedData = [] transactionLoginid = [] for row in data: # print(f'Row: {row}') + if identifyUtype(row.get('Command')) == "other": + continue + if row.get('Command') == None: continue try: @@ -75,6 +80,7 @@ def processData(data, template, **kwargs): return processedData def identifyUserType(obj): + """Check string if it has Admin-> return Administrator else return User.""" if obj: if "Admin" in obj: return "Administrator" @@ -83,6 +89,8 @@ def identifyUserType(obj): else: return None def identifyUtype(obj): + """Process Type of transaction based on string that passed in. + Return transaction type.""" user_logged_on = ['AUTH'] file_deleted = ["dele"] file_uploaded = ["created"] diff --git a/inexEncoder.py b/inexEncoder.py index 09ee3a9..9f81e81 100644 --- a/inexEncoder.py +++ b/inexEncoder.py @@ -3,6 +3,8 @@ import decimal import datetime class Encoder(json.JSONEncoder): + """Encoder uses json.JSONEncoder and checks for instances of decimal and datetime. + Changes decimal.Decimal to int and datetime.datetime to unix timestamp with miliseconds.""" def default(self, o): if isinstance(o, decimal.Decimal): return int(o) diff --git a/test.py b/test.py index d1c1ce3..c430b1f 100644 --- a/test.py +++ b/test.py @@ -18,4 +18,21 @@ def builddict(keys,*args,**kwargs): testfolder = '/Usr/a/asdf/asf' user = 'a' -print(testfolder.split(f"/{user}/")) \ No newline at end of file +def identifyUtype(obj): + """Process Type of transaction based on string that passed in. + Return transaction type.""" + user_logged_on = ['AUTH'] + file_deleted = ["dele"] + file_uploaded = ["created"] + file_downloaded = ["sent"] + + if obj in user_logged_on: + return "user_logged_on" + if obj in file_deleted: + return "file_deleted" + if obj in file_uploaded: + return "file_uploaded" + if obj in file_downloaded: + return "file_downloaded" + else: + return "other" \ No newline at end of file