當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。