Exemplo n.º 1
0
    def _execute_xml_reference(self):
        """Return Reference node
        """
        doc = WPS.Reference()
        storage_option = config.get_config_value('remote-storage',
                                                 'storage_option')

        if storage_option == 'ftp':
            self.storage = FTPStorage()
        elif storage_option == 'dropbox':
            self.storage = DropboxStorage()
        elif storage_option == 'googledrive':
            self.storage = GoogleDriveStorage()
        else:
            self.storage = FileStorage()

        # get_url will create the file and return the url for it
        doc.attrib['{http://www.w3.org/1999/xlink}href'] = self.get_url()

        if self.data_format:
            if self.data_format.mime_type:
                doc.attrib['mimeType'] = self.data_format.mime_type
            if self.data_format.encoding:
                doc.attrib['encoding'] = self.data_format.encoding
            if self.data_format.schema:
                doc.attrib['schema'] = self.data_format.schema
        return doc
Exemplo n.º 2
0
 def _handler(self, request, response):
     LOGGER.info("starting ...")
     if 'count' in request.inputs:
         max_outputs = request.inputs['count'][0].data
     else:
         max_outputs = 1
     # prepare output
     response.outputs['output'].storage = FileStorage()
     response.outputs['output'].output_format = FORMATS.TEXT
     # generate outputs
     result = dict(count=max_outputs, outputs=[])
     for i in range(max_outputs):
         progress = int(i * 100.0 / max_outputs)
         response.update_status('working on document {}'.format(i),
                                progress)
         with open("output_{}.txt".format(i), 'w') as fp:
             fp.write("my output file number %s" % i)
         response.outputs['output'].file = fp.name
         ref_url = response.outputs['output'].get_url()
         result['outputs'].append(
             dict(name=os.path.basename(ref_url), url=ref_url))
     # return document with outpus
     response.outputs['reference'].output_format = FORMATS.JSON
     response.outputs['reference'].data = json.dumps(result)
     return response
    def _execute_xml_reference(self):
        """ Decide what storage model to use and return Reference node
        """
        doc = WPS.Reference()

        # get_url will create the file and return the url for it

        store_type = config.get_config_value('server', 'store_type')
        self.storage = None
        # chooses FileStorage, S3Storage or PgStorage based on a store_type value in cfg file
        if store_type == 'db' and \
           config.get_config_value('db', 'dbname'):
            # TODO: more databases in config file
            self.storage = PgStorage()
        elif store_type == 's3' and \
           config.get_config_value('s3', 'bucket_name'):
            self.storage = S3Storage()
        else:
            self.storage = FileStorage()
        doc.attrib['{http://www.w3.org/1999/xlink}href'] = self.get_url()

        if self.data_format:
            if self.data_format.mime_type:
                doc.attrib['mimeType'] = self.data_format.mime_type
            if self.data_format.encoding:
                doc.attrib['encoding'] = self.data_format.encoding
            if self.data_format.schema:
                doc.attrib['schema'] = self.data_format.schema
        return doc
Exemplo n.º 4
0
 def test_url_handler(self):
     wfsResource = 'http://demo.mapserver.org/cgi-bin/wfs?' \
                   'service=WFS&version=1.1.0&' \
                   'request=GetFeature&' \
                   'typename=continents&maxfeatures=2'
     self.complex_out.url = wfsResource
     storage = FileStorage()
     self.complex_out.storage = storage
     url = self.complex_out.get_url()
     self.assertEqual('file', urlparse(url).scheme)
Exemplo n.º 5
0
    def _json_reference(self, data):
        """Return Reference node
        """
        data["type"] = "reference"

        # get_url will create the file and return the url for it
        if self.prop == 'url':
            data["href"] = self.url
        elif self.prop is not None:
            self.storage = FileStorage()
            data["href"] = self.get_url()

        return data
Exemplo n.º 6
0
    def _execute_xml_reference(self):
        """Return Reference node
        """
        doc = WPS.Reference()

        # get_url will create the file and return the url for it
        self.storage = FileStorage()
        doc.attrib['{http://www.w3.org/1999/xlink}href'] = self.get_url()

        if self.data_format:
            if self.data_format.mime_type:
                doc.attrib['mimeType'] = self.data_format.mime_type
            if self.data_format.encoding:
                doc.attrib['encoding'] = self.data_format.encoding
            if self.data_format.schema:
                doc.attrib['schema'] = self.data_format.schema
        return doc
Exemplo n.º 7
0
    def _json_reference(self, data):
        """Return Reference node
        """
        data["type"] = "reference"

        # get_url will create the file and return the url for it
        self.storage = FileStorage()
        data["href"] = self.get_url()

        if self.data_format:
            if self.data_format.mime_type:
                data['mimetype'] = self.data_format.mime_type
            if self.data_format.encoding:
                data['encoding'] = self.data_format.encoding
            if self.data_format.schema:
                data['schema'] = self.data_format.schema

        return data