Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions winevt/EventLog/Subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ def callback(self):

@callback.setter
def callback(self, callback):
if type(callback) is not type(lambda x: x):
raise Exception("Did not receive function for callback. Recieved invalid type {0}".format(type(callback)))
if not callable(callback):
raise Exception("Did not receive a callable for callback. Received invalid type {0}".format(type(callback)))

if len(signature(callback).parameters) != 3:
raise Exception("Python callback function must accept 3 parameters: action, pContext, Event")
param_count = len(signature(callback).parameters)
if param_count != 3 and param_count != 4:
raise Exception(
"Python callback function must accept either 3 or 4 parameters: action, pContext, Event, and optionally self for methods.")

# Keep track of the original function
self.__callback_python = callback
Expand Down