• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python configuration.get_config_value函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pywps.configuration.get_config_value函数的典型用法代码示例。如果您正苦于以下问题:Python get_config_value函数的具体用法?Python get_config_value怎么用?Python get_config_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_config_value函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: start

def start(args, kill = None):
    config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "pywps.cfg")

    processes = [
        FeatureCount(),
        SayHello(),
        Centroids(),
        UltimateQuestion(),
        Sleep(),
        Buffer(),
        Area(),
        Box(),
        Warp()
    ]

    s = Server(processes=processes, config_file=config_file)

    # TODO: need to spawn a different process for different server
    if args.waitress:
        import waitress
        from pywps import configuration

        configuration.load_configuration(config_file)
        host = configuration.get_config_value('wps', 'serveraddress').split('://')[1]
        port = int(configuration.get_config_value('wps', 'serverport'))

        waitress.serve(s.app, host=host, port=port)
    else:
        s.run()
开发者ID:jachym,项目名称:pywps-4-demo,代码行数:29,代码来源:demo.py


示例2: get_session

def get_session():
    """Get Connection for database
    """

    LOGGER.debug('Initializing database connection')
    global _SESSION_MAKER
    global _LAST_SESSION

    if _LAST_SESSION:
        _LAST_SESSION.close()

    if _SESSION_MAKER:
        _SESSION_MAKER.close_all()
        _LAST_SESSION = _SESSION_MAKER()
        return _LAST_SESSION

    database = configuration.get_config_value('logging', 'database')
    echo = True
    level = configuration.get_config_value('logging', 'level')
    if level in ['INFO']:
        echo = False
    try:
        engine = sqlalchemy.create_engine(database, echo=echo)
    except sqlalchemy.exc.SQLAlchemyError as e:
        raise NoApplicableCode("Could not connect to database: {}".format(e.message))

    Session = sessionmaker(bind=engine)
    ProcessInstance.metadata.create_all(engine)
    RequestInstance.metadata.create_all(engine)

    _SESSION_MAKER = Session

    _LAST_SESSION = _SESSION_MAKER()
    return _LAST_SESSION
开发者ID:xhqiao89,项目名称:pywps,代码行数:34,代码来源:dblog.py


示例3: __init__

    def __init__(self, host=None, port=None, debug=False, processes=[], config_file=None):
        self.app = flask.Flask(__name__)

        # Load config files and override settings if any file specified
        if config_file:
            configuration.load_configuration(config_file)
            self.host = configuration.get_config_value('wps', 'serveraddress').split('://')[1]
            self.port = int(configuration.get_config_value('wps', 'serverport'))

        # Override config host and port if they are passed to the constructor
        if host:
            self.host = host
        if port:
            self.port = port
        self.debug = debug

        self.output_url = configuration.get_config_value('server', 'outputUrl')
        self.output_path = configuration.get_config_value('server', 'outputPath')
        self.temp_path = configuration.get_config_value('server', 'tempPath')

        # check if in the configuration file specified directory exists otherwise create it
        try:
            if not os.path.exists(self.temp_path):
                os.makedirs(self.temp_path)
                print('%s does not exist. Creating it.' % self.temp_path)
            if not os.path.exists(self.output_path):
                os.makedirs(self.output_path)
                print('%s does not exist. Creating it.' % self.output_path)
        except Exception as e:
            raise NoApplicableCode('File error: Could not create folder. %s' % e)

        self.processes = processes
        self.service = Service(processes=self.processes)
开发者ID:keceke,项目名称:pywps,代码行数:33,代码来源:server.py


示例4: main

def main():
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument('-w', '--waitress', action='store_true')
    args = parser.parse_args()

    config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "pywps.cfg")

    processes = [
        FeatureCount(),
        SayHello(),
        Centroids(),
        UltimateQuestion(),
        Sleep(),
        Buffer(),
        Area(),
        Viewshed()
    ]

    s = Server(processes=processes, config_file=config_file)

    # TODO: need to spawn a different process for different server
    if args.waitress:
        import waitress
        from pywps import configuration

        configuration.load_configuration(config_file)
        host = configuration.get_config_value('wps', 'serveraddress').split('://')[1]
        port = int(configuration.get_config_value('wps', 'serverport'))

        waitress.serve(s.app, host=host, port=port)
    else:
        s.run()
开发者ID:keceke,项目名称:pywps,代码行数:34,代码来源:demo.py


示例5: __init__

 def __init__(self):
     """
     """
     self.target = config.get_config_value('server', 'outputpath')
     self.output_url = '%s%s' % (
         config.get_config_value('server', 'url'),
         config.get_config_value('server', 'outputurl')
     )
开发者ID:jan-rudolf,项目名称:pywps,代码行数:8,代码来源:storage.py


示例6: __init__

 def __init__(self):
     """
     """
     self.drive_secret_file = config.get_config_value('remote-storage', 'drive_secret_file')
     self.target = config.get_config_value('server', 'outputpath')
     self.output_url = '%s%s' % (
         config.get_config_value('server', 'url'),
         config.get_config_value('server', 'outputurl')
     )
开发者ID:mishravikas,项目名称:pywps,代码行数:9,代码来源:storage.py


示例7: __init__

 def __init__(self):
     """
     """
     self.target = config.get_config_value('server', 'outputPath')
     self.output_url = '%s:%s%s' % (
         config.get_config_value('wps', 'serveraddress'),
         config.get_config_value('wps', 'serverport'),
         config.get_config_value('server', 'outputUrl')
     )
开发者ID:SiggyF,项目名称:pywps-4,代码行数:9,代码来源:storage.py


示例8: _run_process

    def _run_process(self, wps_request, wps_response):
        LOGGER.debug("Started processing request: {}".format(self.uuid))
        try:
            self._set_grass(wps_request)
            # if required set HOME to the current working directory.
            if config.get_config_value('server', 'sethomedir') is True:
                os.environ['HOME'] = self.workdir
                LOGGER.info('Setting HOME to current working directory: {}'.format(os.environ['HOME']))
            LOGGER.debug('ProcessID={}, HOME={}'.format(self.uuid, os.environ.get('HOME')))
            wps_response._update_status(WPS_STATUS.STARTED, u'PyWPS Process started', 0)
            self.handler(wps_request, wps_response)  # the user must update the wps_response.
            # Ensure process termination
            if wps_response.status != WPS_STATUS.SUCCEEDED and wps_response.status != WPS_STATUS.FAILED:
                # if (not wps_response.status_percentage) or (wps_response.status_percentage != 100):
                LOGGER.debug('Updating process status to 100% if everything went correctly')
                wps_response._update_status(WPS_STATUS.SUCCEEDED, 'PyWPS Process {} finished'.format(self.title), 100)
        except Exception as e:
            traceback.print_exc()
            LOGGER.debug('Retrieving file and line number where exception occurred')
            exc_type, exc_obj, exc_tb = sys.exc_info()
            found = False
            while not found:
                # search for the _handler method
                m_name = exc_tb.tb_frame.f_code.co_name
                if m_name == '_handler':
                    found = True
                else:
                    if exc_tb.tb_next is not None:
                        exc_tb = exc_tb.tb_next
                    else:
                        # if not found then take the first
                        exc_tb = sys.exc_info()[2]
                        break
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            method_name = exc_tb.tb_frame.f_code.co_name

            # update the process status to display process failed

            msg = 'Process error: method={}.{}, line={}, msg={}'.format(fname, method_name, exc_tb.tb_lineno, e)
            LOGGER.error(msg)
            # In case of a ProcessError use the validated exception message.
            if isinstance(e, ProcessError):
                msg = "Process error: {}".format(e)
            # Only in debug mode we use the log message including the traceback ...
            elif config.get_config_value("logging", "level") != "DEBUG":
                # ... otherwise we use a sparse common error message.
                msg = 'Process failed, please check server error log'
            wps_response._update_status(WPS_STATUS.FAILED, msg, 100)

        finally:
            # The run of the next pending request if finished here, weather or not it successfull
            self.launch_next_process()

        return wps_response
开发者ID:bird-house,项目名称:pywps,代码行数:54,代码来源:Process.py


示例9: _set_uuid

    def _set_uuid(self, uuid):
        """Set uuid and status ocation apth and url
        """

        self.uuid = uuid

        file_path = config.get_config_value('server', 'outputpath')

        file_url = config.get_config_value('server', 'outputurl')

        self.status_location = os.path.join(file_path, str(self.uuid)) + '.xml'
        self.status_url = os.path.join(file_url, str(self.uuid)) + '.xml'
开发者ID:hoseinmadadi,项目名称:pywps,代码行数:12,代码来源:Process.py


示例10: __init__

    def __init__(self, processes=[], cfgfiles=None):
        self.processes = {p.identifier: p for p in processes}

        if cfgfiles:
            config.load_configuration(cfgfiles)

        if config.get_config_value('server', 'logfile') and config.get_config_value('server', 'loglevel'):
            LOGGER.setLevel(getattr(logging, config.get_config_value('server', 'loglevel')))
            msg_fmt = '%(asctime)s] [%(levelname)s] file=%(pathname)s line=%(lineno)s module=%(module)s function=%(funcName)s %(message)s'
            fh = logging.FileHandler(config.get_config_value('server', 'logfile'))
            fh.setFormatter(logging.Formatter(msg_fmt))
            LOGGER.addHandler(fh)
        else:  # NullHandler
            LOGGER.addHandler(logging.NullHandler())
开发者ID:sebastic,项目名称:pywps,代码行数:14,代码来源:Service.py


示例11: _set_grass

    def _set_grass(self):
        """Set environment variables needed for GRASS GIS support
        """

        if not PY2:
            LOGGER.debug("Python3 is not supported by GRASS")
            return

        gisbase = config.get_config_value("grass", "gisbase")
        if gisbase and os.path.isdir(gisbase):
            LOGGER.debug("GRASS GISBASE set to %s" % gisbase)

            os.environ["GISBASE"] = gisbase

            os.environ["LD_LIBRARY_PATH"] = "{}:{}".format(
                os.environ.get("LD_LIBRARY_PATH"), os.path.join(gisbase, "lib")
            )
            os.putenv("LD_LIBRARY_PATH", os.environ.get("LD_LIBRARY_PATH"))

            os.environ["PATH"] = "{}:{}:{}".format(
                os.environ.get("PATH"), os.path.join(gisbase, "bin"), os.path.join(gisbase, "scripts")
            )
            os.putenv("PATH", os.environ.get("PATH"))

            python_path = os.path.join(gisbase, "etc", "python")
            os.environ["PYTHONPATH"] = "{}:{}".format(os.environ.get("PYTHONPATH"), python_path)
            os.putenv("PYTHONPATH", os.environ.get("PYTHONPATH"))
            sys.path.insert(0, python_path)
开发者ID:jachym,项目名称:PyWPS,代码行数:28,代码来源:Service.py


示例12: _execute_xml_reference

    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
开发者ID:mishravikas,项目名称:pywps,代码行数:26,代码来源:outputs.py


示例13: href_handler

        def href_handler(complexinput, datain):
            """<wps:Reference /> handler"""
            tmp_dir = config.get_config_value('server', 'workdir')
    
            # save the reference input in workdir
            tmp_file = tempfile.mkstemp(dir=complexinput.workdir)[1]
    
            try:
                (reference_file, reference_file_data) = _openurl(href)
                data_size = reference_file.headers.get('Content-Length', 0)
            except Exception as e:
                raise NoApplicableCode('File reference error: %s' % e)

            # if the response did not return a 'Content-Length' header then calculate the size
            if data_size == 0:
                data_size = _get_datasize(reference_file_data)

            # check if input file size was not exceeded
            complexinput.calculate_max_input_size()
            byte_size = complexinput.max_size * 1024 * 1024
            if int(data_size) > int(byte_size):
                raise FileSizeExceeded('File size for input exceeded.'
                                       ' Maximum allowed: %i megabytes' %\
                       complexinput.max_size, complexinput.get('identifier'))

            try:
                with open(tmp_file, 'w') as f:
                    f.write(reference_file_data)
                    f.close()
            except Exception as e:
                raise NoApplicableCode(e)
    
            complexinput.file = tmp_file
            complexinput.url = href
            complexinput.as_reference = True
开发者ID:SiggyF,项目名称:pywps-4,代码行数:35,代码来源:Service.py


示例14: execute

    def execute(self, identifier, wps_request, uuid):
        """Parse and perform Execute WPS request call

        :param identifier: process identifier string
        :param wps_request: pywps.WPSRequest structure with parsed inputs, still in memory
        :param uuid: string identifier of the request
        """
        self._set_grass()
        response = None
        try:
            process = self.processes[identifier]

            # make deep copy of the process instace
            # so that processes are not overriding each other
            # just for execute
            process = copy.deepcopy(process)

            workdir = os.path.abspath(config.get_config_value('server', 'workdir'))
            tempdir = tempfile.mkdtemp(prefix='pywps_process_', dir=workdir)
            process.set_workdir(tempdir)
        except KeyError:
            raise InvalidParameterValue("Unknown process '%r'" % identifier, 'Identifier')

        olddir = os.path.abspath(os.curdir)
        try:
            os.chdir(process.workdir)
            response = self._parse_and_execute(process, wps_request, uuid)
        finally:
            os.chdir(olddir)

        return response
开发者ID:hoseinmadadi,项目名称:pywps,代码行数:31,代码来源:Service.py


示例15: execute

    def execute(self, identifier, wps_request):
        """Parse and perform Execute WPS request call

        :param identifier: process identifier string
        :param wps_request: pywps.WPSRequest structure with parsed inputs, still in memory
        """
        response = None
        try:
            process = self.processes[identifier]

            workdir = config.get_config_value('server', 'workdir')
            tempdir = tempfile.mkdtemp(prefix='pypws_process_', dir=workdir)
            process.set_workdir(tempdir)
        except KeyError:
            raise InvalidParameterValue("Unknown process '%r'" % identifier)

        olddir = os.path.abspath(os.curdir)
        try:
            os.chdir(process.workdir)
            response = self._parse_and_execute(process, wps_request)
            os.chdir(olddir)
            shutil.rmtree(process.workdir)
        except Exception as e:
            os.chdir(olddir)
            shutil.rmtree(process.workdir)
            raise e

        return response
开发者ID:SiggyF,项目名称:pywps-4,代码行数:28,代码来源:Service.py


示例16: execute

    def execute(self, identifier, wps_request, uuid):
        """Parse and perform Execute WPS request call

        :param identifier: process identifier string
        :param wps_request: pywps.WPSRequest structure with parsed inputs, still in memory
        :param uuid: string identifier of the request
        """
        self._set_grass()
        response = None
        try:
            process = self.processes[identifier]

            workdir = os.path.abspath(config.get_config_value("server", "workdir"))
            tempdir = tempfile.mkdtemp(prefix="pywps_process_", dir=workdir)
            process.set_workdir(tempdir)
        except KeyError:
            raise InvalidParameterValue("Unknown process '%r'" % identifier, "Identifier")

        olddir = os.path.abspath(os.curdir)
        try:
            os.chdir(process.workdir)
            response = self._parse_and_execute(process, wps_request, uuid)
        finally:
            os.chdir(olddir)

        return response
开发者ID:jachym,项目名称:PyWPS,代码行数:26,代码来源:Service.py


示例17: _set_grass

    def _set_grass(self):
        """Set environment variables needed for GRASS GIS support
        """

        if not PY2:
            LOGGER.debug('Python3 is not supported by GRASS')
            return

        gisbase = config.get_config_value('grass', 'gisbase')
        if gisbase and os.path.isdir(gisbase):
            LOGGER.debug('GRASS GISBASE set to %s' % gisbase)

            os.environ['GISBASE'] = gisbase

            os.environ['LD_LIBRARY_PATH'] = '{}:{}'.format(
                os.environ.get('LD_LIBRARY_PATH'),
                os.path.join(gisbase, 'lib'))
            os.putenv('LD_LIBRARY_PATH', os.environ.get('LD_LIBRARY_PATH'))

            os.environ['PATH'] = '{}:{}:{}'.format(
                os.environ.get('PATH'),
                os.path.join(gisbase, 'bin'),
                os.path.join(gisbase, 'scripts'))
            os.putenv('PATH', os.environ.get('PATH'))

            python_path = os.path.join(gisbase, 'etc', 'python')
            os.environ['PYTHONPATH'] = '{}:{}'.format(os.environ.get('PYTHONPATH'),
                    python_path)
            os.putenv('PYTHONPATH', os.environ.get('PYTHONPATH'))
            sys.path.insert(0, python_path)
开发者ID:sebastic,项目名称:pywps,代码行数:30,代码来源:Service.py


示例18: __init__

    def __init__(self, processes=[], cfgfiles=None):
        # ordered dict of processes
        self.processes = OrderedDict((p.identifier, p) for p in processes)

        if cfgfiles:
            config.load_configuration(cfgfiles)

        if config.get_config_value('logging', 'file') and config.get_config_value('logging', 'level'):
            LOGGER.setLevel(getattr(logging, config.get_config_value('logging', 'level')))
            if not LOGGER.handlers:  # hasHandlers in Python 3.x
                fh = logging.FileHandler(config.get_config_value('logging', 'file'))
                fh.setFormatter(logging.Formatter(config.get_config_value('logging', 'format')))
                LOGGER.addHandler(fh)
        else:  # NullHandler | StreamHandler
            if not LOGGER.handlers:
                LOGGER.addHandler(logging.NullHandler())
开发者ID:bird-house,项目名称:pywps,代码行数:16,代码来源:Service.py


示例19: calculate_max_input_size

    def calculate_max_input_size(self):
        """Calculates maximal size for input file based on configuration
        and units

        :return: maximum file size bytes
        """
        max_size = configuration.get_config_value('server', 'maxsingleinputsize')
        self.max_size = configuration.get_size_mb(max_size)
开发者ID:SiggyF,项目名称:pywps-4,代码行数:8,代码来源:inputs.py


示例20: max_input_size

    def max_input_size():
        """Calculates maximal size for input file based on configuration
        and units.

        :return: maximum file size in bytes
        """
        ms = config.get_config_value('server', 'maxsingleinputsize')
        return config.get_size_mb(ms) * 1024**2
开发者ID:bird-house,项目名称:pywps,代码行数:8,代码来源:basic.py



注:本文中的pywps.configuration.get_config_value函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.client_for函数代码示例发布时间:2022-05-26
下一篇:
Python config.getConfigValue函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap