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


Python logger.debug函数代码示例

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


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

示例1: start

    def start(self):
        """
        Start the daemon
        """
        logger.debug('Starting daemon')
        # Check for a pidfile to see if the daemon already runs
        try:
            pf = open(self.pidfile, 'r')
            pid = int(pf.read().strip())
            pf.close()
        except IOError:
            pid = None

        if pid:
            message = "pidfile {} already exist. Daemon already running?\n".format(pid)
            logger.error(message)
            sys.stderr.write(message)
            sys.exit(1)

        # Start the daemon
        self.daemonize()
        try:
            self.run()
        except Exception as e:
            logger.error('Exception running process: {}'.format(e))

        if os.path.exists(self.pidfile):
            os.remove(self.pidfile)
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:28,代码来源:daemon.py

示例2: do_POST

    def do_POST(self):
        path = self.path.split('?')[0][1:].split('/')
        if path[0] != HTTPServerHandler.uuid:
            self.sendJsonError(403, 'Forbidden')
            return

        if len(path) != 2:
            self.sendJsonError(400, 'Invalid request')
            return

        try:
            HTTPServerHandler.lock.acquire()
            length = int(self.headers.getheader('content-length'))
            content = self.rfile.read(length)
            logger.debug('length: {}, content >>{}<<'.format(length, content))
            params = json.loads(content)

            operation = getattr(self, 'post_' + path[1])
            result = operation(params)  # Protect not POST methods
        except AttributeError:
            self.sendJsonError(404, 'Method not found')
            return
        except Exception as e:
            logger.error('Got exception executing POST {}: {}'.format(path[1], utils.toUnicode(e.message)))
            self.sendJsonError(500, str(e))
            return
        finally:
            HTTPServerHandler.lock.release()

        self.sendJsonResponse(result)
开发者ID:dkmstr,项目名称:openuds,代码行数:30,代码来源:httpserver.py

示例3: run

    def run(self):
        if self.ipc is None:
            return
        self.running = True

        # Wait a bit so we ensure IPC thread is running...
        time.sleep(2)

        while self.running and self.ipc.running:
            try:
                msg = self.ipc.getMessage()
                if msg is None:
                    break
                msgId, data = msg
                logger.debug('Got Message on User Space: {}:{}'.format(msgId, data))
                if msgId == ipc.MSG_MESSAGE:
                    self.displayMessage.emit(QtCore.QString.fromUtf8(data))
                elif msgId == ipc.MSG_LOGOFF:
                    self.logoff.emit()
                elif msgId == ipc.MSG_SCRIPT:
                    self.script.emit(QtCore.QString.fromUtf8(data))
                elif msgId == ipc.MSG_INFORMATION:
                    self.information.emit(pickle.loads(data))
            except Exception as e:
                try:
                    logger.error('Got error on IPC thread {}'.format(utils.exceptionToMessage(e)))
                except:
                    logger.error('Got error on IPC thread (an unicode error??)')

        if self.ipc.running is False and self.running is True:
            logger.warn('Lost connection with Service, closing program')

        self.exit.emit()
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:33,代码来源:UDSActorUser.py

示例4: _request

    def _request(self, url, data=None):
        try:
            if data is None:
                # Old requests version does not support verify, but they do not checks ssl certificate by default
                if self.newerRequestLib:
                    r = requests.get(url, verify=VERIFY_CERT)
                else:
                    logger.debug('Requesting with old')
                    r = requests.get(url)  # Always ignore certs??
            else:
                if data == '':
                    data = '{"dummy": true}'  # Ensures no proxy rewrites POST as GET because body is empty...
                if self.newerRequestLib:
                    r = requests.post(url, data=data, headers={'content-type': 'application/json'}, verify=VERIFY_CERT)
                else:
                    logger.debug('Requesting with old')
                    r = requests.post(url, data=data, headers={'content-type': 'application/json'})

            # From versions of requests, content maybe bytes or str. We need str for json.loads
            content = r.content
            if not isinstance(content, six.text_type):
                content = content.decode('utf8')
            r = json.loads(content)  # Using instead of r.json() to make compatible with oooold rquests lib versions
        except requests.exceptions.RequestException as e:
            raise ConnectionError(e)
        except Exception as e:
            raise ConnectionError(exceptionToMessage(e))

        ensureResultIsOk(r)

        return r
开发者ID:dkmstr,项目名称:openuds,代码行数:31,代码来源:REST.py

示例5: rename

def rename(newName):
    '''
    RH, Centos, Fedora Renamer
    Expects new host name on newName
    Host does not needs to be rebooted after renaming
    '''
    logger.debug('using RH renamer')

    with open('/etc/hostname', 'w') as hostname:
        hostname.write(newName)

    # Force system new name
    os.system('/bin/hostname %s' % newName)

    # add name to "hosts"
    with open('/etc/hosts', 'r') as hosts:
        lines = hosts.readlines()
    with open('/etc/hosts', 'w') as hosts:
        hosts.write("127.0.1.1\t{}\n".format(newName))
        for l in lines:
            if l[:9] != '127.0.1.1':  # Skips existing 127.0.1.1. if it already exists
                hosts.write(l)

    with open('/etc/sysconfig/network', 'r') as net:
        lines = net.readlines()
    with open('/etc/sysconfig/network', 'w') as net:
        net.write('HOSTNAME={}\n'.format(newName))
        for l in lines:
            if l[:8] != 'HOSTNAME':
                net.write(l)

    return True
开发者ID:dkmstr,项目名称:openuds,代码行数:32,代码来源:redhat.py

示例6: _request

    def _request(self, url, data=None):
        try:
            if data is None:
                # Old requests version does not support verify, but they do not checks ssl certificate by default
                if self.newerRequestLib:
                    r = requests.get(url, verify=VERIFY_CERT)
                else:
                    logger.debug('Requesting with old')
                    r = requests.get(url)  # Always ignore certs??
            else:
                if self.newerRequestLib:
                    r = requests.post(url, data=data, headers={'content-type': 'application/json'}, verify=VERIFY_CERT)
                else:
                    logger.debug('Requesting with old')
                    r = requests.post(url, data=data, headers={'content-type': 'application/json'})

            r = json.loads(r.content)  # Using instead of r.json() to make compatible with oooold rquests lib versions
        except requests.exceptions.RequestException as e:
            raise ConnectionError(e)
        except Exception as e:
            raise ConnectionError(exceptionToMessage(e))

        ensureResultIsOk(r)

        return r
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:25,代码来源:REST.py

示例7: rename

def rename(newName):
    """
    Debian renamer
    Expects new host name on newName
    Host does not needs to be rebooted after renaming
    """
    logger.debug("using Debian renamer")

    with open("/etc/hostname", "w") as hostname:
        hostname.write(newName)

    # Force system new name
    os.system("/bin/hostname %s" % newName)

    # add name to "hosts"
    with open("/etc/hosts", "r") as hosts:
        lines = hosts.readlines()
    with open("/etc/hosts", "w") as hosts:
        hosts.write("127.0.1.1\t%s\n" % newName)
        for l in lines:
            if l[:9] == "127.0.1.1":  # Skips existing 127.0.1.1. if it already exists
                continue
            hosts.write(l)

    return True
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:25,代码来源:debian.py

示例8: clientMessageProcessor

    def clientMessageProcessor(self, msg, data):
        logger.debug('Got message {}'.format(msg))
        if self.api is None:
            logger.info('Rest api not ready')
            return

        if msg == ipc.REQ_LOGIN:
            res = self.api.login(data).split('\t')
            # third parameter, if exists, sets maxSession duration to this.
            # First & second parameters are ip & hostname of connection source
            if len(res) >= 3:
                self.api.maxSession = int(res[2])  # Third parameter is max session duration
                msg = ipc.REQ_INFORMATION  # Senf information, requested or not, to client on login notification
        elif msg == ipc.REQ_LOGOUT:
            self.api.logout(data)
            self.onLogout(data)
        elif msg == ipc.REQ_INFORMATION:
            info = {}
            if self.api.idle is not None:
                info['idle'] = self.api.idle
            if self.api.maxSession is not None:
                info['maxSession'] = self.api.maxSession
            self.ipc.sendInformationMessage(info)
        elif msg == ipc.REQ_TICKET:
            d = json.loads('data')
            try:
                result = self.api.getTicket(d['ticketId'], d['secure'])
                self.ipc.sendTicketMessage(result)
            except Exception:
                logger.exception('Getting ticket')
                self.ipc.sendTicketMessage({'error': 'invalid ticket'})
开发者ID:glyptodon,项目名称:openuds,代码行数:31,代码来源:service.py

示例9: setReady

 def setReady(self, ipsInfo, hostName=None):
     logger.debug('Notifying readyness: {}'.format(ipsInfo))
     #    data = ','.join(['{}={}'.format(v[0], v[1]) for v in ipsInfo])
     data = {
         'ips': ipsInfo,
         'hostname': hostName
     }
     return self.postMessage('ready', data)
开发者ID:dkmstr,项目名称:openuds,代码行数:8,代码来源:REST.py

示例10: postMessage

    def postMessage(self, msg, data, processData=True):
        logger.debug('Invoking post message {} with data {}'.format(msg, data))

        if self.uuid is None:
            raise ConnectionError('REST api has not been initialized')

        if processData:
            data = json.dumps({'data': data})
        url = self._getUrl('/'.join([self.uuid, msg]))
        return self._request(url, data)['result']
开发者ID:glyptodon,项目名称:openuds,代码行数:10,代码来源:REST.py

示例11: stop

    def stop(self):
        logger.debug('Stopping Server IPC')
        self.running = False
        for t in self.threads:
            t.stop()
        socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect(('localhost', self.port))
        self.serverSocket.close()

        for t in self.threads:
            t.join()
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:10,代码来源:ipc.py

示例12: cleanupFinishedThreads

 def cleanupFinishedThreads(self):
     '''
     Cleans up current threads list
     '''
     aliveThreads = []
     for t in self.threads:
         if t.isAlive():
             logger.debug('Thread {} is alive'.format(t))
             aliveThreads.append(t)
     self.threads[:] = aliveThreads
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:10,代码来源:ipc.py

示例13: sendRequestMessage

    def sendRequestMessage(self, msg, data=None):
        logger.debug('Sending request for msg: {}({}), {}'.format(msg, REV_DICT.get(msg), data))
        if data is None:
            data = b''

        if isinstance(data, six.text_type):  # Convert to bytes if necessary
            data = data.encode('utf-8')

        l = len(data)
        msg = six.int2byte(msg) + six.int2byte(l & 0xFF) + six.int2byte(l >> 8) + data
        self.clientSocket.sendall(msg)
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:11,代码来源:ipc.py

示例14: information

 def information(self, info):
     '''
     Invoked when received information from service
     '''
     logger.debug('Got information message: {}'.format(info))
     if 'idle' in info:
         idle = int(info['idle'])
         operations.initIdleDuration(idle)
         self.maxIdleTime = idle
         logger.debug('Set screensaver launching to {}'.format(idle))
     else:
         self.maxIdleTime = None
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:12,代码来源:UDSActorUser.py

示例15: testParameters

 def testParameters(self):
     logger.debug('Testing connection')
     try:
         cfg = self._getCfg()
         api = REST.Api(
             cfg['host'], cfg['masterKey'], cfg['ssl'])
         api.test()
         QtGui.QMessageBox.information(
             self, 'Test Passed', 'The test was executed successfully', QtGui.QMessageBox.Ok)
         logger.info('Test was passed successfully')
     except Exception as e:
         logger.info('Test error: {}'.format(utils.exceptionToMessage(e)))
         QtGui.QMessageBox.critical(self, 'Test Error', utils.exceptionToMessage(e), QtGui.QMessageBox.Ok)
开发者ID:dkmstr,项目名称:openuds,代码行数:13,代码来源:UDSActorConfig.py


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