Beispiel #1
0
    def _unpackMultipartContent( self , response ) : 

        content      = response.content
        content_type = response['Content-Type']

        # check the content type 
        if getMimeType( content_type ) \
            not in ( "multipart/mixed" , "multipart/related" ) :
            raise Exception , "Received content is neither mixed nor related multipart! Content-Type: %s" % content_type 

        # extract multipart boundary  
        boundary = getMultipartBoundary( content_type ) 
        
        # unpack the multipart content 
        for header,offset,size in mpUnpack(content,boundary) :
            match = RE_MIME_TYPE_XML.match( _getMime(header['content-type']) ) 
            if match is not None : 
                # store XML response 
                self.xmlData = content[offset:(offset+size)]
            else : 
                # store coverage data 
                self.imageData = content[offset:(offset+size)]
Beispiel #2
0
import time
import logging
from cgi import escape
import tempfile
import os

from mapscript import *

from eoxserver.core.util.multiparttools import mpUnpack, mpPack, capitalize
from eoxserver.core.util.multiparttools import getMimeType, getMultipartBoundary
from eoxserver.contrib import gdal


logger = logging.getLogger(__name__)
is_xml = lambda ct: getMimeType(ct) in ("text/xml", "application/xml", "application/gml+xml")
is_multipart = lambda ct: getMimeType(ct).startswith("multipart/") 
msversion = msGetVersionInt()

class MapServerException(Exception):
    def __init__(self, message, locator):
        super(MapServerException, self).__init__(message)
        self.locator = locator


class MetadataMixIn(object):
    """ Mix-In for classes that wrap mapscript objects with associated metadata.
    """

    def __init__(self, metadata=None):
        super(MetadataMixIn, self).__init__()