fix(home directory) #15 home directory not correct

This commit is contained in:
Jonathan Branan 2024-08-26 13:50:35 -05:00
parent cb96b00e8d
commit 394c276131
2 changed files with 21 additions and 6 deletions

View File

@ -17,6 +17,7 @@ def processData(data, template, **kwargs):
continue
userType = identifyUserType(row.get('user_type'))
userHome = parseHomefolder(row.get('Actor'),row.get('VirtualFolderName'))
try:
processedData.append(template(identifyUtypecommand,\
prd_ext_tenant_name=kwargs.get('prd_ext_tenant_name'),\
@ -45,7 +46,7 @@ def processData(data, template, **kwargs):
duration=row.get('TransferTime'),\
user_type=userType,\
user_name=row.get('Actor'),\
user_home_directory=row.get('VirtualFolderName'),\
user_home_directory=userHome,\
utype=identifyUtypecommand))
except UnboundLocalError:
print(f'Problem row GUID:{row.get("TransactionGUID")} ::: TransactionObject:{row.get("TransactionObject")} Command: {row.get("Command")}')
@ -80,7 +81,7 @@ def processData(data, template, **kwargs):
user_uid=row.get('TransactionID'),\
user_type=userType,\
user_name=row.get('Actor'),\
user_home_directory=row.get('PhysicalFolderName'),\
user_home_directory=userHome,\
utype=identifyUtypetransactionObject\
))
transactionLoginid.append(row.get('TransactionGUID'))
@ -100,6 +101,14 @@ def identifyUserType(obj):
else:
return None
def parseHomefolder(user, virtualfolder):
if user:
userSplit = f'/{user}/'
if virtualfolder:
if userSplit in virtualfolder:
home = virtualfolder.split(userSplit)[0] + userSplit
return home if home else None
def identifyUtype(obj):
"""Process Type of transaction based on string that passed in.
Return transaction type."""

14
test.py
View File

@ -15,8 +15,6 @@ def builddict(keys,*args,**kwargs):
dict[key] = kwargs.get(key)
print(dict)
testfolder = '/Usr/a/asdf/asf'
user = 'a'
def identifyUtype(obj):
"""Process Type of transaction based on string that passed in.
@ -37,6 +35,14 @@ def identifyUtype(obj):
else:
return "other"
transactionType = 'file_uploaded'
print(transactionType.split("_")[1].rstrip("d").rstrip("e"))
testfolder = '/Usr/a/asdf/asf/asdfas/asdfasdf/'
user = 'a'
def parsehomefolder(user, virtualfolder):
userSplit = f'/{user}/'
home = virtualfolder.split(userSplit)[0] + userSplit
print(home)
return home
a = parsehomefolder(user, testfolder)