本文整理汇总了Python中event.Event方法的典型用法代码示例。如果您正苦于以下问题:Python event.Event方法的具体用法?Python event.Event怎么用?Python event.Event使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类event
的用法示例。
在下文中一共展示了event.Event方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def on(self, condition):
"""
Shortcut for creation and appending of a new Event
Parameters
----------
condition : `Condition`
Returns
-------
`Event`
"""
ev = Event(condition)
self._events.append(ev)
return ev
示例2: __config_value_changed_cb
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def __config_value_changed_cb(self, config, section, name, value):
section = section.replace('_', '-')
if section != 'engine/replace-with-kanji-python':
return
logger.debug("config_value_changed(%s, %s, %s): %s" % (section, name, value, self.__mode))
if name == "logging_level":
self.__logging_level = self.__load_logging_level(config)
elif name == "delay":
self.__reset()
self.__delay = self.__load_delay(config)
self.__event = Event(self, self.__delay, self.__layout)
elif name == "layout":
self.__reset()
self.__layout = self.__load_layout(config)
self.__event = Event(self, self.__delay, self.__layout)
elif name == "dictionary":
self.__reset()
self.__dict = self.__load_dictionary(config)
elif name == "mode":
self.set_mode(self.__load_input_mode(self.__config))
self.__override = True
示例3: __unicode__
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def __unicode__(self):
'''Provide a human-readable dump of the Fault's state.'''
s = super(Fault, self).__unicode__()
s += u'\nFault Header\n'
s += u'============\n'
for addl_info in self.alarm_additional_info:
s += u' Alarm Additional Info: {}: {}\n'.format(addl_info[0],
addl_info[1])
s += u' Alarm Condition: {}\n'.format(self.alarm_condition)
s += u' Alarm A Interface: {}\n'.format(self.alarm_a_interface)
s += u' Alarm Severity: {}\n'.format(self.event_severity)
s += u' Event Source Type: {}\n'.format(self.event_source_type)
s += u' Fault Fields Version: {}\n'.format(self.fault_fields_version)
s += u' Specific Problem: {}\n'.format(self.specific_problem)
s += u' VF Status: {}\n'.format(self.vf_status)
return s
示例4: __unicode__
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def __unicode__(self):
'''Provide a human-readable dump of the Syslog's state.
'''
s = super(Syslog, self).__unicode__()
s += u'\nSyslog Header\n'
s += u'============\n'
s += u' Event source type: {}\n'.format(self.event_source_type)
s += u' Tag: {}\n'.format(self.syslog_tag)
s += u' Message: {}\n'.format(self.syslog_msg)
s += u' Host: {}\n'.format(self.event_source_host)
s += u' Facility: {}\n'.format(self.syslog_facility)
s += u' Proc.: {}\n'.format(self.syslog_proc)
s += u' Proc ID: {}\n'.format(self.syslog_proc_id)
s += u' Version: {}\n'.format(self.syslog_ver)
s += u' SData: {}\n'.format(self.syslog_sdata)
s += u' Fields Version: {}\n'.format(self.syslog_fields_version)
return s
示例5: __init__
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def __init__(self):
super(EngineReplaceWithKanji, self).__init__()
self.__mode = 'A' # __mode must be one of _input_mode_names
self.__override = False
self.__layout = roomazi.layout
self.__to_kana = self.__handle_roomazi_layout
self.__preedit_string = ''
self.__previous_text = ''
self.__ignore_surrounding_text = False
self.__lookup_table = IBus.LookupTable.new(10, 0, True, False)
self.__lookup_table.set_orientation(IBus.Orientation.VERTICAL)
self.__init_props()
self.__config = IBus.Bus().get_config()
self.__config.connect('value-changed', self.__config_value_changed_cb)
self.__logging_level = self.__load_logging_level(self.__config)
self.__dict = self.__load_dictionary(self.__config)
self.__layout = self.__load_layout(self.__config)
self.__delay = self.__load_delay(self.__config)
self.__event = Event(self, self.__delay, self.__layout)
self.set_mode(self.__load_input_mode(self.__config))
self.__shrunk = ''
示例6: __init__
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def __init__(self, uri):
super().__init__()
self._uri = uri
# Automatically extract uri to stream from m3u playlists
self._uri = utils.read_uri_from_playlist(self._uri)
self._stopFlag = Event()
self._thread = None
self.signal_title_read.connect(self._slot_title_read)
示例7: __call__
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def __call__(self, event_type, event_data):
"""Adds a new event to the event queue returned from start().
Args:
event_type(int): A numeric id corresponding to an event in
google.assistant.event.EventType.
event_data(str): A serialized JSON string with key/value pairs
for event arguments.
"""
self._event_queue.offer(Event(event_type, event_data))
示例8: _to_events
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def _to_events(self, submission):
if isinstance(submission, (tuple, list)):
return sum(map(self._to_events, submission), [])
elif isinstance(submission, Event):
return [submission]
else:
return []
示例9: submit
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def submit(self, submission):
"""
Submit a task in form of an event, a task or an task-like object
Parameters
----------
submission : (list of) [`Task` or object or `Event`]
Returns
-------
list of `Task`
the list of tasks actually executed after looking at all objects
"""
return self._to_tasks(submission)
示例10: getchar
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def getchar(self):
'''Get next character from queue.'''
Cevent = INPUT_RECORD()
count = c_int(0)
while 1:
status = self.ReadConsoleInputW(self.hin, byref(Cevent), 1, byref(count))
if (status and count.value==1 and Cevent.EventType == 1 and
Cevent.Event.KeyEvent.bKeyDown):
sym = keysym(Cevent.Event.KeyEvent.wVirtualKeyCode)
if len(sym) == 0:
sym = Cevent.Event.KeyEvent.uChar.AsciiChar
return sym
示例11: __init__
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def __init__(self, source, sender=None, rule=None, event=Event,
clean=None, parser_num=1, queue_size=1024, retry_time=600,
process=False, fmt='result', **kwargs):
if process:
self.Queue = multiprocessing.Queue
self.Process = multiprocessing.Process
else:
self.Queue = Queue.Queue
self.Process = threading.Thread
clean = clean or DefaultCleaner(fmt).clean
super(Agent, self).__init__(**kwargs)
self.clean = try_catch(clean)
self.source = source
self.sender = sender or Null()
self.event = event
self.parser = LogParser(rule) if rule else DefaultParser()
self.sender.send = send_retry(self.sender.send, self)
self.qin = self.Queue(queue_size or 1024)
self.parser_num = 0
self.parser_init = parser_num or 1
self.parsers = []
self.agentname = kwargs.get('name', self.name)
self.retry_time = retry_time or 600
self.finish = multiprocessing.Event()
self.inter = multiprocessing.Event()
示例12: wait
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def wait(self, dwMilliseconds = None):
"""
Waits for the next debug event.
@see: L{cont}, L{dispatch}, L{loop}
@type dwMilliseconds: int
@param dwMilliseconds: (Optional) Timeout in milliseconds.
Use C{INFINITE} or C{None} for no timeout.
@rtype: L{Event}
@return: An event that occured in one of the debugees.
@raise WindowsError: Raises an exception on error.
If no target processes are left to debug,
the error code is L{win32.ERROR_INVALID_HANDLE}.
"""
# Wait for the next debug event.
raw = win32.WaitForDebugEvent(dwMilliseconds)
event = EventFactory.get(self, raw)
# Remember it.
self.lastEvent = event
# Return it.
return event
示例13: getchar
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def getchar(self):
'''Get next character from queue.'''
Cevent = INPUT_RECORD()
count = c_int(0)
while 1:
status = self.ReadConsoleInputA(self.hin, byref(Cevent), 1, byref(count))
if (status and count.value==1 and Cevent.EventType == 1 and
Cevent.Event.KeyEvent.bKeyDown):
sym = keysym(Cevent.Event.KeyEvent.wVirtualKeyCode)
if len(sym) == 0:
sym = Cevent.Event.KeyEvent.uChar.AsciiChar
return sym
示例14: parse
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def parse(self, request):
''' This method turns HTTPRequset into Event and returns it. '''
# [CAUTION] if the request does not end with '\r\n', then parse ends with error.
request_line = request.split('\r\n')[0]
additional_info = request.split('\r\n')[1:]
# 1. parsing request_line
parsed_rl = request_line.split(' ')
if len(parsed_rl) == 3:
self.method = parsed_rl[0]
self.request_uri = parsed_rl[1]
self.protocol = parsed_rl[2]
# 2. parsing additional information
# general-header, request-header, entity-header
# especially, get 'Connection' info.
info_dict = {}
print('Additional info: ' + str(additional_info))
for info in additional_info:
if ': ' not in info:
continue
key = info.split(': ')[0]
value = info.split(': ')[1]
info_dict[key] = value
# TODO(clsan) : If connection is None, what should we do?
self.connection = info_dict.get('Connection')
# self.accept_ranges = info_dict['Accept-Ranges']
# print('accept_ranges:' + self.accept_ranges)
# Check whether data is inserted correctly
print('Method: ' + self.method)
print('Request-URI: ' + self.request_uri)
print('HTTP-Version: ' + self.protocol)
print('Connection: ' + self.connection)
# Check whether requested uri needs disk_io or not.
return Event(self.method, self.request_uri, disk_io=(self.request_uri != '/'), connection = self.connection)
示例15: run
# 需要导入模块: import event [as 别名]
# 或者: from event import Event [as 别名]
def run(self, CLIENT_SOCKET, mask):
# data = CLIENT_SOCKET.recv(self.BUFFER_SIZE)
data = CLIENT_SOCKET.recv(512)
# Receive data from the socket. The return value is a bytes object representing the data received.
# The maximum amount of data to be received at once is specified by bufsize.
data_size = 0
data_size += len(data)
decoded_data = data.decode('utf-8')
if data_size == 0:
sel.unregister(CLIENT_SOCKET)
CLIENT_SOCKET.close()
print('Connection from client is disconnected.')
else:
if decoded_data[-2:] != '\r\n':
print('Bad Request(too long HTTP header)')
print('Close connection from client')
error_event = Event()
error_event.CLIENT_SOCKET = CLIENT_SOCKET
raise EventLoopAppException(HTTP_400_BAD_REQUEST, 'Bad Request(too long HTTP header)', error_event)
else:
print('[INFO][%s] Received data from client.' % ctime())
parser = HTTPParser()
event = parser.parse(decoded_data) # Request turned into event.
event.CLIENT_SOCKET = CLIENT_SOCKET
self.event_queue.enqueue(event)