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

Python _internal._log函数代码示例

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

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



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

示例1: restart_with_reloader

def restart_with_reloader():
    """Spawn a new Python interpreter with the same arguments as this one,
    but running the reloader thread.
    """
    while 1:
        _log('info', ' * Restarting with reloader')

        requires_shell = False

        if sys.executable:
            args = [sys.executable] + sys.argv
        else:
            args, requires_shell = detect_executable()

        new_environ = os.environ.copy()
        new_environ['WERKZEUG_RUN_MAIN'] = 'true'

        # a weird bug on windows. sometimes unicode strings end up in the
        # environment and subprocess.call does not like this, encode them
        # to latin1 and continue.
        if os.name == 'nt' and PY2:
            for key, value in iteritems(new_environ):
                if isinstance(value, text_type):
                    new_environ[key] = value.encode('iso-8859-1')

        exit_code = subprocess.call(args, env=new_environ, shell=requires_shell)
        if exit_code != 3:
            return exit_code
开发者ID:transistor1,项目名称:werkzeug,代码行数:28,代码来源:serving.py


示例2: thumbs

def thumbs():
    # not good (type of values) but something like this
    infile = request.args.get('file', None)
    width = request.args.get('width', 120)
    height = request.args.get('height', 90)
    quality = request.args.get('quality', 100)
    crop = request.args.get('crop', False)

    origfile = os.path.join(basedir, app.static_folder + infile)
    if not os.path.isfile(origfile):
        infile = '/img/nopic.jpg'
        origfile = os.path.join(basedir, app.static_folder + infile)
    filehash = sha1(infile.encode('utf-8')).hexdigest()
    #cached_file = os.path.basename(infile).rsplit('.',1)[0] + \
    #    '_' + width + 'x' + height + '.' + \
    #    os.path.basename(infile).rsplit('.',1)[1]
    cached_file = filehash + \
                  '_' + width + 'x' + height + '.' + \
                  os.path.basename(infile).rsplit('.', 1)[1]

    newpath = os.path.join(basedir, app.static_folder + '/img/cache/' + cached_file)

    if os.path.isfile(newpath):
        _log('info', newpath)
        return send_file(newpath)

    resize(Image.open(origfile), (int(width), int(height)), crop, newpath, quality)

    return send_file(newpath, add_etags=False)
开发者ID:ics,项目名称:doc8643,代码行数:29,代码来源:views.py


示例3: restart_with_reloader

def restart_with_reloader():
    """Spawn a new Python interpreter with the same arguments as this one,
    but running the reloader thread.
    """
    while 1:
        _log('info', ' * Restarting with reloader')
        #args = [sys.executable] + sys.argv
        args = ['moin.py','server','standalone']

        new_environ = os.environ.copy()
        new_environ['WERKZEUG_RUN_MAIN'] = 'true'

        # a weird bug on windows. sometimes unicode strings end up in the
        # environment and subprocess.call does not like this, encode them
        # to latin1 and continue.
        if os.name == 'nt':
            for key, value in new_environ.iteritems():
                if isinstance(value, unicode):
                    new_environ[key] = value.encode('iso-8859-1')
            shell = True
        else:
            shell = False

        exit_code = subprocess.call(args, env=new_environ, shell=shell)
        if exit_code != 3:
            return exit_code
开发者ID:happytk,项目名称:moin,代码行数:26,代码来源:serving.py


示例4: werk_log

    def werk_log(self, type, message, *args):
        try:
            msg = '%s - - [%s] %s' % (
                self.address_string(),
                self.log_date_time_string(),
                message % args,
            )
            http_code = str(args[1])
        except:
            return _orig_log(type, message, *args)

        # Utilize terminal colors, if available
        if http_code[0] == '2':
            # Put 2XX first, since it should be the common case
            msg = _style.HTTP_SUCCESS(msg)
        elif http_code[0] == '1':
            msg = _style.HTTP_INFO(msg)
        elif http_code == '304':
            msg = _style.HTTP_NOT_MODIFIED(msg)
        elif http_code[0] == '3':
            msg = _style.HTTP_REDIRECT(msg)
        elif http_code == '404':
            msg = _style.HTTP_NOT_FOUND(msg)
        elif http_code[0] == '4':
            msg = _style.HTTP_BAD_REQUEST(msg)
        else:
            # Any 5XX, or any other response
            msg = _style.HTTP_SERVER_ERROR(msg)

        _log(type, msg)
开发者ID:philippbosch,项目名称:django-werkzeug-debugger-runserver,代码行数:30,代码来源:runserver.py


示例5: restart_with_reloader

    def restart_with_reloader(self):
        """Spawn a new Python interpreter with the same arguments as this one,
        but running the reloader thread.
        """
        while 1:
            _log('info', ' * Restarting with %s' % self.name)
            args = _get_args_for_reloading()

            # a weird bug on windows. sometimes unicode strings end up in the
            # environment and subprocess.call does not like this, encode them
            # to latin1 and continue.
            if os.name == 'nt' and PY2:
                new_environ = {}
                for key, value in iteritems(os.environ):
                    if isinstance(key, text_type):
                        key = key.encode('iso-8859-1')
                    if isinstance(value, text_type):
                        value = value.encode('iso-8859-1')
                    new_environ[key] = value
            else:
                new_environ = os.environ.copy()

            new_environ['WERKZEUG_RUN_MAIN'] = 'true'
            exit_code = subprocess.call(args, env=new_environ,
                                        close_fds=False)
            if exit_code != 3:
                return exit_code
开发者ID:gaoussoucamara,项目名称:simens-cerpad,代码行数:27,代码来源:_reloader.py


示例6: run

    def run(self):
        watches = {}
        observer = self.observer_class()
        observer.start()

        to_delete = set(watches)
        paths = _find_observable_paths(self.extra_files)
        for path in paths:
            if path not in watches:
                try:
                    watches[path] = observer.schedule(
                        self.event_handler, path, recursive=True)
                except OSError as e:
                    message = str(e)

                    if message != "Path is not a directory":
                        # Log the exception
                        _log('error', message)

                    # Clear this path from list of watches We don't want
                    # the same error message showing again in the next
                    # iteration.
                    watches[path] = None
            to_delete.discard(path)
        for path in to_delete:
            watch = watches.pop(path, None)
            if watch is not None:
                observer.unschedule(watch)
        self.observable_paths = paths

        yield from self.should_reload.wait()

        sys.exit(3)
开发者ID:alfred82santa,项目名称:aiowerkzeug,代码行数:33,代码来源:_reloader.py


示例7: pauseSession

def pauseSession():
    u = User.query.get(session['userID'])
    _log("info", u.__str__())
    s = u.getRunningSession()
    s.startPause()
    
    return "gepauzeerd"
开发者ID:BGordts,项目名称:peno3_iStudyPlus,代码行数:7,代码来源:sessionController.py


示例8: log_request

 def log_request(self, code='-', size='-'):
     _log('info', '%s -- [%s] %s %s',
         self.address_string(),
         self.requestline,
         code,
         size
     )
开发者ID:danaspiegel,项目名称:softball_stat_manager,代码行数:7,代码来源:serving.py


示例9: run_simple

def run_simple(hostname, port, application, use_reloader=False,
               use_debugger=False, use_evalex=True, extra_files=None,
               reloader_interval=1, passthrough_errors=False,
               ssl_context=None):
    if use_debugger:
        from werkzeug.debug import DebuggedApplication
        application = DebuggedApplication(application, use_evalex)

    def serve_forever():
        make_server(hostname, port, application,
                    passthrough_errors=passthrough_errors,
                    ssl_context=ssl_context).serve_forever()

    if os.environ.get('WERKZEUG_RUN_MAIN') != 'true':
        display_hostname = hostname != '*' and hostname or 'localhost'
        if ':' in display_hostname:
            display_hostname = '[%s]' % display_hostname
        _log('info', ' * Running on %s://%s:%d/', ssl_context is None
             and 'http' or 'https', display_hostname, port)

    if use_reloader:
        open_test_socket(hostname, port)
        run_with_reloader(serve_forever, extra_files, reloader_interval)
    else:
        serve_forever()
开发者ID:plowman,项目名称:clastic,代码行数:25,代码来源:server.py


示例10: _reloader_stat_loop

def _reloader_stat_loop(extra_files=None, interval=1):
    """When this function is run from the main thread, it will force other
    threads to exit when any modules currently loaded change.

    Copyright notice.  This function is based on the autoreload.py from
    the CherryPy trac which originated from WSGIKit which is now dead.

    :param extra_files: a list of additional files it should watch.
    """
    from itertools import chain

    mtimes = {}
    while 1:
        for filename in chain(_iter_module_files(), extra_files or ()):
            try:
                mtime = os.stat(filename).st_mtime
            except OSError:
                continue

            old_time = mtimes.get(filename)
            if old_time is None:
                mtimes[filename] = mtime
                continue
            elif mtime > old_time:
                _log("info", " * Detected change in %r, reloading" % filename)
                sys.exit(3)
        time.sleep(interval)
开发者ID:Contextualist,项目名称:Quip4AHA-GAE-legacy,代码行数:27,代码来源:serving.py


示例11: reloader_loop

def reloader_loop(extra_files = None, interval = 1):

    def iter_module_files():
        for module in sys.modules.values():
            filename = getattr(module, '__file__', None)
            if filename:
                old = None
                while not os.path.isfile(filename):
                    old = filename
                    filename = os.path.dirname(filename)
                    if filename == old:
                        break
                else:
                    if filename[-4:] in ('.pyc', '.pyo'):
                        filename = filename[:-1]
                    yield filename

    mtimes = {}
    while 1:
        for filename in chain(iter_module_files(), extra_files or ()):
            try:
                mtime = os.stat(filename).st_mtime
            except OSError:
                continue

            old_time = mtimes.get(filename)
            if old_time is None:
                mtimes[filename] = mtime
                continue
            elif mtime > old_time:
                _log('info', ' * Detected change in %r, reloading' % filename)
                sys.exit(3)

        time.sleep(interval)
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:34,代码来源:serving.py


示例12: run_simple

def run_simple(hostname, port, application, use_reloader=False,
               use_debugger=False, use_evalex=True, extra_files=None,
               reloader_interval=1, passthrough_errors=False, processes=None,
               threaded=False, ssl_context=None):
    if use_debugger:
        from werkzeug.debug import DebuggedApplication
        application = DebuggedApplication(application, use_evalex)

    processes = max(processes, 1)

    def serve_forever():
        make_server(hostname, port, application, processes=processes,
                    threaded=threaded, passthrough_errors=passthrough_errors,
                    ssl_context=ssl_context).serve_forever()

    def serve_error_app(tb_str, monitored_files):
        from clastic import flaw
        err_app = flaw.create_app(tb_str, monitored_files)
        err_server = make_server(hostname, port, err_app)
        thread.start_new_thread(err_server.serve_forever, ())
        return err_server

    if os.environ.get('WERKZEUG_RUN_MAIN') != 'true':
        display_hostname = hostname != '*' and hostname or 'localhost'
        if ':' in display_hostname:
            display_hostname = '[%s]' % display_hostname
        _log('info', ' * Running on %s://%s:%d/', ssl_context is None
             and 'http' or 'https', display_hostname, port)

    if use_reloader:
        open_test_socket(hostname, port)
        run_with_reloader(serve_forever, extra_files, reloader_interval,
                          error_func=serve_error_app)
    else:
        serve_forever()
开发者ID:markrwilliams,项目名称:clastic,代码行数:35,代码来源:server.py


示例13: log_pin_request

 def log_pin_request(self):
     """Log the pin if needed."""
     if self.pin_logging and self.pin is not None:
         _log('info', ' * To enable the debugger you need to '
              'enter the security pin:')
         _log('info', ' * Debugger pin code: %s' % self.pin)
     return Response('')
开发者ID:CityPulse,项目名称:pickup-planner,代码行数:7,代码来源:__init__.py


示例14: restart_with_reloader

def restart_with_reloader():
    """Spawn a new Python interpreter with the same arguments as this one,
    but running the reloader thread.
    """
    while 1:
        _log('info', ' * Restarting with reloader')
        #fix lastest python version entry_point script file incompatible bug
        if sys.argv[0].endswith('.pyw') or sys.argv[0].endswith('.py'):
            args = [sys.executable] + sys.argv
        else:
            args = sys.argv
        new_environ = os.environ.copy()
        new_environ['WERKZEUG_RUN_MAIN'] = 'true'

        # a weird bug on windows. sometimes unicode strings end up in the
        # environment and subprocess.call does not like this, encode them
        # to latin1 and continue.
        if os.name == 'nt' and PY2:
            for key, value in iteritems(new_environ):
                if isinstance(value, text_type):
                    new_environ[key] = value.encode('iso-8859-1')

        exit_code = subprocess.call(args, env=new_environ)
        if exit_code != 3:
            return exit_code
开发者ID:limodou,项目名称:uliweb,代码行数:25,代码来源:serving.py


示例15: run_simple

def run_simple(
    hostname,
    port,
    application,
    use_reloader=False,
    use_debugger=False,
    use_evalex=True,
    extra_files=None,
    reloader_interval=1,
    reloader_type="auto",
    threaded=False,
    processes=1,
    request_handler=None,
    static_files=None,
    passthrough_errors=False,
    ssl_context=None,
):
    if use_debugger:
        from werkzeug.debug import DebuggedApplication

        application = DebuggedApplication(application, use_evalex)
    if static_files:
        from werkzeug.wsgi import SharedDataMiddleware

        application = SharedDataMiddleware(application, static_files)

    def inner():
        # Override here
        make_server(
            hostname, port, application, threaded, processes, request_handler, passthrough_errors, ssl_context
        ).serve_forever()

    if os.environ.get("WERKZEUG_RUN_MAIN") != "true":
        display_hostname = hostname != "*" and hostname or "localhost"
        if ":" in display_hostname:
            display_hostname = "[%s]" % display_hostname
        quit_msg = "(Press CTRL+C to quit)"
        _log(
            "info",
            " * Running on %s://%s:%d/ %s",
            ssl_context is None and "http" or "https",
            display_hostname,
            port,
            quit_msg,
        )
    if use_reloader:
        # Create and destroy a socket so that any exceptions are raised before
        # we spawn a separate Python interpreter and lose this ability.
        address_family = select_ip_version(hostname, port)
        test_socket = socket.socket(address_family, socket.SOCK_STREAM)
        test_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        test_socket.bind((hostname, port))
        test_socket.close()

        from werkzeug._reloader import run_with_reloader

        run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
    else:
        inner()
开发者ID:ZionOps,项目名称:w3af,代码行数:59,代码来源:mp_flask.py


示例16: stop

def stop():
    _log('info', 'Issuing kill command')
    subprocess.call(["sudo pkill -9 -f user_script.py"], shell = True)
    #commands.getstatusoutput('python /home/pi/blockytalky/code/kill.py')
    toSend = Message("name", None, "HwCmd", Message.createImage(motor1=0, motor2=0, motor3=0, motor4=0, pin13=0))
    toSend = Message.encode(toSend)
    channel.basic_publish(exchange="", routing_key="HwCmd", body=toSend)
    return 'OK'
开发者ID:ealter,项目名称:blockytalky,代码行数:8,代码来源:blockly_webserver.py


示例17: log_startup

 def log_startup(sock):
     display_hostname = hostname not in ('', '*') and hostname or 'localhost'
     if ':' in display_hostname:
         display_hostname = '[%s]' % display_hostname
     quit_msg = '(Press CTRL+C to quit)'
     port = sock.getsockname()[1]
     _log('info', ' * Running on %s://%s:%d/ %s',
          ssl_context is None and 'http' or 'https',
          display_hostname, port, quit_msg)
开发者ID:ACollectionOfAtoms,项目名称:acoa2,代码行数:9,代码来源:serving.py


示例18: restart_with_reloader

def restart_with_reloader():
    to_mon = []
    while 1:
        _log('info', ' * Clastic restarting with reloader')
        args = [sys.executable] + sys.argv
        new_environ = os.environ.copy()
        new_environ['WERKZEUG_RUN_MAIN'] = 'true'
        if os.name == 'nt':
            for key, value in new_environ.iteritems():
                if isinstance(value, unicode):
                    new_environ[key] = value.encode('iso-8859-1')
        stderr_buff = []
        child_proc = subprocess.Popen(args, env=new_environ, stderr=subprocess.PIPE)
        rf = child_proc.stderr
        exit_code, lines = None, []
        while exit_code is None or lines:
            if child_proc.poll() is None:
                lines.append(rf.readline())
            elif exit_code is None:
                lines.extend(rf.readlines())
                exit_code = child_proc.returncode
                if not lines:
                    break
            cur_line = lines.pop(0)
            if cur_line.startswith(_MON_PREFIX):
                to_mon = literal_eval(cur_line[len(_MON_PREFIX):])
            else:
                sys.stderr.write(cur_line)
                stderr_buff.append(cur_line)
                if len(stderr_buff) > _STDERR_BUFF_SIZE:
                    stderr_buff.pop(0)

        if exit_code == 3:
            continue
        elif exit_code == 1 and stderr_buff:
            enable_tty_echo()
            from clastic import flaw
            tb_str = ''.join(stderr_buff)
            err_app = flaw.create_app(tb_str, to_mon)
            # TODO: these values should be passed through
            err_server = make_server('localhost', 5000, err_app)
            thread.start_new_thread(err_server.serve_forever, ())
            try:
                reloader_loop(to_mon, 1)
            except KeyboardInterrupt:
                return 0
            except SystemExit as se:
                if se.code == 3:
                    continue
                return se.code
            finally:
                err_server.shutdown()
                err_server.server_close()
            return 0
        else:
            return exit_code
开发者ID:canassa,项目名称:clastic,代码行数:56,代码来源:server.py


示例19: commitSession

def commitSession():
    sessionID = session['sessionID']
    userSession = UserSession.query.get(sessionID)
    _log("info", "mr usersessio: " + userSession.__str__())
    userSession.commitSession()
    
    sessionID = session.pop('sessionID',None)
    session.pop('isPauzed',None)
    
    #return redirect("app/" + session["userID"].__str__() + "/dashboard")
    return "Yolo"
开发者ID:BGordts,项目名称:peno3_iStudyPlus,代码行数:11,代码来源:sessionController.py


示例20: upload

def upload():
    startTime = None
    endTime = None
    if request.method == "POST":
        data = request.form
        data1 = data.copy()
        data2 = data1.get('<xml xmlns')
        _log('info', 'Blockly code received')

        toWrite = "<xml xmlns = " + data2
        upload_code(toWrite)
        return 'OK'
开发者ID:ealter,项目名称:blockytalky,代码行数:12,代码来源:blockly_webserver.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python _internal._parse_signature函数代码示例发布时间:2022-05-26
下一篇:
Python _internal._get_environ函数代码示例发布时间: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