mirror of
https://github.com/iperov/DeepFaceLive
synced 2025-07-16 10:03:42 -07:00
code release
This commit is contained in:
parent
b941ba41a3
commit
a902f11f74
354 changed files with 826570 additions and 1 deletions
53
xlib/mp/csw/Error.py
Normal file
53
xlib/mp/csw/Error.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
from typing import Union
|
||||
|
||||
from xlib.python import EventListener
|
||||
|
||||
from .CSWBase import ControlClient, ControlHost
|
||||
|
||||
|
||||
class Error:
|
||||
"""
|
||||
One-way error control.
|
||||
|
||||
"""
|
||||
|
||||
class Client(ControlClient):
|
||||
def __init__(self):
|
||||
ControlClient.__init__(self)
|
||||
|
||||
self._on_error_evl = EventListener()
|
||||
self._call_on_msg('error', self._on_msg_error)
|
||||
|
||||
def _on_msg_error(self, text):
|
||||
self._on_error_evl.call(text)
|
||||
|
||||
def call_on_error(self, func_or_list):
|
||||
"""
|
||||
Call when the error message arrive
|
||||
|
||||
func(text : Union[str,None])
|
||||
"""
|
||||
self._on_error_evl.add(func_or_list)
|
||||
|
||||
def _on_reset(self):
|
||||
self._on_msg_error(None)
|
||||
|
||||
|
||||
class Host(ControlHost):
|
||||
def __init__(self):
|
||||
ControlHost.__init__(self)
|
||||
|
||||
|
||||
def set_error(self, text : Union[str, None]):
|
||||
"""
|
||||
set tex
|
||||
|
||||
text str or None
|
||||
"""
|
||||
if text is None:
|
||||
self.disable()
|
||||
else:
|
||||
self.enable()
|
||||
self._send_msg('error', text)
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue