def parseRequest(self,queryStringObject): """ Parse input OGC WPS request, which is either URL Query string or file object, e.g. :mod:`sys.stdin` :param queryStringObject: string or file object with the request :returns: Dictionary of parsed input values :rtype: dict """ # decide, which method to use # HTTP GET vs. HTTP POST if self.method == METHOD_GET: from Parser.Get import Get self.parser = Get(self) else: from pywps.Parser.Post import Post self.parser = Post(self) self.inputs = self.parser.parse(queryStringObject) return self.inputs
def parseRequest(self, queryStringObject): """ Parse input OGC WPS request, which is either URL Query string or file object, e.g. :mod:`sys.stdin` :param queryStringObject: string or file object with the request :returns: Dictionary of parsed input values :rtype: dict """ # decide, which method to use # HTTP GET vs. HTTP POST if self.method == METHOD_GET: from Parser.Get import Get self.parser = Get(self) else: from pywps.Parser.Post import Post self.parser = Post(self) self.inputs = self.parser.parse(queryStringObject) return self.inputs
class Pywps: """This is main PyWPS Class, which parses the request, performs the desired operation and writes required response back. :param method: Used HTTP method, which is either :data:`METHOD_POST` or :data:`METHOD_GET`: :type method: string :param configFiles: List of configuration files. Ignore, if you want to use standard files location :type configFiles: list .. attribute:: method METHOD_GET or METHOD_POST .. attribute:: parser WPS request parser .. attribute:: inputs Parsed inputs object .. attribute:: request GetCapabilities, DescribeProcess or Execute (response) object .. attribute:: parser GetCapabilities, DescribeProcess or Execute, POST or GET (parsing) object .. attribute:: languages List of supported languages .. attribute:: versions Default supported versions .. attribute:: logFile File objects, where some logs are written to. .. note:: Use :: import logging logging.debug("hallo world") for any debugging information, you want to get """ method = METHOD_GET # HTTP POST or GET inputs = None # parsed input values request = None # object with getcapabilities/describeprocess/execute parser = None languages = [DEFAULT_LANG] versions=[DEFAULT_VERSION] UUID = None def __init__(self, method=METHOD_GET, configFiles=None): """Class constructor """ # get settings config.loadConfiguration(configFiles) self.setLogFile() self.UUID = uuid.uuid1().__str__() self.languages = config.getConfigValue("wps","lang").split(",") DEFAULT_LANG = self.languages[0] # set default version self.versions = config.getConfigValue("wps","version").split(",") DEFAULT_VERSION = self.versions[0] # find out the request method self.method = method def parseRequest(self,queryStringObject): """ Parse input OGC WPS request, which is either URL Query string or file object, e.g. :mod:`sys.stdin` :param queryStringObject: string or file object with the request :returns: Dictionary of parsed input values :rtype: dict """ # decide, which method to use # HTTP GET vs. HTTP POST if self.method == METHOD_GET: from Parser.Get import Get self.parser = Get(self) else: from pywps.Parser.Post import Post self.parser = Post(self) self.inputs = self.parser.parse(queryStringObject) return self.inputs def performRequest(self,inputs = None, processes=None): """Performs the desired WSP Request. :param inputs: idealy self.inputs (Default) object, result from parseRequest. Default is self.inputs :rtype: pywps.Wps.Response """ if inputs == None: inputs = self.inputs # the modules are imported first, when the request type is known if inputs.has_key("request"): if inputs["request"] == "getcapabilities": from pywps.Wps.GetCapabilities import GetCapabilities self.request = GetCapabilities(self,processes=processes) elif inputs["request"] == "describeprocess": from pywps.Wps.DescribeProcess import DescribeProcess self.request = DescribeProcess(self,processes=processes) elif inputs["request"] == "execute": from pywps.Wps.Execute import Execute self.request = Execute(self,processes=processes) elif inputs.has_key("wsdl"): inputs["version"]="1.0.0" from pywps.Wps.Wsdl import Wsdl self.request = Wsdl(self) else: raise Exceptions.InvalidParameterValue( "request: "+inputs["request"]) self.response = self.request.response return self.response def setLogFile(self): """Set :data:`logFile`. Default is sys.stderr """ global logFile fileName = config.getConfigValue("server","logFile") logLevel = eval("logging."+config.getConfigValue("server","logLevel").upper()) format = "PyWPS [%(asctime)s] %(levelname)s: %(message)s" if not fileName: logging.basicConfig(level=logLevel,format=format) else: logging.basicConfig(filename=fileName,level=logLevel,format=format) logFile = open(fileName, "a")
def __init__(self,wps): PostParser.__init__(self,wps)
class Pywps: """This is main PyWPS Class, which parses the request, performs the desired operation and writes required response back. :param method: Used HTTP method, which is either :data:`METHOD_POST` or :data:`METHOD_GET`: :type method: string :param configFiles: List of configuration files. Ignore, if you want to use standard files location :type configFiles: list .. attribute:: method METHOD_GET or METHOD_POST .. attribute:: parser WPS request parser .. attribute:: inputs Parsed inputs object .. attribute:: request GetCapabilities, DescribeProcess or Execute (response) object .. attribute:: parser GetCapabilities, DescribeProcess or Execute, POST or GET (parsing) object .. attribute:: languages List of supported languages .. attribute:: versions Default supported versions .. attribute:: logFile File objects, where some logs are written to. .. note:: Use :: import logging logging.debug("hallo world") for any debugging information, you want to get """ method = METHOD_GET # HTTP POST or GET inputs = None # parsed input values request = None # object with getcapabilities/describeprocess/execute parser = None languages = [DEFAULT_LANG] versions = [DEFAULT_VERSION] UUID = None def __init__(self, environ, configFiles=None): """Class constructor """ # get settings config.loadConfiguration(configFiles, environ) self.setLogFile() self.UUID = uuid.uuid1().__str__() self.languages = config.getConfigValue("wps", "lang").split(",") DEFAULT_LANG = self.languages[0] # set default version self.versions = config.getConfigValue("wps", "version").split(",") DEFAULT_VERSION = self.versions[0] # find out the request method self.method = environ["REQUEST_METHOD"] def parseRequest(self, queryStringObject): """ Parse input OGC WPS request, which is either URL Query string or file object, e.g. :mod:`sys.stdin` :param queryStringObject: string or file object with the request :returns: Dictionary of parsed input values :rtype: dict """ # decide, which method to use # HTTP GET vs. HTTP POST if self.method == METHOD_GET: from Parser.Get import Get self.parser = Get(self) else: from pywps.Parser.Post import Post self.parser = Post(self) self.inputs = self.parser.parse(queryStringObject) return self.inputs def performRequest(self, inputs=None, processes=None): """Performs the desired WSP Request. :param inputs: idealy self.inputs (Default) object, result from parseRequest. Default is self.inputs :rtype: pywps.Wps.Response """ if inputs == None: inputs = self.inputs # the modules are imported first, when the request type is known if inputs.has_key("request"): if inputs["request"] == "getcapabilities": from pywps.Wps.GetCapabilities import GetCapabilities self.request = GetCapabilities(self, processes=processes) elif inputs["request"] == "describeprocess": from pywps.Wps.DescribeProcess import DescribeProcess self.request = DescribeProcess(self, processes=processes) elif inputs["request"] == "execute": from pywps.Wps.Execute import Execute self.request = Execute(self, processes=processes) elif inputs.has_key("wsdl"): inputs["version"] = "1.0.0" from pywps.Wps.Wsdl import Wsdl self.request = Wsdl(self) else: raise Exceptions.InvalidParameterValue("request: " + inputs["request"]) self.response = self.request.response return self.response def setLogFile(self): """Set :data:`logFile`. Default is sys.stderr """ global logFile fileName = config.getConfigValue("server", "logFile") logLevel = eval("logging." + config.getConfigValue("server", "logLevel").upper()) format = "PyWPS [%(asctime)s] %(levelname)s: %(message)s" if not fileName: logging.basicConfig(level=logLevel, format=format) else: logging.basicConfig(filename=fileName, level=logLevel, format=format) logFile = open(fileName, "a")
def __init__(self, wps): PostParser.__init__(self, wps)