當前位置: 首頁>>代碼示例>>Python>>正文


Python base.Application方法代碼示例

本文整理匯總了Python中gunicorn.app.base.Application方法的典型用法代碼示例。如果您正苦於以下問題:Python base.Application方法的具體用法?Python base.Application怎麽用?Python base.Application使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gunicorn.app.base的用法示例。


在下文中一共展示了base.Application方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _mount_app

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def _mount_app(self, prefix, app, **options):
        if app in self._mounts or '_mount.app' in app.config:
            depr(0, 13, "Application mounted multiple times. Falling back to WSGI mount.",
                 "Clone application before mounting to a different location.")
            return self._mount_wsgi(prefix, app, **options)

        if options:
            depr(0, 13, "Unsupported mount options. Falling back to WSGI mount.",
                 "Do not specify any route options when mounting bottle application.")
            return self._mount_wsgi(prefix, app, **options)

        if not prefix.endswith("/"):
            depr(0, 13, "Prefix must end in '/'. Falling back to WSGI mount.",
                 "Consider adding an explicit redirect from '/prefix' to '/prefix/' in the parent application.")
            return self._mount_wsgi(prefix, app, **options)

        self._mounts.append(app)
        app.config['_mount.prefix'] = prefix
        app.config['_mount.app'] = self
        for route in app.routes:
            route.rule = prefix + route.rule.lstrip('/')
            self.add_route(route) 
開發者ID:brycesub,項目名稱:silvia-pi,代碼行數:24,代碼來源:bottle.py

示例2: _make_callback

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def _make_callback(self):
        callback = self.callback
        for plugin in self.all_plugins():
            try:
                if hasattr(plugin, 'apply'):
                    api = getattr(plugin, 'api', 1)
                    context = self if api > 1 else self._context
                    callback = plugin.apply(callback, context)
                else:
                    callback = plugin(callback)
            except RouteReset: # Try again with changed configuration.
                return self._make_callback()
            if not callback is self.callback:
                try_update_wrapper(callback, self.callback)
        return callback






###############################################################################
# Application Object ###########################################################
############################################################################### 
開發者ID:zhangzhengde0225,項目名稱:VaspCZ,代碼行數:26,代碼來源:bottle.py

示例3: save

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def save(self, destination, overwrite=False, chunk_size=2 ** 16):
        """ Save file to disk or copy its content to an open file(-like) object.
            If *destination* is a directory, :attr:`filename` is added to the
            path. Existing files are not overwritten by default (IOError).

            :param destination: File path, directory or file(-like) object.
            :param overwrite: If True, replace existing files. (default: False)
            :param chunk_size: Bytes to read at a time. (default: 64kb)
        """
        if isinstance(destination, basestring):  # Except file-likes here
            if os.path.isdir(destination):
                destination = os.path.join(destination, self.filename)
            if not overwrite and os.path.exists(destination):
                raise IOError('File exists.')
            with open(destination, 'wb') as fp:
                self._copy_file(fp, chunk_size)
        else:
            self._copy_file(destination, chunk_size)

###############################################################################
# Application Helper ###########################################################
############################################################################### 
開發者ID:brycesub,項目名稱:silvia-pi,代碼行數:24,代碼來源:bottle.py

示例4: __repr__

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def __repr__(self):
        cb = self.get_undecorated_callback()
        return '<%s %r %r>' % (self.method, self.rule, cb)






###############################################################################
# Application Object ###########################################################
############################################################################### 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:14,代碼來源:__init__.py

示例5: save

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def save(self, destination, overwrite=False, chunk_size=2**16):
        ''' Save file to disk or copy its content to an open file(-like) object.
            If *destination* is a directory, :attr:`filename` is added to the
            path. Existing files are not overwritten by default (IOError).

            :param destination: File path, directory or file(-like) object.
            :param overwrite: If True, replace existing files. (default: False)
            :param chunk_size: Bytes to read at a time. (default: 64kb)
        '''
        if isinstance(destination, basestring): # Except file-likes here
            if os.path.isdir(destination):
                destination = os.path.join(destination, self.filename)
            if not overwrite and os.path.exists(destination):
                raise IOError('File exists.')
            with open(destination, 'wb') as fp:
                self._copy_file(fp, chunk_size)
        else:
            self._copy_file(destination, chunk_size)






###############################################################################
# Application Helper ###########################################################
############################################################################### 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:29,代碼來源:__init__.py

示例6: run

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def run(self, handler):
        from gunicorn.app.base import Application

        config = {'bind': "%s:%d" % (self.host, int(self.port))}
        config.update(self.options)

        class GunicornApplication(Application):
            def init(self, parser, opts, args):
                return config

            def load(self):
                return handler

        GunicornApplication().run() 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:16,代碼來源:__init__.py

示例7: __repr__

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def __repr__(self):
        return '<%s %r %r>' % (self.method, self.rule, self.callback)






###############################################################################
# Application Object ###########################################################
############################################################################### 
開發者ID:exiahuang,項目名稱:SalesforceXyTools,代碼行數:13,代碼來源:bottle.py

示例8: open

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def open(self, name, mode='r', *args, **kwargs):
        ''' Find a resource and return a file object, or raise IOError. '''
        fname = self.lookup(name)
        if not fname: raise IOError("Resource %r not found." % name)
        return self.opener(name, mode=mode, *args, **kwargs)






###############################################################################
# Application Helper ###########################################################
############################################################################### 
開發者ID:exiahuang,項目名稱:SalesforceXyTools,代碼行數:16,代碼來源:bottle.py

示例9: abort

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def abort(code=500, text='Unknown Error: Application stopped.'):
    """ Aborts execution and causes a HTTP error. """
    raise HTTPError(code, text) 
開發者ID:exiahuang,項目名稱:SalesforceXyTools,代碼行數:5,代碼來源:bottle.py

示例10: __iter__

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def __iter__(self):
       read, buff = self.fp.read, self.buffer_size
       while True:
           part = read(buff)
           if not part: break
           yield part






###############################################################################
# Application Helper ###########################################################
############################################################################### 
開發者ID:zhangzhengde0225,項目名稱:VaspCZ,代碼行數:17,代碼來源:bottle.py

示例11: _gunicorn_run

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def _gunicorn_run(self):
        from gunicorn.app.base import Application
        app = self.wsgi_app

        class QgGunicornApp(Application):

            def init(self, parser, opts, args):
                workers = CONF.gunicorn.workers
                if workers <= 0:
                    workers = multiprocessing.cpu_count() * 2 + 1
                logger_class = "simple"
                if CONF.gunicorn.ignore_healthcheck_accesslog:
                    logger_class = "qg.web.glogging.GunicornLogger"
                return {
                    'bind': '{0}:{1}'.format(CONF.web.bind, CONF.web.port),
                    'config': CONF.gunicorn.config,
                    'workers': workers,
                    'daemon': CONF.gunicorn.daemon,
                    'accesslog': CONF.gunicorn.accesslog,
                    'loglevel': CONF.gunicorn.loglevel,
                    'timeout': CONF.gunicorn.timeout,
                    'worker_class': CONF.gunicorn.worker_class,
                    'logger_class': logger_class
                }

            def load(self):
                return app

        # NOTE(zhen.pei): 為了不讓gunicorn默認匹配sys.argv[1:]
        sys.argv = [sys.argv[0]]
        QgGunicornApp().run() 
開發者ID:qunarcorp,項目名稱:open_dnsdb,代碼行數:33,代碼來源:flaskapp.py

示例12: __repr__

# 需要導入模塊: from gunicorn.app import base [as 別名]
# 或者: from gunicorn.app.base import Application [as 別名]
def __repr__(self):
        cb = self.get_undecorated_callback()
        return '<%s %r %r>' % (self.method, self.rule, cb)

###############################################################################
# Application Object ###########################################################
############################################################################### 
開發者ID:brycesub,項目名稱:silvia-pi,代碼行數:9,代碼來源:bottle.py


注:本文中的gunicorn.app.base.Application方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。