def execAccountingModules(received): """Execute all accounting modules in [reconfigured order Input: (dict) data received from client; (dict) internal parameters; (dict) reply items; Output: (bool) True - success; False - failure """ modulesOk = True for module in acctModules: if modulesOk and module.accountingCapable: modstr = '### Accounting module "%s" ###' % module.name info ('#' * len(modstr)) info (modstr) info ('#' * len(modstr)) try: # protect received data dictionary locReceived = received.copy() # execute acct function module['acct_funct'](locReceived) except: misc.printException() modulesOk = False else: # if everything was ok # assign probably changed attribute dictionaries to original ones misc.rewriteDict(received, locReceived) # exit cycle if any module failed else: break # return module execution result return modulesOk
def execFunction(function, received = None, check = None, reply = None): """Execute preloaded function Input: (function ref) reference to function, (dict) data received from client; (dict) internal parameters; (dict) reply items; Output: (mixed) function result """ ret = None try: # protect attribute dictionaries in case of failure locReceived = received.copy() locCheck = check.copy() locReply = reply.copy() ret = function(locReceived, locCheck, locReply) except: misc.printException() ret = None else: # if everything was ok # assign probably changed attribute dictionaries to original ones misc.rewriteDict(received, locReceived) misc.rewriteDict(check, locCheck) misc.rewriteDict(reply, locReply) return ret