예제 #1
0
 def __init__(self, core: StratusCore, type: str, **kwargs):
     StratusClient.__init__(self, type, **kwargs)
     self.app: StratusAppBase = core.getApplication()
예제 #2
0
파일: app.py 프로젝트: ShintuJoseph/stratus
    def updateInteractions(self):
        pass

    def addApis( self, app ):
        apiListParm = self.core.parms.get("API",None)
        apiList = self.available_apis if apiListParm is None else apiListParm.split(",")
        for apiName in self.available_apis:
            if apiName in apiList:
                try:
                    package_name = f"stratus.handlers.rest.api.{apiName}.app"
                    module = importlib.import_module( package_name )
                    constructor = getattr( module, "RestAPI" )
                    rest_api: RestAPIBase = constructor( apiName, self )
                    rest_api.instantiate( app )
                    self.apis.append( rest_api )
                except Exception as err:
                    self.logger.error( f"Error instantiating api {apiName}: {str(err)}\n" + traceback.format_exc( ))

    @staticmethod
    def render_server_error( ex: Exception ):
        print( str( ex ) )
        traceback.print_exc()
        return Response(response=json.dumps({ 'message': getattr(ex, 'message', repr(ex)), "code": 500, "rid": "", "status": "error" } ), status=500, mimetype="application/json")

if __name__ == "__main__":
    HERE = os.path.dirname(os.path.abspath(__file__))
    SETTINGS_FILE = os.path.join(HERE, "wps_server_edas_settings.ini")
    core = StratusCore( SETTINGS_FILE  )
    app: StratusApp = core.getApplication()
    app.start()
예제 #3
0
        tb = traceback.format_exc()
        self.logger.error("@@STRATUS-APP: Execution error: " + str(ex))
        self.logger.error(tb)
        response = {"status": "error", "error": str(ex), "traceback": tb}
        self.sendResponseMessage(StratusResponse(rid, response))

    def updateInteractions(self):
        self.processRequests()
        self.processResults()

    def term(self, msg):
        self.logger.info("@@STRATUS-APP: !!EDAS Shutdown: " + msg)
        self.active = False
        self.auth.stop()
        self.logger.info("@@STRATUS-APP: QUIT PythonWorkerPortal")
        try:
            self.request_socket.close()
        except Exception:
            pass
        self.logger.info("@@STRATUS-APP: CLOSE request_socket")
        self.responder.close_connection()
        self.logger.info("@@STRATUS-APP: TERM responder")
        self.shutdown()
        self.logger.info("@@STRATUS-APP: shutdown complete")


if __name__ == "__main__":
    core = StratusCore("test_settings1.ini")
    app = core.getApplication()
    app.start()
예제 #4
0
from typing import List, Dict, Any, Sequence, BinaryIO, TextIO, ValuesView, Optional
from stratus_endpoint.handler.base import TaskHandle
import os

testEndpoint = dict(type="endpoint",
                    module="stratus.handlers.endpoint.test",
                    object="TestEndpoint1")

if __name__ == "__main__":

    settings = dict(stratus=dict(type="test"),
                    test1=testEndpoint,
                    test2=testEndpoint,
                    test3=testEndpoint)
    stratus = StratusCore(settings)
    app = stratus.getApplication()

    operation = [
        dict(name='test1:op', result="r1", cid="C0", workTime="3.0"),
        dict(name='test2:op', result="r2", cid="C1", workTime="6.0"),
        dict(name='test3:op',
             input=["r1", "r2"],
             result="r3",
             cid="C2",
             workTime="1.0")
    ]
    request = dict(operation=operation, rid="R0", cid="C0")

    app.submitWorkflow(request)
    for taskHandle in taskHandles.values():
        result = taskHandle.getResult()