Esempio n. 1
0
 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
Esempio n. 2
0
 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]
     muteLogs = resourceInstance.muteLogs or resourceMethod.muteLogs
     if resourceInstance.enabled and not resourceInstance.disabled and not resourceMethod.disabled:
         if not muteLogs:
             log.debug(
                 resourceMethod,
                 f'{resourceMethod.shedulerId} scheduler started with args={methodArgs} and kwargs={methodKwargs}'
             )
         methodReturn = None
         try:
             FlaskManager.validateArgs(args, requestClass,
                                       innerResourceInstanceMethod)
             methodReturn = resourceMethod(*args, **kwargs)
         except Exception as exception:
             if not muteLogs:
                 log.warning(
                     resourceMethod,
                     f'Not possible to run {resourceMethod.shedulerId} properly',
                     exception=exception,
                     muteStackTrace=True)
             FlaskManager.raiseAndPersistGlobalException(
                 exception, resourceInstance, resourceMethod)
         if not muteLogs:
             log.debug(
                 resourceMethod,
                 f'{resourceMethod.shedulerId} scheduler finished')
         return methodReturn
     if not muteLogs:
         log.warning(
             resourceMethod,
             f'{resourceMethod.shedulerId} scheduler didn{c.SINGLE_QUOTE}t started. {"Schedulers are disabled" if not resourceInstance.enabled else "This scheduler is disabled" if resourceInstance.disabled else "This scheduler method is disabled"}'
         )