Example #1
0
    def setUp(self):
        super(WCSTransactionTestCase, self).setUp()
        logger.debug("WCSTransactionTestCase for ID: %s" % self.ID)
        
        if self.isAsync:
            from eoxserver.resources.processes.tracker import (
                dequeueTask, TaskStatus, startTask, stopTaskSuccessIfNotFinished
            )

            # get a pending task from the queue
            taskId = dequeueTask(1)[0]

            # create instance of TaskStatus class
            pStatus = TaskStatus( taskId )
            try:
                # get task parameters and change status to STARTED
                requestType , requestID , requestHandler , inputs = startTask( taskId )
                # load the handler
                module , _ , funct = requestHandler.rpartition(".")
                handler = getattr( __import__(module,fromlist=[funct]) , funct )
                # execute handler
                handler( pStatus , inputs )
                # if no terminating status has been set do it right now
                stopTaskSuccessIfNotFinished( taskId )
            except Exception as e :
                pStatus.setFailure( unicode(e) )
        
        # Add DescribeCoverage request/response
        request = "service=WCS&version=2.0.0&request=DescribeCoverage&coverageid=%s" % str( self.ID )
        self.responseDescribeCoverage = self.client.get('/ows?%s' % request)

        # Add GetCoverage request/response
        request = "service=WCS&version=2.0.0&request=GetCoverage&format=image/tiff&mediatype=multipart/mixed&coverageid=%s" % str( self.ID )
        self.responseGetCoverage = self.client.get('/ows?%s' % request)
        
        # Add delete coverage request/response
        requestBegin = """<wcst:Transaction service="WCS" version="1.1"
            xmlns:wcst="http://www.opengis.net/wcs/1.1/wcst" 
            xmlns:ows="http://www.opengis.net/ows/1.1" 
            xmlns:xlink="http://www.w3.org/1999/xlink" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xsi:schemaLocation="http://www.opengis.net/wcs/1.1/wcst http://schemas.opengis.net/wcst/1.1/wcstTransaction.xsd">
            <wcst:InputCoverages>
                <wcst:Coverage>
                    <ows:Identifier>"""
        requestEnd = """</ows:Identifier>
                    <wcst:Action codeSpace=\"http://schemas.opengis.net/wcs/1.1.0/actions.xml\">
                        Delete
                    </wcst:Action>"
                </wcst:Coverage>
            </wcst:InputCoverages>
        </wcst:Transaction>"""
        request =  requestBegin + self.ID + requestEnd
        self.responseDeleteCoverage = self.client.post('/ows', request, "text/xml")

        # Add DescribeCoverage request/response after delete
        request = "service=WCS&version=2.0.0&request=DescribeCoverage&coverageid=%s" % str( self.ID )
        self.responseDescribeCoverageDeleted = self.client.get('/ows?%s' % request)
Example #2
0
def taskDispatch(taskID, threadID):
    """ 
        task dispatcher 

        based on the request class the right request hadler is used 
        to process the asynchronous requets 
    """
    # status logger
    pStatus = TaskStatus(taskID, dbLock)

    try:

        # get task parameters
        requestType, requestID, requestHandler, inputs = dbLocker(
            dbLock, startTask, taskID)

        info("[%3.3i] PROCESS: %s %s is running ... " %
             (threadID, requestType, requestID))

        # create importer object
        imp = Importer(requestHandler)

        # try to load the right module and handler
        imp.loadHandler()

        # execute handler - proper status logging is duty of the callback
        imp.handler(pStatus, inputs)

        # try to unload the handler
        imp.unloadHandler()

        # if no terminating status has been set do it right now
        dbLocker(dbLock, stopTaskSuccessIfNotFinished, taskID)

        info("[%3.3i] PROCESS: %s %s is finished ... " %
             (threadID, requestType, requestID))

    except (KeyboardInterrupt, SystemExit):
        raise
    except Exception as e:

        pStatus.setFailure(unicode(e))

        # finish the task
        error("[%3.3i] %s " % (threadID, unicode(e)))
Example #3
0
def taskDispatch( taskID , threadID ) : 
    """ 
        task dispatcher 

        based on the request class the right request hadler is used 
        to process the asynchronous requets 
    """ 
    # status logger 
    pStatus = TaskStatus( taskID , dbLock ) 

    try: 

        # get task parameters 
        requestType , requestID , requestHandler , inputs = dbLocker( dbLock , startTask , taskID ) 

        info( "[%3.3i] PROCESS: %s %s is running ... " % ( threadID , requestType , requestID ) ) 

        # create importer object 
        imp = Importer( requestHandler ) 

        # try to load the right module and handler 
        imp.loadHandler() 

        # execute handler - proper status logging is duty of the callback 
        imp.handler( pStatus , inputs ) 

        # try to unload the handler 
        imp.unloadHandler() 

        # if no terminating status has been set do it right now 
        dbLocker( dbLock , stopTaskSuccessIfNotFinished , taskID )

        info( "[%3.3i] PROCESS: %s %s is finished ... " % ( threadID , requestType , requestID ) ) 

    except (KeyboardInterrupt,SystemExit): raise 
    except Exception as e : 

        pStatus.setFailure( unicode(e) ) 

        # finish the task 
        error( "[%3.3i] %s " % ( threadID , unicode(e) ) ) 
Example #4
0
    def setUp(self):
        super(WCSTransactionTestCase, self).setUp()
        logger.debug("WCSTransactionTestCase for ID: %s" % self.ID)

        if self.isAsync:
            from eoxserver.resources.processes.tracker import (
                dequeueTask, TaskStatus, startTask,
                stopTaskSuccessIfNotFinished)

            # get a pending task from the queue
            taskId = dequeueTask(1)[0]

            # create instance of TaskStatus class
            pStatus = TaskStatus(taskId)
            try:
                # get task parameters and change status to STARTED
                requestType, requestID, requestHandler, inputs = startTask(
                    taskId)
                # load the handler
                module, _, funct = requestHandler.rpartition(".")
                handler = getattr(__import__(module, fromlist=[funct]), funct)
                # execute handler
                handler(pStatus, inputs)
                # if no terminating status has been set do it right now
                stopTaskSuccessIfNotFinished(taskId)
            except Exception as e:
                pStatus.setFailure(unicode(e))

        # Add DescribeCoverage request/response
        request = (
            "service=WCS&version=2.0.0&request=DescribeCoverage&coverageid=%s"
            % str(self.ID))
        self.responseDescribeCoverage = self.client.get('/ows?%s' % request)

        # Add GetCoverage request/response
        request = (
            "service=WCS&version=2.0.0&request=GetCoverage&format=image/tiff"
            "&mediatype=multipart/mixed&coverageid=%s" % str(self.ID))
        self.responseGetCoverage = self.client.get('/ows?%s' % request)

        # Add delete coverage request/response
        requestBegin = """<wcst:Transaction service="WCS" version="1.1"
            xmlns:wcst="http://www.opengis.net/wcs/1.1/wcst"
            xmlns:ows="http://www.opengis.net/ows/1.1"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.opengis.net/wcs/1.1/wcst http://schemas.opengis.net/wcst/1.1/wcstTransaction.xsd">
            <wcst:InputCoverages>
                <wcst:Coverage>
                    <ows:Identifier>"""
        requestEnd = """</ows:Identifier>
                    <wcst:Action codeSpace=\"http://schemas.opengis.net/wcs/1.1.0/actions.xml\">
                        Delete
                    </wcst:Action>"
                </wcst:Coverage>
            </wcst:InputCoverages>
        </wcst:Transaction>"""
        request = requestBegin + self.ID + requestEnd
        self.responseDeleteCoverage = self.client.post('/ows', request,
                                                       "text/xml")

        # Add DescribeCoverage request/response after delete
        request = (
            "service=WCS&version=2.0.0&request=DescribeCoverage&coverageid=%s"
            % str(self.ID))
        self.responseDescribeCoverageDeleted = self.client.get('/ows?%s' %
                                                               request)