FIX MEGA BUG - DONT USE DEFAUL VALUE AS [] or {} - python has been save it between call if arg is not transmitted

dev-linux
Ivan Maslov 4 years ago
parent f72b20a490
commit 150300de34

@ -169,9 +169,10 @@ def UACKeyListCheck(inRequest, inRoleKeyList):
# Update user access
def UACUpdate(inGSettings, inADLoginStr, inADStr="", inADIsDefaultBool=True, inURLList=[], inRoleHierarchyAllowedDict={}):
def UACUpdate(inGSettings, inADLoginStr, inADStr="", inADIsDefaultBool=True, inURLList=None, inRoleHierarchyAllowedDict=None):
lUserTurple = (inADStr.upper(),inADLoginStr.upper()) # Create turple key for inGSettings["ServerDict"]["AccessUsers"]["RuleDomainUserDict"]
if inURLList is None: inURLList = [] # Check if None
if inRoleHierarchyAllowedDict is None: inRoleHierarchyAllowedDict = {} # Check if None
# Get the old URLList
try:
inURLList += inGSettings["ServerDict"]["AccessUsers"]["RuleDomainUserDict"][lUserTurple]["MethodMatchURLBeforeList"]
@ -288,7 +289,8 @@ def WebUserUACHierarchyGet(inRequest):
return inRequest.UserRoleHierarchyGet()
## GSettings defs
def GSettingsKeyListValueSet(inGSettings, inValue, inKeyList=[]): # Set value in GSettings by the key list
def GSettingsKeyListValueSet(inGSettings, inValue, inKeyList=None): # Set value in GSettings by the key list
if inKeyList is None: inKeyList = []
lDict = inGSettings
for lItem2 in inKeyList[:-1]:
#Check if key - value exists
@ -300,7 +302,8 @@ def GSettingsKeyListValueSet(inGSettings, inValue, inKeyList=[]): # Set value in
lDict[inKeyList[-1]] = inValue #Set value
return True
def GSettingsKeyListValueGet(inGSettings, inKeyList=[]): # Get the value from the GSettings by the key list
def GSettingsKeyListValueGet(inGSettings, inKeyList=None): # Get the value from the GSettings by the key list
if inKeyList is None: inKeyList = []
lDict = inGSettings
for lItem2 in inKeyList[:-1]:
#Check if key - value exists
@ -311,7 +314,8 @@ def GSettingsKeyListValueGet(inGSettings, inKeyList=[]): # Get the value from th
lDict=lDict[lItem2]
return lDict.get(inKeyList[-1],None)
def GSettingsKeyListValueAppend(inGSettings, inValue, inKeyList=[]): # Append value in GSettings by the key list
def GSettingsKeyListValueAppend(inGSettings, inValue, inKeyList=None): # Append value in GSettings by the key list
if inKeyList is None: inKeyList = []
lDict = inGSettings
for lItem2 in inKeyList[:-1]:
#Check if key - value exists
@ -323,7 +327,8 @@ def GSettingsKeyListValueAppend(inGSettings, inValue, inKeyList=[]): # Append va
lDict[inKeyList[-1]].append(inValue) #Set value
return True
def GSettingsKeyListValueOperatorPlus(inGSettings, inValue, inKeyList=[]): # Operator plus value in GSettings by the key list
def GSettingsKeyListValueOperatorPlus(inGSettings, inValue, inKeyList=None): # Operator plus value in GSettings by the key list
if inKeyList is None: inKeyList = []
lDict = inGSettings
for lItem2 in inKeyList[:-1]:
#Check if key - value exists
@ -336,7 +341,9 @@ def GSettingsKeyListValueOperatorPlus(inGSettings, inValue, inKeyList=[]): # Ope
return True
# Add Activity item in Processor list
def ProcessorActivityItemAppend(inGSettings, inDef, inArgList=[], inArgDict={}, inArgGSettingsStr=None, inArgLoggerStr=None):
def ProcessorActivityItemAppend(inGSettings, inDef, inArgList=None, inArgDict=None, inArgGSettingsStr=None, inArgLoggerStr=None):
if inArgList is None: inArgList=[]
if inArgDict is None: inArgDict={}
lActivityList=[
{
"Def":inDef, # def link or def alias (look gSettings["Processor"]["AliasDefDict"])
@ -399,7 +406,8 @@ def ProcessStop(inProcessNameWOExeStr, inCloseForceBool, inUserNameStr = "%usern
os.system(lActivityCloseCommand)
#Check activity of the list of processes
def ProcessListGet(inProcessNameWOExeList=[]):
def ProcessListGet(inProcessNameWOExeList=None):
if inProcessNameWOExeList is None: inProcessNameWOExeList = []
'''Get list of running process sorted by Memory Usage and filtered by inProcessNameWOExeList'''
lMapUPPERInput = {} # Mapping for processes WO exe
lResult = {"ProcessWOExeList":[],"ProcessDetailList":[]}
@ -427,7 +435,9 @@ def ProcessListGet(inProcessNameWOExeList=[]):
return lResult
# Python def - start module function
def PythonStart(inModulePathStr, inDefNameStr, inArgList=[], inArgDict={}, inLogger = None): # Python import module and start def
def PythonStart(inModulePathStr, inDefNameStr, inArgList=None, inArgDict=None, inLogger = None): # Python import module and start def
if inArgList is None: inArgList=[]
if inArgDict is None: inArgDict={}
try:
lModule=importlib.import_module(inModulePathStr) #Подключить модуль для вызова
lFunction=getattr(lModule,inDefNameStr) #Найти функцию
@ -442,7 +452,9 @@ def PythonStart(inModulePathStr, inDefNameStr, inArgList=[], inArgDict={}, inLog
# # # # # # # # # # # # # # # # # # # # # # #
# Add activity in time weekly
def SchedulerActivityTimeAddWeekly(inGSettings, inTimeHHMMStr="23:55:", inWeekdayList=[], inActivityList=[]):
def SchedulerActivityTimeAddWeekly(inGSettings, inTimeHHMMStr="23:55:", inWeekdayList=None, inActivityList=None):
if inWeekdayList is None: inWeekdayList=[]
if inActivityList is None: inActivityList=[]
lActivityTimeItemDict = {
"TimeHH:MMStr": inTimeHHMMStr, # Time [HH:MM] to trigger activity
"WeekdayList": inWeekdayList, # List of the weekday index when activity is applicable, Default [1,2,3,4,5,6,7]
@ -457,7 +469,8 @@ def SchedulerActivityTimeAddWeekly(inGSettings, inTimeHHMMStr="23:55:", inWeekda
# Create some RDP template dict to use it when connect/reconnect
def RDPTemplateCreate(inLoginStr, inPasswordStr, inHostStr="127.0.0.1", inPortInt = 3389, inWidthPXInt = 1680, inHeightPXInt = 1050,
inUseBothMonitorBool = False, inDepthBitInt = 32, inSharedDriveList=["c"]):
inUseBothMonitorBool = False, inDepthBitInt = 32, inSharedDriveList=None):
if inSharedDriveList is None: inSharedDriveList = ["c"]
lRDPTemplateDict= { # Init the configuration item
"Host": inHostStr, # Host address, example "77.77.22.22"
"Port": str(inPortInt), # RDP Port, example "3389"
@ -523,7 +536,8 @@ def RDPSessionConnect(inGSettings, inRDPSessionKeyStr, inRDPTemplateDict=None, i
return True
# Disconnect the RDP session
def RDPSessionDisconnect(inGSettings, inRDPSessionKeyStr, inBreakTriggerProcessWOExeList = []):
def RDPSessionDisconnect(inGSettings, inRDPSessionKeyStr, inBreakTriggerProcessWOExeList = None):
if inBreakTriggerProcessWOExeList is None: inBreakTriggerProcessWOExeList = []
# Check thread
if not Core.IsProcessorThread(inGSettings=inGSettings):
if inGSettings["Logger"]: inGSettings["Logger"].warning(f"RDP def was called not from processor queue - activity will be append in the processor queue.")
@ -578,7 +592,8 @@ def RDPSessionMonitorStop(inGSettings, inRDPSessionKeyStr):
return lResult
# Logoff the RDP session
def RDPSessionLogoff(inGSettings, inRDPSessionKeyStr, inBreakTriggerProcessWOExeList = []):
def RDPSessionLogoff(inGSettings, inRDPSessionKeyStr, inBreakTriggerProcessWOExeList = None):
if inBreakTriggerProcessWOExeList is None: inBreakTriggerProcessWOExeList = []
lResult = True
# Check thread
if not Core.IsProcessorThread(inGSettings=inGSettings):

Loading…
Cancel
Save