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


Python Logger.addPrintCallback方法代码示例

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


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

示例1: RemoteExecutionThread

# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import addPrintCallback [as 别名]
class RemoteExecutionThread(QtCore.QThread):
    """ Threaded external processor execution"""

#===================================================================================================
#                                                                                       C L A S S

    _ACTIVE_THREAD_STORAGE = []

#___________________________________________________________________________________________________ __init__
    def __init__(self, parent, **kwargs):
        QtCore.QThread.__init__(self, parent)

        self._events           = dict()
        self._log              = Logger(self)
        self._log.trace        = True
        self._log.addPrintCallback(self._handleLogWritten)
        self._response         = None
        self._output           = None
        self._error            = None
        self._explicitComplete = ArgsUtils.get('explicitComplete', False, kwargs)

        class RETCompleteSignal(QtCore.QObject):
            signal = QtCore.Signal(dict)
        self._completeSignal = RETCompleteSignal()

        class RETLogSignal(QtCore.QObject):
            signal = QtCore.Signal(str)
        self._logSignal = RETLogSignal()

        class RETProgressSignal(QtCore.QObject):
            signal = QtCore.Signal(dict)
        self._progressSignal = RETProgressSignal()

        class RETEventSignal(QtCore.QObject):
            signal = QtCore.Signal(dict)
        self._eventSignal = RETEventSignal()

        # Add the thread to the static active thread storage so that it won't be garbage collected
        # until the thread completes.
        self.__class__._ACTIVE_THREAD_STORAGE.append(self)

        self._connectSignals(**kwargs)

#===================================================================================================
#                                                                                   G E T / S E T

#___________________________________________________________________________________________________ GS: log
    @property
    def log(self):
        return self._log

#___________________________________________________________________________________________________ GS: logSignal
    @property
    def logSignal(self):
        return self._logSignal

#___________________________________________________________________________________________________ GS: completeSignal
    @property
    def completeSignal(self):
        return self._completeSignal

#___________________________________________________________________________________________________ GS: progressSignal
    @property
    def progressSignal(self):
        return self._progressSignal

#___________________________________________________________________________________________________ GS: response
    @property
    def response(self):
        return self._response

#___________________________________________________________________________________________________ GS: output
    @property
    def output(self):
        return self._output

#___________________________________________________________________________________________________ GS: error
    @property
    def error(self):
        return self._error

#===================================================================================================
#                                                                                     P U B L I C

#___________________________________________________________________________________________________ dispatchEvent
    def dispatchEvent(self, identifier, target =None, data =None):
        self._eventSignal.signal.emit({
            'id':identifier,
            'source':self,
            'target':target if target else self,
            'data':data })

#___________________________________________________________________________________________________ execute
    def execute(
            self, callback =None, logCallback =None, progressCallback =None,
            eventCallback =None, **kwargs
    ):
        self._connectSignals(
            callback=callback,
            logCallback=logCallback,
#.........这里部分代码省略.........
开发者ID:hannahp,项目名称:PyGlass,代码行数:103,代码来源:RemoteExecutionThread.py

示例2: RemoteExecutionThread

# 需要导入模块: from pyaid.debug.Logger import Logger [as 别名]
# 或者: from pyaid.debug.Logger.Logger import addPrintCallback [as 别名]
class RemoteExecutionThread(QtCore.QThread):
    """ Threaded external processor execution"""

#===================================================================================================
#                                                                                       C L A S S

    _ACTIVE_THREAD_STORAGE = []

    completeSignal = QtCore.Signal(object)
    eventSignal    = QtCore.Signal(object)
    logSignal      = QtCore.Signal(object)
    progressSignal = QtCore.Signal(object)

#___________________________________________________________________________________________________ __init__
    def __init__(self, parent, **kwargs):
        QtCore.QThread.__init__(self, parent)

        self.userData = ArgsUtils.get('userData', None, kwargs)

        self._events           = dict()
        self._log              = Logger(self)
        self._log.trace        = True
        self._log.addPrintCallback(self._handleLogWritten)
        self._logger           = self._log

        self._maxLogBufferSize = 0
        self._logBuffer        = []
        self._returnCode         = None
        self._output           = None
        self._error            = None
        self._explicitComplete = ArgsUtils.get('explicitComplete', False, kwargs)

        # Add the thread to the static active thread storage so that it won't be garbage collected
        # until the thread completes.
        self.__class__._ACTIVE_THREAD_STORAGE.append(self)

        self._connectSignals(**kwargs)

#===================================================================================================
#                                                                                   G E T / S E T

#___________________________________________________________________________________________________ GS: success
    @property
    def success(self):
        return self.returnCode == 0

#___________________________________________________________________________________________________ GS: log
    @property
    def log(self):
        return self._log

#___________________________________________________________________________________________________ GS: logger
    @property
    def logger(self):
        return self._log

#___________________________________________________________________________________________________ GS: response
    @property
    def response(self):
        warnings.warn(
            'RemoteExceutionThread.response is deprecated in favor of .returnCode',
            DeprecationWarning)
        self._log.write('[DEPRECATION WARNING]: Use returnCode instead of response', traceStack=True)
        return self._returnCode

#___________________________________________________________________________________________________ GS: returnCode
    @property
    def returnCode(self):
        return self._returnCode

#___________________________________________________________________________________________________ GS: output
    @property
    def output(self):
        return self._output

#___________________________________________________________________________________________________ GS: error
    @property
    def error(self):
        return self._error

#===================================================================================================
#                                                                                     P U B L I C

#___________________________________________________________________________________________________ dispatchEvent
    def dispatchEvent(self, signal, identifier =None, data =None):
        signal.emit(RemoteThreadEvent(
            identifier=identifier,
            target=self,
            data=data))

#___________________________________________________________________________________________________ execute
    def execute(
            self, callback =None, logCallback =None, progressCallback =None,
            eventCallback =None, **kwargs
    ):
        self._connectSignals(
            callback=callback,
            logCallback=logCallback,
            progressCallback=progressCallback,
            eventCallback=eventCallback,
#.........这里部分代码省略.........
开发者ID:sernst,项目名称:PyGlass,代码行数:103,代码来源:RemoteExecutionThread.py


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