def mustLogWithoutColors(): # Arrange noExceptionThrown = 'exception not thrown' someLogMessage = 'some log message' someExceptionMessage = 'some exception message' someInnerExceptionMessage = 'some inner exception message' exception = None someExceptionMessageWithStackTrace = f'{someExceptionMessage} with stacktrace' someExceptionMessageWithoutStackTrace = f'{someExceptionMessage} without stacktrace' def controlableException(logType, muteStackTrace=False): try: raise Exception( someExceptionMessageWithoutStackTrace if muteStackTrace else someExceptionMessageWithStackTrace) except Exception as exception: if logType in OPTIONAL_EXCEPTION_LOG_TYPES: logType(logType, someLogMessage, exception=exception, muteStackTrace=muteStackTrace) else: logType(logType, someLogMessage, exception, muteStackTrace=muteStackTrace) # Act log.success(log.success, someLogMessage) log.setting(log.setting, someLogMessage) log.debug(log.debug, someLogMessage) log.warning(log.warning, someLogMessage) controlableException(log.log) controlableException(log.debug) controlableException(log.warning) controlableException(log.wraper) controlableException(log.failure) controlableException(log.error) controlableException(log.test) controlableException(log.log, muteStackTrace=True) controlableException(log.debug, muteStackTrace=True) controlableException(log.warning, muteStackTrace=True) controlableException(log.wraper, muteStackTrace=True) controlableException(log.failure, muteStackTrace=True) controlableException(log.error, muteStackTrace=True) controlableException(log.test, muteStackTrace=True) log.log(log.log, someLogMessage, None) log.debug(log.debug, someLogMessage, None) log.warning(log.warning, someLogMessage, None) log.wraper(log.wraper, noExceptionThrown, None) log.failure(log.failure, noExceptionThrown, None) log.error(log.error, noExceptionThrown, None) log.test(log.test, someLogMessage, None) # Assert assert 'my environment' == EnvironmentHelper.get( SettingHelper.ACTIVE_ENVIRONMENT)
def run(self): try: self.model.metadata.create_all(self.engine) except Exception as firstException: waittingTime = 30 log.warning( self.run, f'Not possible to run. Going for a second attemp in {waittingTime} seconds', exception=firstException) time.sleep(waittingTime) try: self.model.metadata.create_all(self.engine) except Exception as secondException: waittingTime = 30 log.warning( self.run, f'Not possible to run either. Going for a third and last attemp in {waittingTime} seconds', exception=secondException) time.sleep(waittingTime) try: self.model.metadata.create_all(self.engine) except Exception as secondException: log.error(self.run, 'Not possible to run', exception) raise exception log.debug(self.run, 'Database tables created')
def getErrorMessage(clientResponse, exception=None): completeErrorMessage = f'{HttpClientConstant.ERROR_AT_CLIENT_CALL_MESSAGE}{c.DOT_SPACE}{HttpClientConstant.CLIENT_DID_NOT_SENT_ANY_MESSAGE}' errorMessage = HttpClientConstant.CLIENT_DID_NOT_SENT_ANY_MESSAGE possibleErrorMessage = None bodyAsJson = {} try : bodyAsJson = clientResponse.json() except Exception as innerException : bodyAsJsonException = FlaskUtil.safellyGetResponseJson(clientResponse) log.log(getErrorMessage, f'Invalid client response: {bodyAsJsonException}', exception=innerException) log.debug(getErrorMessage, f'Not possible to get error message from client response: {bodyAsJsonException}. Proceeding with value {bodyAsJson} by default', exception=innerException, muteStackTrace=True) try: if ObjectHelper.isNotNone(clientResponse): if ObjectHelper.isDictionary(bodyAsJson): possibleErrorMessage = bodyAsJson.get('message', bodyAsJson.get('error')).strip() if ObjectHelper.isList(bodyAsJson) and 0 < len(bodyAsJson): possibleErrorMessage = bodyAsJson[0].get('message', bodyAsJson[0].get('error')).strip() if ObjectHelper.isNotNone(possibleErrorMessage) and StringHelper.isNotBlank(possibleErrorMessage): errorMessage = f'{c.LOG_CAUSE}{possibleErrorMessage}' else: log.debug(getErrorMessage, f'Client response {FlaskUtil.safellyGetResponseJson(clientResponse)}') exceptionPortion = HttpClientConstant.ERROR_AT_CLIENT_CALL_MESSAGE if ObjectHelper.isNone(exception) or StringHelper.isBlank(exception) else str(exception) completeErrorMessage = f'{exceptionPortion}{c.DOT_SPACE}{errorMessage}' except Exception as exception: log.warning(getErrorMessage, f'Not possible to get error message. Returning {completeErrorMessage} by default', exception=exception) return completeErrorMessage
def __init__(self, *args, **kwargs): log.debug( OuterClass, f'in {InnerClass.__name__}.__init__(*{args},**{kwargs})') OuterClass.__init__(self, *args, **kwargs) self.repository = apiInstance.repository self.globals = apiInstance.globals
def validateResponseClass(responseClass, controllerResponse): log.debug(validateResponseClass, controllerResponse) if responseClass: if not controllerResponse and not isinstance(controllerResponse, list): raiseBadResponseImplementetion(f'Response not present') if isinstance(responseClass, list): if 0 == len(responseClass): raiseBadResponseImplementetion( f'"responseClass" was not defined') elif len(responseClass) == 1: if not isinstance(responseClass[0], list): if not isinstance(controllerResponse, responseClass[0]): raiseBadResponseImplementetion( f'Response class does not match expected class. Expected "{responseClass[0].__name__}", response "{controllerResponse.__class__.__name__}"' ) elif not isinstance(responseClass[0][0], list): if not isinstance(controllerResponse, list): raiseBadResponseImplementetion( f'Response is not a list. Expected "{responseClass[0].__class__.__name__}", but found "{controllerResponse.__class__.__name__}"' ) elif isinstance(controllerResponse, list) and len( controllerResponse) > 0 and not isinstance( controllerResponse[0], responseClass[0][0]): # print(f'responseClass = {responseClass}') # print(f'responseClass[0] = {responseClass[0]}') # print(f'responseClass[0][0] = {responseClass[0][0]}') raiseBadResponseImplementetion( f'Response element class does not match expected element class. Expected "{responseClass[0][0].__name__}", response "{controllerResponse[0].__class__.__name__}"' ) else: if not isinstance(controllerResponse, responseClass): raiseBadResponseImplementetion( f'Response class does not match expected class. Expected "{responseClass.__name__}", response "{controllerResponse.__class__.__name__}"' )
def __init__(self, *args, **kwargs): log.debug( OuterClass, f'in {InnerClass.__name__}.__init__(*{args},**{kwargs})') OuterClass.__init__(self, *args, **kwargs) self.helper = apiInstance.resource.helper self.converter = apiInstance.resource.converter
def addControllerListTo(apiInstance, controllerList): for controller in controllerList: OpenApiManager.addControllerDocumentation(controller, apiInstance) mainUrl = f'{apiInstance.baseUrl}{controller.url}' urlList = [mainUrl] infoList = [f'Controller: {mainUrl}'] controllerMethodList = ReflectionHelper.getAttributePointerList( controller) for controllerMethod in controllerMethodList: if ReflectionHelper.hasAttributeOrMethod( controllerMethod, FlaskManager.KW_URL) and ObjectHelper.isNotEmpty( controllerMethod.url): controllerUrl = f'{mainUrl}{controllerMethod.url}' if controllerUrl not in urlList: urlList.append(controllerUrl) infoList.append( f'{c.TAB}{ReflectionHelper.getName(controllerMethod)}: {controllerUrl}' ) # subUrlList = controllerMethod.url.split(c.SLASH) # concatenatedSubUrl = c.NOTHING # for subUrl in subUrlList : # if subUrl : # concatenatedSubUrl += f'{c.SLASH}{subUrl}' # if c.LESSER == subUrl[0] and c.BIGGER == subUrl[-1] : # newUrl = f'{apiInstance.baseUrl}{controller.url}{concatenatedSubUrl}' # if not newUrl in urlList : # urlList.append(newUrl) OpenApiManager.addEndPointDocumentation( controllerUrl, controllerMethod, controller, apiInstance) log.debug( addControllerListTo, f'{controller.url} -> {StringHelper.prettyPython(infoList)}') apiInstance.add_resource(controller, *urlList)
def handleCommandList(self, commandList): globals = self.globals log.debug(self.__class__, f'{self.__class__.__name__}.commandList = {commandList}') log.debug(self.__class__, f'session = {self.session}') return self.apiSet[commandList[self._0_API_KEY]][commandList[ self._1_COMMAND]](commandList)
def inteligentLoop(self) : log.debug(self.inteligentLoop, 'starded') try : self.service.conversation.inteligentLoop() except Exception as exception : log.error(self.inteligentLoop, 'Error at scheduler', exception) log.debug(self.inteligentLoop, 'ended')
def __init__(self, *args, **kwargs): log.debug( OuterClass, f'in {InnerClass.__name__}.__init__(*{args},**{kwargs})') OuterClass.__init__(self) flask_restful.Resource.__init__(self, *args, **kwargs) self.service = apiInstance.resource.service
def handleSystemArgumentValue(self, commandList, externalFunction): globals = self.globals try: if self.apiClassSet: apiClass = self.apiClassSet.get(commandList[self._0_API_KEY]) if apiClass and apiClass in [self.__class__, GitCommitter]: log.success(self.__class__, f'running {commandList} command list') return self.handleCommandList(commandList) elif apiClass: globals.overrideApiTree(apiClass.__name__, package=apiClass.__name__) api = apiClass(*self.args, **self.kwargs) log.success( self.__class__, f'running {apiClass.__name__}({self.args}, {self.kwargs})' ) return api.handleCommandList(commandList) else: log.failure( self.__class__, f'''couldn't instance api class of {commandList[self._0_API_KEY]}''', c.NOTHING) else: log.debug( self.__class__, f'{commandList[self._0_API_KEY]} key called and running all alone' ) return externalFunction(commandList, globals, **self.kwargs) except Exception as exception: errorMessage = str(exception) if self.MISSING_REQUIRED_ARGUMENT in errorMessage: newArgs = *self.args, self.globals try: api = apiClass(*newArgs, **self.kwargs) log.success( self.__class__, f'running {apiClass.__name__}({self.args}, {self.kwargs})' ) return api.handleCommandList(commandList) except Exception as exception: secondErrorMessage = f', after first try: {str(exception)}' newArgs = *self.args, self.session, self.globals try: api = apiClass(*newArgs, **self.kwargs) log.success( self.__class__, f'running {apiClass.__name__}({self.args}, {self.kwargs})' ) return api.handleCommandList(commandList) except Exception as exception: thirdErrorMessage = f', after second try: {str(exception)}' else: secondErrorMessage = '' thirdErrorMessage = '' globals.error( self.__class__, f'error processing "{commandList[self._0_API_KEY]}" call{secondErrorMessage}{thirdErrorMessage}', errorMessage)
def __init__(self, *args, **kwargs): log.debug( OuterClass, f'in {InnerClass.__name__}.__init__(*{args},**{kwargs})') apiInstance = FlaskManager.getApi() OuterClass.__init__(self, *args, **kwargs) self.globals = apiInstance.globals self.service = apiInstance.resource.service
def __init__(self,*args,**kwargs): log.debug(OuterClass,f'in {InnerClass.__name__}.__init__(*{args},**{kwargs})') OuterClass.__init__(self,*args,**kwargs) apiInstance = FlaskManager.getApi() self.service = apiInstance.resource.service self.validator = apiInstance.resource.validator self.helper = apiInstance.resource.helper self.converter = apiInstance.resource.converter
def validateAndReturnResponse(completeResponse): if (ObjectHelper.isNotTuple(completeResponse) or not 3 == len(completeResponse)) or (ObjectHelper.isNotDictionary( completeResponse[1])) or (not isinstance( HttpStatus.map(completeResponse[-1]), EnumItem)): log.debug(validateAndReturnResponse, f'Invalid completeResponse: {completeResponse}') raise Exception('Invalid complete response') return completeResponse
def getNewBrowser(self, options=None, hidden=False) : options = options if ObjectHelper.isNotNone(options) else self.getBrowserOptions() browser = BrowserConstants.BOWSER_CLASS(ChromeDriverManager().install(), chrome_options=options) browser.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": f'{USER_AGENT}'}) browser.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})") log.debug(self.getNewBrowser, f'session_id: {browser.session_id}') log.debug(self.getNewBrowser, f'command_executor: {browser.command_executor._url}') return browser
def getStaticFolder(apiInstance, appInstance): globalsInstance = apiInstance.globals pythonFrameworkStaticFiles = f'{globalsInstance.OS_SEPARATOR}python_framework{globalsInstance.OS_SEPARATOR}api{globalsInstance.OS_SEPARATOR}resource' swaggerStaticFiles = f'{globalsInstance.OS_SEPARATOR}{KW_OPEN_API}{KW_UI}{globalsInstance.OS_SEPARATOR}' apiInstance.documentationFolderPath = f'{globalsInstance.staticPackage}{pythonFrameworkStaticFiles}{swaggerStaticFiles}' log.debug( getStaticFolder, f'apiInstance.documentationFolderPath at "{apiInstance.documentationFolderPath}"' ) return apiInstance.documentationFolderPath
def testing_Client(): #arrange muteLogs = False process = getProcess( f'python app.py', f'{CURRENT_PATH}{EnvironmentHelper.OS_SEPARATOR}apitests{EnvironmentHelper.OS_SEPARATOR}testone', muteLogs=muteLogs) time.sleep(ESTIMATED_BUILD_TIME_IN_SECONDS) log.debug(log.debug, f'variant: {EnvironmentHelper.get("URL_VARIANT")}') killProcesses(process)
def Wrapper(OuterClass, *args, **kwargs): log.debug(Client,f'''wrapping {OuterClass.__name__}''') class InnerClass(OuterClass): url = controllerUrl def __init__(self,*args,**kwargs): log.debug(OuterClass,f'in {InnerClass.__name__}.__init__(*{args},**{kwargs})') apiInstance = FlaskManager.getApi() OuterClass.__init__(self,*args,**kwargs) self.globals = apiInstance.globals ReflectionHelper.overrideSignatures(InnerClass, OuterClass) return InnerClass
def innerMethodWrapper(resourceInstanceMethod,*args,**kwargs) : log.debug(ValidatorMethod,f'''wrapping {resourceInstanceMethod.__name__}''') def innerResourceInstanceMethod(*args,**kwargs) : resourceInstance = args[0] try : FlaskManager.validateArgs(args,requestClass,innerResourceInstanceMethod) methodReturn = resourceInstanceMethod(*args,**kwargs) except Exception as exception : FlaskManager.raiseGlobalException(exception, resourceInstance, resourceInstanceMethod) return methodReturn ReflectionHelper.overrideSignatures(innerResourceInstanceMethod, resourceInstanceMethod) return innerResourceInstanceMethod
def __init__(self, *args, **kwargs): log.debug( OuterClass, f'in {InnerClass.__name__}.__init__(*{args},**{kwargs})') OuterClass.__init__(self, *args, **kwargs) self.globals = apiInstance.globals self.service = apiInstance.resource.service self.repository = apiInstance.resource.repository self.validator = apiInstance.resource.validator self.mapper = apiInstance.resource.mapper self.helper = apiInstance.resource.helper self.converter = apiInstance.resource.converter
def addSwagger(apiInstance, appInstance): documentationUrl = f'{apiInstance.baseUrl}{c.SLASH}{KW_OPEN_API}' swaggerUi = get_swaggerui_blueprint( documentationUrl, OpenApiDocumentationFile.getDocumentationFileName(apiInstance)) log.debug( addSwagger, f'swaggerUi._static_folder before reassignment: "{swaggerUi._static_folder}"' ) swaggerUi._static_folder = getStaticFolder(apiInstance, appInstance) appInstance.register_blueprint(swaggerUi, url_prefix=documentationUrl) OpenApiDocumentationFile.overrideDocumentation(apiInstance)
def Wrapper(OuterClass, *args, **kwargs): log.debug(Validator,f'''wrapping {OuterClass.__name__}''') class InnerClass(OuterClass): def __init__(self,*args,**kwargs): log.debug(OuterClass,f'in {InnerClass.__name__}.__init__(*{args},**{kwargs})') OuterClass.__init__(self,*args,**kwargs) apiInstance = FlaskManager.getApi() self.service = apiInstance.resource.service self.validator = apiInstance.resource.validator self.helper = apiInstance.resource.helper self.converter = apiInstance.resource.converter ReflectionHelper.overrideSignatures(InnerClass, OuterClass) return InnerClass
def Wrapper(OuterClass, *args, **kwargs): log.debug(SimpleClient, f'''wrapping {OuterClass.__name__}''') class InnerClass(OuterClass): def __init__(self, *args, **kwargs): log.debug( OuterClass, f'in {InnerClass.__name__}.__init__(*{args},**{kwargs})') OuterClass.__init__(self, *args, **kwargs) self.globals = getApi().globals ReflectionHelper.overrideSignatures(InnerClass, OuterClass) return InnerClass
def innerMethodWrapper(resourceInstanceMethod, *args, **kwargs): noException = None log.debug(ControllerMethod, f'''wrapping {resourceInstanceMethod.__name__}''') def innerResourceInstanceMethod(*args, **kwargs): resourceInstance = args[0] try: if roleRequired and (type(list()) == type(roleRequired) and not [] == roleRequired): completeResponse = securedMethod(args, kwargs, consumes, resourceInstance, resourceInstanceMethod, requestClass, roleRequired) else: completeResponse = notSecuredMethod( args, kwargs, consumes, resourceInstance, resourceInstanceMethod, requestClass) validateResponseClass(responseClass, completeResponse[0]) except Exception as exception: completeResponse = getCompleteResponseByException( exception, resourceInstance, resourceInstanceMethod) ###- request.method: GET ###- request.url: http://127.0.0.1:5000/alert/dingding/test?x=y ###- request.base_url: http://127.0.0.1:5000/alert/dingding/test ###- request.url_charset: utf-8 ###- request.url_root: http://127.0.0.1:5000/ ###- str(request.url_rule): /alert/dingding/test ###- request.host_url: http://127.0.0.1:5000/ ###- request.host: 127.0.0.1:5000 ###- request.script_root: ###- request.path: /alert/dingding/test ###- request.full_path: /alert/dingding/test?x=y ###- request.args: ImmutableMultiDict([('x', 'y')]) ###- request.args.get('x'): y controllerResponse = completeResponse[0] status = completeResponse[1] return jsonifyResponse(controllerResponse, produces, status) overrideSignatures(innerResourceInstanceMethod, resourceInstanceMethod) innerResourceInstanceMethod.url = controllerMethodUrl innerResourceInstanceMethod.requestClass = controllerMethodRequestClass innerResourceInstanceMethod.responseClass = controllerMethodResponseClass innerResourceInstanceMethod.roleRequired = controllerMethodRoleRequired innerResourceInstanceMethod.produces = controllerMethodProduces innerResourceInstanceMethod.consumes = controllerMethodConsumes return innerResourceInstanceMethod
def innerMethodWrapper(resourceInstanceMethod,*args,**kwargs) : log.debug(ClientMethod,f'''wrapping {resourceInstanceMethod.__name__}''') def innerResourceInstanceMethod(*args,**kwargs) : resourceInstance = args[0] completeResponse = None if logRequest : log.prettyJson( resourceInstanceMethod, 'bodyRequest', json.loads(Serializer.jsonifyIt(args[1:])), condition = logRequest, logLevel = log.DEBUG ) try : FlaskManager.validateKwargs( kwargs, resourceInstance, innerResourceInstanceMethod, requestHeaderClass = requestHeaderClass, requestParamClass = requestParamClass ) FlaskManager.validateArgs(args, requestClass, innerResourceInstanceMethod) completeResponse = resourceInstanceMethod(*args,**kwargs) FlaskManager.validateResponseClass(responseClass, completeResponse) except Exception as exception : log.warning(innerResourceInstanceMethod, 'Not posssible to complete request', exception=exception) raise exception controllerResponse = completeResponse[0] if ObjectHelper.isNotNone(completeResponse[0]) else {'message' : completeResponse[1].enumName} if logResponse : log.prettyJson( resourceInstanceMethod, 'bodyResponse', json.loads(Serializer.jsonifyIt(controllerResponse)), condition = logResponse, logLevel = log.DEBUG ) return completeResponse[0] ReflectionHelper.overrideSignatures(innerResourceInstanceMethod, resourceInstanceMethod) innerResourceInstanceMethod.url = controllerMethodUrl innerResourceInstanceMethod.requestHeaderClass = controllerMethodRequestHeaderClass innerResourceInstanceMethod.requestParamClass = controllerMethodRequestParamClass innerResourceInstanceMethod.requestClass = controllerMethodRequestClass innerResourceInstanceMethod.responseClass = controllerMethodResponseClass innerResourceInstanceMethod.roleRequired = controllerMethodRoleRequired innerResourceInstanceMethod.produces = controllerMethodProduces innerResourceInstanceMethod.consumes = controllerMethodConsumes innerResourceInstanceMethod.logRequest = controllerMethodLogRequest innerResourceInstanceMethod.logResponse = controllerMethodLogResponse return innerResourceInstanceMethod
def __init__(self, model, globals, echo=False, connectArgs=None): self.globals = globals self.sqlalchemy = sqlalchemy dialect = self.globals.getSetting( f'{self.KW_API}{c.DOT}{self.KW_DATABASE}{c.DOT}{self.KW_REPOSITORY_DIALECT}' ) self.engine = self.getNewEngine(dialect, echo, connectArgs) self.session = scoped_session(sessionmaker( self.engine)) ###- sessionmaker(bind=self.engine)() # self.session = scoped_session(sessionmaker(autocommit=True, autoflush=True, bind=self.engine)) ###- sessionmaker(bind=self.engine)() self.model = model self.model.metadata.bind = self.engine # self.model.metadata.reflect() # self.run() log.debug(self.__init__, 'Database initialized')
def Wrapper(OuterClass, *args, **kwargs): log.debug(Scheduler, f'''wrapping {OuterClass.__name__}''') class InnerClass(OuterClass): def __init__(self, *args, **kwargs): log.debug( OuterClass, f'in {InnerClass.__name__}.__init__(*{args},**{kwargs})') apiInstance = FlaskManager.getApi() OuterClass.__init__(self, *args, **kwargs) self.globals = apiInstance.globals self.service = apiInstance.resource.service ReflectionHelper.overrideSignatures(InnerClass, OuterClass) return InnerClass
def inBetweenFunction(function, *argument, **keywordArgument): log.debug(initialize, f'''{function.__name__} method''') if (openInBrowser): log.debug(initialize, f'''Openning "{url}" url in rowser''') webbrowser.open_new(url) def innerFunction(*args, **kwargs): try: functionReturn = function(*args, **kwargs) except Exception as exception: raise Exception( f'Failed to initialize. Cause: {str(exception)}') return functionReturn return innerFunction
def innerMethodWrapper(resourceInstanceMethod, *innerMethodArgs, **innerMethodKwargs): log.debug(SchedulerMethod, f'''wrapping {resourceInstanceMethod.__name__}''') apiInstance = FlaskManager.getApi() methodClassName = ReflectionHelper.getMethodClassName( resourceInstanceMethod) methodName = ReflectionHelper.getName(resourceInstanceMethod) methodKwargs['id'] = methodKwargs.get( 'id', f'{methodClassName}{c.DOT}{methodName}') instancesUpTo = methodKwargs.pop('instancesUpTo', 1) weekDays = methodKwargs.pop('weekDays', None) if ObjectHelper.isNotEmpty( methodArgs ) and SchedulerType.CRON == methodArgs[0] and ObjectHelper.isNotNone( weekDays) and StringHelper.isNotBlank(weekDays): methodKwargs['day_of_week'] = weekDays if ObjectHelper.isNotNone(instancesUpTo): methodKwargs['max_instances'] = instancesUpTo shedulerArgs = [*methodArgs] shedulerKwargs = {**methodKwargs} @apiInstance.scheduler.task(*shedulerArgs, **shedulerKwargs) def innerResourceInstanceMethod(*args, **kwargs): resourceInstanceName = methodClassName[:-len( FlaskManager.KW_SCHEDULER_RESOURCE)] resourceInstanceName = f'{resourceInstanceName[0].lower()}{resourceInstanceName[1:]}' args = FlaskManager.getArgumentInFrontOfArgs( args, ReflectionHelper.getAttributeOrMethod( apiInstance.resource.scheduler, resourceInstanceName)) resourceInstance = args[0] methodReturn = None try: FlaskManager.validateArgs(args, requestClass, innerResourceInstanceMethod) methodReturn = resourceInstanceMethod(*args, **kwargs) except Exception as exception: FlaskManager.raiseGlobalException(exception, resourceInstance, resourceInstanceMethod) log.log(innerResourceInstanceMethod, f'Not possible to run {shedulerId} properly', exception=exception) return methodReturn ReflectionHelper.overrideSignatures(innerResourceInstanceMethod, resourceInstanceMethod) return innerResourceInstanceMethod
def Wrapper(OuterClass, *args, **kwargs): apiInstance = getApi() noException = None log.debug(Converter, f'''wrapping {OuterClass.__name__}''') class InnerClass(OuterClass): def __init__(self, *args, **kwargs): log.debug( OuterClass, f'in {InnerClass.__name__}.__init__(*{args},**{kwargs})') OuterClass.__init__(self, *args, **kwargs) self.helper = apiInstance.resource.helper self.converter = apiInstance.resource.converter overrideSignatures(InnerClass, OuterClass) return InnerClass