Skip to content

Commit

Permalink
Show something useful from EvtSubscribe_push demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Jun 4, 2024
1 parent f82f936 commit 3ece48f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Coming in build 307, as yet unreleased
--------------------------------------

### pywin32
* The `EvtSubscribe_push` demo now actually demonstrates the callback action and the event context being filled. (#2281, @Avasam)
* Fixed accidentally trying to raise a `str` instead of an `Exception` in (#2270, @Avasam)
* `Pythonwin/pywin/debugger/debugger.py`
* `Pythonwin/pywin/framework/dlgappcore.py`
Expand Down
9 changes: 8 additions & 1 deletion win32/Demos/EvtSubscribe_push.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## Demonstrates a "push" subscription with a callback function
from __future__ import annotations

from time import sleep

import win32evtlog

query_text = '*[System[Provider[@Name="Microsoft-Windows-Winlogon"]]]'
Expand All @@ -15,11 +19,14 @@ def c(reason, context, evt):
return 0


evttext = []
evttext: list[str] = []
s = win32evtlog.EvtSubscribe(
"System",
win32evtlog.EvtSubscribeStartAtOldestRecord,
Query="*",
Callback=c,
Context=evttext,
)

sleep(0.001)
print("\n".join(evttext))

0 comments on commit 3ece48f

Please sign in to comment.