示例#1
0
    def update_status(self, message=None, status_percentage=None, status=None,
            clean=True):
        """
        Update status report of currently running process instance

        :param str message: Message you need to share with the client
        :param int status_percentage: Percent done (number betwen <0-100>)
        :param pywps.app.WPSResponse.STATUS status: process status - user should usually
            ommit this parameter
        """

        if message:
            self.message = message

        if status:
            self.status = status

        if status_percentage:
            self.status_percentage = status_percentage

        # check if storing of the status is requested
        if self.status >= STATUS.STORE_AND_UPDATE_STATUS:

            # rebuild the doc and update the status xml file
            self.doc = self._construct_doc()
            self.write_response_doc(self.doc, clean)

        update_response(self.uuid, self)
示例#2
0
    def update_status(self,
                      message=None,
                      status_percentage=None,
                      status=None,
                      clean=True):
        """
        Update status report of currently running process instance

        :param str message: Message you need to share with the client
        :param int status_percentage: Percent done (number betwen <0-100>)
        :param pywps.app.WPSResponse.STATUS status: process status - user should usually
            ommit this parameter
        """

        if message:
            self.message = message

        if status:
            self.status = status

        if status_percentage:
            self.status_percentage = status_percentage

        # check if storing of the status is requested
        if self.status >= STATUS.STORE_AND_UPDATE_STATUS:

            # rebuild the doc and update the status xml file
            self.doc = self._construct_doc()
            self.write_response_doc(self.doc, clean)

        update_response(self.uuid, self)
示例#3
0
    def update_status(self, message, status_percentage=None):
        self.message = message
        if status_percentage:
            self.status_percentage = status_percentage

            # rebuild the doc and update the status xml file
            self.doc = self._construct_doc()

        # check if storing of the status is requested
        if self.status >= self.STORE_STATUS:
            self.write_response_doc(self.doc)

        update_response(self.uuid, self)
示例#4
0
    def update_status(self, message, status_percentage=None):
        self.message = message
        if status_percentage:
            self.status_percentage = status_percentage

            # rebuild the doc and update the status xml file
            self.doc = self._construct_doc()

        # check if storing of the status is requested
        if self.status >= self.STORE_STATUS:
            self.write_response_doc(self.doc)

        update_response(self.uuid, self)
示例#5
0
    def update_status(self, message=None, status_percentage=None, status=None, clean=True):
        """
        Update status report of currently running process instance

        :param str message: Message you need to share with the client
        :param int status_percentage: Percent done (number betwen <0-100>)
        :param pywps.response.status.STATUS status: process status - user should usually
            ommit this parameter
        """

        if message:
            self.message = message

        if status is not None:
            self.status = status

        if status_percentage is not None:
            self.status_percentage = status_percentage

        update_response(self.uuid, self)
示例#6
0
    def update_status(self, message=None, status_percentage=None, status=None,
                      clean=True):
        """
        Update status report of currently running process instance

        :param str message: Message you need to share with the client
        :param int status_percentage: Percent done (number betwen <0-100>)
        :param pywps.response.status.STATUS status: process status - user should usually
            ommit this parameter
        """

        if message:
            self.message = message

        if status is not None:
            self.status = status

        if status_percentage is not None:
            self.status_percentage = status_percentage

        update_response(self.uuid, self)
示例#7
0
文件: Service.py 项目: janpisl/pywps
    def __call__(self, http_request):

        request_uuid = uuid.uuid1()

        environ_cfg = http_request.environ.get('PYWPS_CFG')
        if 'PYWPS_CFG' not in os.environ and environ_cfg:
            LOGGER.debug('Setting PYWPS_CFG to %s', environ_cfg)
            os.environ['PYWPS_CFG'] = environ_cfg

        try:
            wps_request = WPSRequest(http_request)
            LOGGER.info('Request: %s', wps_request.operation)
            if wps_request.operation in [
                    'getcapabilities', 'describeprocess', 'execute'
            ]:
                log_request(request_uuid, wps_request)
                response = None
                if wps_request.operation == 'getcapabilities':

                    response = self.get_capabilities(wps_request, request_uuid)

                elif wps_request.operation == 'describeprocess':
                    response = self.describe(wps_request, request_uuid,
                                             wps_request.identifiers)

                elif wps_request.operation == 'execute':
                    response = self.execute(wps_request.identifier,
                                            wps_request, request_uuid)
                update_response(request_uuid, response, close=True)
                return response
            else:
                update_response(request_uuid, response, close=True)
                raise RuntimeError("Unknown operation %r" %
                                   wps_request.operation)

        except HTTPException as e:
            # transform HTTPException to OWS NoApplicableCode exception
            if not isinstance(e, NoApplicableCode):
                e = NoApplicableCode(e.description, code=e.code)

            class FakeResponse:
                message = e.locator
                status = e.code
                status_percentage = 100

            try:
                update_response(request_uuid, FakeResponse, close=True)
            except NoApplicableCode as e:
                return e
            return e
        except Exception as e:
            e = NoApplicableCode(
                "No applicable error code, please check error log", code=500)
            return e
示例#8
0
    def __call__(self, http_request):

        request_uuid = uuid.uuid1()

        environ_cfg = http_request.environ.get('PYWPS_CFG')
        if 'PYWPS_CFG' not in os.environ and environ_cfg:
            LOGGER.debug('Setting PYWPS_CFG to %s', environ_cfg)
            os.environ['PYWPS_CFG'] = environ_cfg

        try:
            wps_request = WPSRequest(http_request)
            LOGGER.info('Request: %s', wps_request.operation)
            if wps_request.operation in ['getcapabilities',
                                         'describeprocess',
                                         'execute']:
                log_request(request_uuid, wps_request)
                response = None
                if wps_request.operation == 'getcapabilities':
                    response = self.get_capabilities()

                elif wps_request.operation == 'describeprocess':
                    response = self.describe(wps_request.identifiers)

                elif wps_request.operation == 'execute':
                    response = self.execute(
                        wps_request.identifier,
                        wps_request,
                        request_uuid
                    )
                update_response(request_uuid, response, close=True)
                return response
            else:
                update_response(request_uuid, response, close=True)
                raise RuntimeError("Unknown operation %r"
                                   % wps_request.operation)

        except HTTPException as e:
            # transform HTTPException to OWS NoApplicableCode exception
            if not isinstance(e, NoApplicableCode):
                e = NoApplicableCode(e.description, code=e.code)

            class FakeResponse:
                message = e.locator
                status = e.code
                status_percentage = 100
            try:
                update_response(request_uuid, FakeResponse, close=True)
            except NoApplicableCode as e:
                return e
            return e
示例#9
0
    def __call__(self, http_request):
        request_uuid = uuid.uuid1()
        try:
            wps_request = WPSRequest(http_request)
            if wps_request.operation in ['getcapabilities',
                                         'describeprocess',
                                         'execute']:
                log_request(request_uuid, wps_request)
                response = None
                if wps_request.operation == 'getcapabilities':
                    response = self.get_capabilities()

                elif wps_request.operation == 'describeprocess':
                    response = self.describe(wps_request.identifiers)

                elif wps_request.operation == 'execute':
                    response = self.execute(
                        wps_request.identifier,
                        wps_request,
                        request_uuid
                    )
                update_response(request_uuid, response, close=True)
                return response
            else:
                update_response(request_uuid, response, close=True)
                raise RuntimeError("Unknown operation %r"
                                   % wps_request.operation)

        except HTTPException as e:
            # transform HTTPException to OWS NoApplicableCode exception
            if not isinstance(e, NoApplicableCode):
                e = NoApplicableCode(e.description, code=e.code)

            class FakeResponse:
                message = e.locator
                status = e.code
                status_percentage = 100
            update_response(request_uuid, FakeResponse, close=True)
            return e
示例#10
0
def wps(request):

    processes = [
        FeatureCount(),
        SayHello(),
        Centroids(),
        UltimateQuestion(),
        Sleep(),
        Buffer(),
        Area(),
        Box()
    ]
    service = Service(processes=processes)
    http_request = werkzeug_Request(request.environ)
    print type(http_request)



    request_uuid = uuid.uuid1()
    response = None
    environ_cfg = http_request.environ.get('PYWPS_CFG')
    # if not 'PYWPS_CFG' in os.environ and environ_cfg:
    #     # LOGGER.debug('Setting PYWPS_CFG to %s', environ_cfg)
    #     os.environ['PYWPS_CFG'] = environ_cfg

    # try:
    wps_request = WPSRequest(http_request)
    # LOGGER.info('Request: %s', wps_request.operation)
    if wps_request.operation in ['getcapabilities',
                                 'describeprocess',
                                 'execute']:
        # log_request(request_uuid, wps_request)
        response = None
        if wps_request.operation == 'getcapabilities':
            response = service.get_capabilities()

        elif wps_request.operation == 'describeprocess':
            response = service.describe(wps_request.identifiers)

        elif wps_request.operation == 'execute':
            response = service.execute(
                wps_request.identifier,
                wps_request,
                request_uuid
            )
        update_response(request_uuid, response, close=True)
        # return response
    else:
        update_response(request_uuid, response, close=True)
        raise RuntimeError("Unknown operation %r"
                           % wps_request.operation)

    print response.get_data()
    # except HTTPException as e:
    #     # transform HTTPException to OWS NoApplicableCode exception
    #     if not isinstance(e, NoApplicableCode):
    #         e = NoApplicableCode(e.description, code=e.code)
    #
    #     class FakeResponse:
    #         message = e.locator
    #         status = e.code
    #         status_percentage = 100
    #     update_response(request_uuid, FakeResponse, close=True)
    #     return e

    return HttpResponse(response.get_data(), content_type='application/xhtml+xml')
    #