当前位置: 首页>>代码示例>>Python>>正文


Python kivy.logger方法代码示例

本文整理汇总了Python中kivy.logger方法的典型用法代码示例。如果您正苦于以下问题:Python kivy.logger方法的具体用法?Python kivy.logger怎么用?Python kivy.logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy的用法示例。


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

示例1: _do

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def _do(self,method,body,qargs):
        url = str(qargs.get('url'))
        if not urlparse(url.lower()).scheme:
            url="http://%s:%s/%s"% (self.instance._webserver[0],self.instance._webserver[1],url.lstrip("/"))

        if self.request.query:
            url = url + "?" + self.request.query
        headers = {k[4:]: v for k, v in self.request.headers.items() if k.lower().startswith("set-")}

        http_client = tornado.httpclient.AsyncHTTPClient()
        logger.debug("PROXY FETCH (%s %s %s %s)",method,url,headers,body)
        try:
            response = await http_client.fetch(url, method=method,body=body,headers=headers,validate_cert = False)
            self.set_status(response.code)
            for k, v in response.headers.items():
                if k.lower() in ["content-type", "date", "expires", "cache-control"]:
                    self.set_header(k,v)
            logger.debug("PROXY FETCH, return=%s, size=%s",response.code,len(response.body))
            self.write(response.body)
        except Exception as e:
            logger.debug("PROXY FETCH ERROR (%s), return 0",e)
            self.set_status(0)
            self.write(str(e)) 
开发者ID:manatlan,项目名称:guy,代码行数:25,代码来源:guy.py

示例2: emit

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def emit(self, message):
        # during the startup, store the message in the history
        if Logger.logfile_activated is None:
            FileHandler.history += [message]
            return

        # startup done, if the logfile is not activated, avoid history.
        if Logger.logfile_activated is False:
            FileHandler.history = []
            return

        if FileHandler.fd is None:
            try:
                self._configure()
                from kivy.config import Config
                Config.add_callback(self._configure, 'kivy', 'log_dir')
                Config.add_callback(self._configure, 'kivy', 'log_name')
            except Exception:
                # deactivate filehandler...
                FileHandler.fd = False
                Logger.exception('Error while activating FileHandler logger')
                return
            while FileHandler.history:
                _message = FileHandler.history.pop()
                self._write_message(_message)

        self._write_message(message) 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:29,代码来源:logger.py

示例3: logger_config_update

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def logger_config_update(section, key, value):
    if LOG_LEVELS.get(value) is None:
        raise AttributeError('Loglevel {0!r} doesn\'t exists'.format(value))
    Logger.setLevel(level=LOG_LEVELS.get(value))

#: Kivy default logger instance 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:8,代码来源:logger.py

示例4: get

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def get(self,page): # page doesn't contains a dot '.'
        #####################################################
        if not await callhttp(self,page):
        #####################################################
            if page=="" or page==self.instance._name:
                logger.debug("MainHandler: Render Main Instance (%s)",self.instance._name)
                self.write( self.instance._renderHtml() )
            else:
                chpage=self.instanciate(page) # auto-instanciate each time !
                chpage.parent = self.instance
                if chpage:
                    logger.debug("MainHandler: Render Children (%s)",page)
                    self.write( chpage._renderHtml() )
                else:
                    raise tornado.web.HTTPError(status_code=404) 
开发者ID:manatlan,项目名称:guy,代码行数:17,代码来源:guy.py

示例5: instanciate

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def instanciate(self,page):
        declared = {cls.__name__:cls for cls in Guy.__subclasses__()}
        gclass=declared[page]
        logger.debug("MainHandler: Auto instanciate (%s)",page)
        x=inspect.signature(gclass.__init__)
        args=[self.get_argument(i) for i in list(x.parameters)[1:]]
        return gclass(*args) 
开发者ID:manatlan,项目名称:guy,代码行数:9,代码来源:guy.py

示例6: sockwrite

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def sockwrite(theSock, **kwargs ):
    if theSock:
        try:
            await theSock.write_message(jDumps(kwargs))
        except Exception as e:
            logger.error("Socket write : can't:%s",theSock)
            if theSock in WebSocketHandler.clients: del WebSocketHandler.clients[theSock] 
开发者ID:manatlan,项目名称:guy,代码行数:9,代码来源:guy.py

示例7: emit

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def emit(event,*args):
    logger.debug(">>> Emit ALL: %s (%s)",event,args)
    for i in list( WebSocketHandler.clients.keys() ):
        await sockwrite(i,event=event,args=args) 
开发者ID:manatlan,项目名称:guy,代码行数:6,代码来源:guy.py

示例8: on_close

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def on_close(self):
        current=WebSocketHandler.clients[self]
        logger.debug("Disconnect %s",current._id)
        del WebSocketHandler.clients[self] 
开发者ID:manatlan,项目名称:guy,代码行数:6,代码来源:guy.py

示例9: run

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def run(self,log=False,autoreload=False,one=False,args=[]):
        """ Run the guy's app in a windowed env (one client)"""
        self._log=log
        if log:
            handler.setLevel(logging.DEBUG)
            logger.setLevel(logging.DEBUG)

        if ISANDROID: #TODO: add executable for kivy/iOs mac/apple
            runAndroid(self)
        else:
            lockPort=None
            if one:
                lp=LockPortFile(self._name)
                if lp.bringToFront():
                    return
                else:
                    lockPort = lp.create()

            ws=WebServer( self, autoreload=autoreload )
            ws.start()

            app=ChromeApp(ws.startPage,self._name,self.size,lockPort=lockPort,chromeargs=args)

            self.RETOUR=None
            def exit(v=None):
                self.RETOUR=v

                ws.exit()
                app.exit()

            tornado.autoreload.add_reload_hook(exit)

            self._callbackExit = exit
            try:
                app.wait() # block
            except KeyboardInterrupt:
                print("-Process stopped")

            ws.exit()
            ws.join()
            return self.RETOUR 
开发者ID:manatlan,项目名称:guy,代码行数:43,代码来源:guy.py

示例10: runCef

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def runCef(self,log=False,autoreload=False,one=False):
        """ Run the guy's app in a windowed cefpython3 (one client)"""
        self._log=log
        if log:
            handler.setLevel(logging.DEBUG)
            logger.setLevel(logging.DEBUG)

        lockPort=None
        if one:
            lp=LockPortFile(self._name)
            if lp.bringToFront():
                return
            else:
                lockPort = lp.create()

        ws=WebServer( self, autoreload=autoreload )
        ws.start()

        self.RETOUR=None
        try:
            app=CefApp(ws.startPage,self.size,lockPort=lockPort)

            def cefexit(v=None):
                self.RETOUR=v
                app.exit()

            tornado.autoreload.add_reload_hook(app.exit)

            self._callbackExit = cefexit
            try:
                app.wait() # block
            except KeyboardInterrupt:
                print("-Process stopped")
        except Exception as e:
            print("Trouble with CEF:",e)
        ws.exit()
        ws.join()
        return self.RETOUR 
开发者ID:manatlan,项目名称:guy,代码行数:40,代码来源:guy.py

示例11: serve

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def serve(self,port=8000,log=False,open=True,autoreload=False):
        """ Run the guy's app for multiple clients (web/server mode) """
        self._log=log
        if log:
            handler.setLevel(logging.DEBUG)
            logger.setLevel(logging.DEBUG)

        ws=WebServer( self ,"0.0.0.0",port=port, autoreload=autoreload )
        ws.start()

        self.RETOUR=None
        def exit(v=None):
            self.RETOUR=v
            ws.exit()

        self._callbackExit = exit
        print("Running", ws.startPage )

        if open: #auto open browser
            try:
                import webbrowser
                webbrowser.open_new_tab(ws.startPage)
            except:
                pass

        try:
            ws.join() #important !
        except KeyboardInterrupt:
            print("-Process stopped")
        ws.exit()
        return self.RETOUR 
开发者ID:manatlan,项目名称:guy,代码行数:33,代码来源:guy.py

示例12: emitMe

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def emitMe(self,event, *args):
        logger.debug(">>> emitMe %s (%s)",event,args)
        await sockwrite(self._wsock,event=event,args=args) 
开发者ID:manatlan,项目名称:guy,代码行数:5,代码来源:guy.py

示例13: _callMe

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def _callMe(self,jsmethod, *args):
        logger.debug(">>> callMe %s (%s)",jsmethod,args)
        key=uuid.uuid4().hex
        # send jsmethod
        await sockwrite(self._wsock,jsmethod=jsmethod,args=args,key=key)
        # wait the return (of the key)
        while 1:
            if key in WebSocketHandler.returns:
                response=WebSocketHandler.returns[key]
                del WebSocketHandler.returns[key]
                if "error" in response:
                    raise JSException(response["error"])
                else:
                    return response.get("value")
            await asyncio.sleep(0.01) 
开发者ID:manatlan,项目名称:guy,代码行数:17,代码来源:guy.py

示例14: on_message

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def on_message(self, message):
        current = WebSocketHandler.clients.get(self,None)
        if current is None:
            return

        o = jLoads(message)
        logger.debug("WS RECEPT: %s",o)
        method,args,uuid = o["command"],o.get("args"),o["uuid"]

        if method == "emit":
            event, *args = args
            await emit( event, *args )  # emit all
        elif method == "return":
            logger.debug(" as JS Response %s : %s",uuid,args)
            WebSocketHandler.returns[uuid]=args
        else:
            async def execution(function, uuid,mode):
                logger.debug(" as Execute (%s) %s(%s)",mode,method,args)
                try:
                    ret = await function()
                    ##############################################################
                    if type(ret)==dict and "script" in ret: #evil mode
                        s=ret["script"]
                        del ret["script"]
                        r = dict(result=ret,script=s, uuid=uuid) #evil mode
                    else:
                    ##############################################################
                        r = dict(result=ret, uuid=uuid)
                except concurrent.futures._base.CancelledError as e:
                    r = dict(error="task cancelled", uuid=uuid)
                except Exception as e:
                    r = dict(error=str(e), uuid=uuid)
                    logger.error("================================= in %s %s", method, mode)
                    logger.error(traceback.format_exc().strip())
                    logger.error("=================================")
                logger.debug(">>> (%s) %s",mode,r)
                await sockwrite(self,**r)

            fct=current._getRoutage(method)

            if asyncio.iscoroutinefunction( fct ):

                async def function():
                    return await current(self,method,*args)

                #asyncio.create_task( execution( function, uuid, "ASYNC") )  #py37
                asyncio.ensure_future ( execution( function, uuid, "ASYNC") ) #py35

            else:
                async def function():
                    return current(self,method,*args)

                await execution( function, uuid, "SYNC" ) 
开发者ID:manatlan,项目名称:guy,代码行数:55,代码来源:guy.py

示例15: _update_thread

# 需要导入模块: import kivy [as 别名]
# 或者: from kivy import logger [as 别名]
def _update_thread(self, instance):
        try:
            selection = instance.selection
            filename = selection[0] if len(selection) else None
            if filename:
                # Even though we stopped the RX thread, this is OK
                # since it doesn't return a value
                self.ids.fw_progress.title = "Processing"

                self._teardown_json_serial()

                self.ids.fw_progress.title = "Progress"

                # Get our firmware updater class and register the
                # callback that will update the progress gauge
                fu = fw_update.FwUpdater(logger=Logger)
                fu.register_progress_callback(self._update_progress_gauge)

                retries = 5
                port = None
                while retries > 0 and not port:
                    # Find our bootloader
                    port = fu.scan_for_device()

                    if not port:
                        retries -= 1
                        sleep(2)

                if not port:
                    self.ids.fw_progress.title = ""
                    raise Exception("Unable to locate bootloader")

                # Go on our jolly way
                fu.update_firmware(filename, port)
                self.ids.fw_progress.title = "Restarting"

                # Sleep for a few seconds since we need to let USB re-enumerate
                sleep(3)
            else:
                alertPopup('Error Loading', 'No firmware file selected')
        except Exception as detail:
            alertPopup('Error Loading', 'Failed to Load Firmware:\n\n{}'.format(detail))
            Logger.error(traceback.format_exc())

        self._restart_json_serial()
        self.ids.fw_progress.value = ''
        self.ids.fw_progress.title = "" 
开发者ID:autosportlabs,项目名称:RaceCapture_App,代码行数:49,代码来源:firmwareupdateview.py


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