How do i find some text and symbols in string python 3.7 - python-3.x

I need some help figuring out how to find TV (0) -> Broadcast (F): routing change (80)
From this lot....
Loaded CEC from /home/user/.local/lib/python2.7/site-packages/cec.so
Callback added
CEC has cec_adapter_descriptor
Initializing CEC library
CEC Log message: Broadcast (F): osd name set to 'Broadcast'
CEC Log message: connection opened, clearing any previous input and waiting for active transmissions to end before starting
CEC Log message: communication thread started
CEC Log message: turning controlled mode on
CEC Log message: communication thread ended
CEC Log message: connection opened
CEC Log message: GetPhysicalAddress - trying to get the physical address via ADL
CEC Log message: GetPhysicalAddress - ADL returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address via nvidia driver
CEC Log message: GetPhysicalAddress - nvidia driver returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address via drm files
CEC Log message: GetPhysicalAddress - drm files returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address from the OS
CEC Log message: GetPhysicalAddress - OS returned physical address 0000
CEC Log message: unregistering all CEC clients
CEC Log message: connection opened, clearing any previous input and waiting for active transmissions to end before starting
CEC Log message: communication thread started
CEC Log message: turning controlled mode on
CEC Log message: connection opened
CEC Log message: << Broadcast (F) -> TV (0): POLL
CEC Log message: << f0
CEC Log message: processor thread started
CEC Log message: setting the line timeout to 3
CEC Log message: >> POLL sent
CEC Log message: TV (0): device status changed into 'present'
CEC Log message: << requesting vendor ID of 'TV' (0)
CEC Log message: << f0:8c
CEC Log message: >> 0f:00:8c:04
Got event 4 with data ({'initiator': 0, 'parameters': '\x8c\x04', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 0},)
CEC Log message: marking opcode 'give device vendor id' as unsupported feature for device 'TV'
CEC Log message: expected response received (87: device vendor id)
CEC Log message: registering new CEC client - v4.0.4
CEC Log message: detecting logical address for type 'recording device'
CEC Log message: trying logical address 'Recorder 1'
CEC Log message: << Recorder 1 (1) -> Recorder 1 (1): POLL
CEC Log message: << 11
CEC Log message: >> TV (0) -> Broadcast (F): feature abort ( 0)
CEC Log message: CEC transmission - received response - TRANSMIT_FAILED_ACK
CEC Log message: << 11
CEC Log message: CEC transmission - received response - TRANSMIT_FAILED_ACK
CEC Log message: >> POLL not sent
CEC Log message: using logical address 'Recorder 1'
CEC Log message: Recorder 1 (1): device status changed into 'handled by libCEC'
CEC Log message: Recorder 1 (1): power status changed from 'unknown' to 'on'
CEC Log message: Recorder 1 (1): vendor = Pulse Eight (001582)
CEC Log message: Recorder 1 (1): CEC version 1.4
CEC Log message: AllocateLogicalAddresses - device '0', type 'recording device', LA '1'
CEC Log message: setting ackmask to 2
CEC Log message: Recorder 1 (1): osd name set to 'python-cec'
CEC Log message: Recorder 1 (1): menu language set to 'eng'
CEC Log message: GetPhysicalAddress - trying to get the physical address via ADL
CEC Log message: GetPhysicalAddress - ADL returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address via nvidia driver
CEC Log message: GetPhysicalAddress - nvidia driver returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address via drm files
CEC Log message: GetPhysicalAddress - drm files returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address from the OS
CEC Log message: GetPhysicalAddress - OS returned physical address 0000
CEC Log message: setting HDMI port to 1 on device TV (0)
CEC Log message: Recorder 1 (1): physical address changed from ffff to 1000
CEC Log message: << Recorder 1 (1) -> broadcast (F): physical address 1000
CEC Log message: << 1f:84:10:00:01
CEC Log message: using persisted autonomous mode setting: 'enabled'
CEC Log message: using persisted CEC version setting: '1.4'
CEC Log message: using persisted logical address setting: 'Recorder 1'
CEC Log message: >> 01:46
CEC Log message: using persisted device type setting: 'recording device'
Got event 4 with data ({'initiator': 0, 'parameters': '', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 70},)
CEC Log message: << Recorder 1 (1) -> TV (0): OSD name 'python-cec'
CEC Log message: << 10:47:70:79:74:68:6f:6e:2d:63:65:63
CEC Log message: >> TV (0) -> Recorder 1 (1): give osd name (46)
CEC Log message: using persisted logical address mask setting: '206'
CEC Log message: using persisted physical address setting: '1000'
CEC Log message: CEC client registered: libCEC version = 4.0.4, client version = 4.0.4, firmware version = 9, firmware build date: Fri Nov 2 10:08:56 2018 +0000, logical address(es) = Recorder 1 (1) , base device: TV (0), HDMI port number: 1, physical address: 1.0.0.0, compiled on Linux-4.4.0-161-generic ... , features: P8_USB, DRM, P8_detect, randr, Exynos, AOCEC
CEC Log message: << Recorder 1 (1) -> TV (0): OSD name 'python-cec'
CEC Log message: << 10:47:70:79:74:68:6f:6e:2d:63:65:63
CEC Log message: << requesting power status of 'TV' (0)
CEC Log message: << 10:8f
CEC Log message: RECEIVE_FAILED
Creating Device object for TV
CEC Log message: >> 01:90:00
Got event 4 with data ({'initiator': 0, 'parameters': '\x00', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 144},)
CEC Log message: TV (0): power status changed from 'unknown' to 'on'
CEC Log message: expected response received (90: report power status)
CEC Log message: >> TV (0) -> Recorder 1 (1): report power status (90)
CEC Log message: >> 01:46
Got event 4 with data ({'initiator': 0, 'parameters': '', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 70},)
CEC Log message: << Recorder 1 (1) -> TV (0): OSD name 'python-cec'
CEC Log message: << 10:47:70:79:74:68:6f:6e:2d:63:65:63
CEC Log message: >> TV (0) -> Recorder 1 (1): give osd name (46)
CEC Log message: >> 06
CEC Log message: << POLL: TV (0) -> Tuner 2 (6)
CEC Log message: >> 06
CEC Log message: << POLL: TV (0) -> Tuner 2 (6)
CEC Log message: >> 07
CEC Log message: << POLL: TV (0) -> Tuner 3 (7)
CEC Log message: >> 07
CEC Log message: << POLL: TV (0) -> Tuner 3 (7)
CEC Log message: >> 08
CEC Log message: << POLL: TV (0) -> Playback 2 (8)
CEC Log message: >> 08
CEC Log message: << POLL: TV (0) -> Playback 2 (8)
CEC Log message: >> 09
CEC Log message: << POLL: TV (0) -> Recorder 3 (9)
CEC Log message: >> 09
CEC Log message: << POLL: TV (0) -> Recorder 3 (9)
CEC Log message: >> 0f:80:30:00:30:00
Got event 4 with data ({'initiator': 0, 'parameters': '0\x000\x00', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 128},)
CEC Log message: >> TV (0) -> Broadcast (F): routing change (80)
CEC Log message: >> 0f:86:30:00
Got event 4 with data ({'initiator': 0, 'parameters': '0\x00', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 134},)
CEC Log message: >> TV (0) sets stream path to physical address 3000
CEC Log message: >> TV (0) -> Broadcast (F): set stream path (86)
CEC Log message: >> 0a
CEC Log message: << POLL: TV (0) -> Tuner 4 (a)
CEC Log message: >> 0a
CEC Log message: << POLL: TV (0) -> Tuner 4 (a)
CEC Log message: >> 0b
CEC Log message: << POLL: TV (0) -> Playback 3 (b)
CEC Log message: >> 0b
CEC Log message: << POLL: TV (0) -> Playback 3 (b)
CEC Log message: >> 0f:80:10:00:10:00
Got event 4 with data ({'initiator': 0, 'parameters': '\x10\x00\x10\x00', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 128},)
CEC Log message: making Recorder 1 (1) the active source
CEC Log message: marking the adapter as active source
CEC Log message: >> TV (0) -> Broadcast (F): routing change (80)
CEC Log message: >> source activated: Recorder 1 (1)
Got event 64 with data (True, 1)
CEC Log message: sending active source message for 'Recorder 1'
CEC Log message: << requesting vendor ID of 'TV' (0)
CEC Log message: 'give device vendor id' is marked as unsupported feature for device 'TV'
CEC Log message: << powering on 'TV' (0)
CEC Log message: << 10:04
CEC Log message: << Recorder 1 (1) -> broadcast (F): active source (1000)
CEC Log message: << 1f:82:10:00
CEC Log message: << Recorder 1 (1) -> TV (0): menu state 'activated'
CEC Log message: << 10:8e:00
CEC Log message: >> 0f:86:10:00
Got event 4 with data ({'initiator': 0, 'parameters': '\x10\x00', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 134},)
CEC Log message: >> TV (0) sets stream path to physical address 1000
CEC Log message: Recorder 1 (1) was already marked as active source
CEC Log message: >> source activated: Recorder 1 (1)
Got event 64 with data (True, 1)
CEC Log message: << Recorder 1 (1) -> broadcast (F): active source (1000)
CEC Log message: << 1f:82:10:00
CEC Log message: >> TV (0) -> Broadcast (F): set stream path (86)
CEC Log message: >> 01:46
Got event 4 with data ({'initiator': 0, 'parameters': '', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 70},)
CEC Log message: << Recorder 1 (1) -> TV (0): OSD name 'python-cec'
CEC Log message: << 10:47:70:79:74:68:6f:6e:2d:63:65:63
CEC Log message: >> TV (0) -> Recorder 1 (1): give osd name (46)
CEC Log message: >> 01:8d:02
Got event 4 with data ({'initiator': 0, 'parameters': '\x02', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 141},)
CEC Log message: << Recorder 1 (1) -> TV (0): menu state 'activated'
CEC Log message: << 10:8e:00
CEC Log message: >> TV (0) -> Recorder 1 (1): menu request (8D)
CEC Log message: >> 01:46
Got event 4 with data ({'initiator': 0, 'parameters': '', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 70},)
CEC Log message: << Recorder 1 (1) -> TV (0): OSD name 'python-cec'
CEC Log message: << 10:47:70:79:74:68:6f:6e:2d:63:65:63
CEC Log message: >> TV (0) -> Recorder 1 (1): give osd name (46)
CEC Log message: >> 01:8d:02
Got event 4 with data ({'initiator': 0, 'parameters': '\x02', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 141},)
CEC Log message: << Recorder 1 (1) -> TV (0): menu state 'activated'
CEC Log message: << 10:8e:00
CEC Log message: >> TV (0) -> Recorder 1 (1): menu request (8D)
^CTraceback (most recent call last):
File "/home/user/Documents/Python works/event-test.py", line 31, in <module>
while True:
KeyboardInterrupt
this is code snipped from my project.
def cb(event, *args):
print("Got event", event, "with data", args)
def log_cb(event, level, time, message):
print("CEC Log message:", message)
I made this but it doesn't work.
while True:
if "routing change(80)" in '$log_cb':
print("it worked ")
# if (cb == "___routing change(80) "):
# print("it worked ")
-------------------------------------------------- update -------------------------------------------------------------------
After Tom Robinson gave me a pointer in the right direction
here is the full code, the error i'm receiving is as he said but now I cannot fathom what arguments for event, level, time and message are needed
I've tried a few print commands to see if i can get the right info.
also tried if "routing change(80)" in log_cb(event, level, time, message): but get NameError: name 'event' is not defined
#!/usr/bin/env python
# Callback test; just to see if callbacks are working.
from __future__ import print_function
from time import sleep
import cec
print("Loaded CEC from", cec.__file__)
def cb(event, *args):
print("Got event", event, "with data", args)
# arguments: iils
def log_cb(event, level, time, message):
print("CEC Log message:", message)
cec.add_callback(cb, cec.EVENT_ALL & ~cec.EVENT_LOG)
cec.add_callback(log_cb, cec.EVENT_LOG)
print("Callback added")
sleep(2)
if cec.HAVE_CEC_ADAPTER_DESCRIPTOR:
print("CEC has cec_adapter_descriptor");
else:
print("CEC does not have cec_adapter_descriptor");
print("Initializing CEC library")
cec.init()
print("Creating Device object for TV")
while True:
# if "routing change(80)" in "log_cb":
if "routing change(80)" in log_cb():
print("it worked ")
And the new error:
Traceback (most recent call last):
File "/home/user/Documents/Python works/event-test.py", line 32, in <module>
if "routing change(80)" in log_cb():
TypeError: log_cb() takes exactly 4 arguments (0 given)
close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
Got event 4 with data ({'initiator': 0, 'parameters': '\x00', 'ack': False, 'opcode_set'
code update:
#!/usr/bin/env python
# Callback test; just to see if callbacks are working.
from __future__ import print_function
from time import sleep
import cec
print("Loaded CEC from", cec.__file__)
def cb(event, *args):
print("Got event", event, "with data", args)
# arguments: iils
def log_cb(event, level, time, message):
print("CEC Log message:", message)
if "routing change (80)" in message:
exit()
# print("it worked ")
# if (message == "routing change(80)"):
# exit()
cec.add_callback(cb, cec.EVENT_ALL & ~cec.EVENT_LOG)
cec.add_callback(log_cb, cec.EVENT_LOG)
print("Callback added")
sleep(2)
if cec.HAVE_CEC_ADAPTER_DESCRIPTOR:
print("CEC has cec_adapter_descriptor");
else:
print("CEC does not have cec_adapter_descriptor");
print("Initializing CEC library")
cec.init()
print("Creating Device object for TV")
print(cb)
print(log_cb)
#sleep(22)
while True:
pass
that while true is only there for testing as without it the script ends at line print(log_cb)
I'm running it from CLI
Log message:
Loaded CEC from /home/user/.local/lib/python2.7/site-packages/cec.so
Callback added
CEC has cec_adapter_descriptor
Initializing CEC library
CEC Log message: Broadcast (F): osd name set to 'Broadcast'
CEC Log message: connection opened, clearing any previous input and waiting for active transmissions to end before starting
CEC Log message: communication thread started
CEC Log message: turning controlled mode on
CEC Log message: communication thread ended
CEC Log message: connection opened
CEC Log message: GetPhysicalAddress - trying to get the physical address via ADL
CEC Log message: GetPhysicalAddress - ADL returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address via nvidia driver
CEC Log message: GetPhysicalAddress - nvidia driver returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address via drm files
CEC Log message: GetPhysicalAddress - drm files returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address from the OS
CEC Log message: GetPhysicalAddress - OS returned physical address 0000
CEC Log message: unregistering all CEC clients
CEC Log message: connection opened, clearing any previous input and waiting for active transmissions to end before starting
CEC Log message: communication thread started
CEC Log message: turning controlled mode on
CEC Log message: connection opened
CEC Log message: << Broadcast (F) -> TV (0): POLL
CEC Log message: << f0
CEC Log message: processor thread started
CEC Log message: setting the line timeout to 3
CEC Log message: >> POLL sent
CEC Log message: TV (0): device status changed into 'present'
CEC Log message: << requesting vendor ID of 'TV' (0)
CEC Log message: << f0:8c
CEC Log message: >> 0f:00:8c:04
Got event 4 with data ({'initiator': 0, 'parameters': '\x8c\x04', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 0},)
CEC Log message: marking opcode 'give device vendor id' as unsupported feature for device 'TV'
CEC Log message: expected response received (87: device vendor id)
CEC Log message: registering new CEC client - v4.0.4
CEC Log message: detecting logical address for type 'recording device'
CEC Log message: trying logical address 'Recorder 1'
CEC Log message: << Recorder 1 (1) -> Recorder 1 (1): POLL
CEC Log message: << 11
CEC Log message: >> TV (0) -> Broadcast (F): feature abort ( 0)
CEC Log message: CEC transmission - received response - TRANSMIT_FAILED_ACK
CEC Log message: << 11
CEC Log message: CEC transmission - received response - TRANSMIT_FAILED_ACK
CEC Log message: >> POLL not sent
CEC Log message: using logical address 'Recorder 1'
CEC Log message: Recorder 1 (1): device status changed into 'handled by libCEC'
CEC Log message: Recorder 1 (1): power status changed from 'unknown' to 'on'
CEC Log message: Recorder 1 (1): vendor = Pulse Eight (001582)
CEC Log message: Recorder 1 (1): CEC version 1.4
CEC Log message: AllocateLogicalAddresses - device '0', type 'recording device', LA '1'
CEC Log message: setting ackmask to 2
CEC Log message: Recorder 1 (1): osd name set to 'python-cec'
CEC Log message: Recorder 1 (1): menu language set to 'eng'
CEC Log message: GetPhysicalAddress - trying to get the physical address via ADL
CEC Log message: GetPhysicalAddress - ADL returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address via nvidia driver
CEC Log message: GetPhysicalAddress - nvidia driver returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address via drm files
CEC Log message: GetPhysicalAddress - drm files returned physical address 0000
CEC Log message: GetPhysicalAddress - trying to get the physical address from the OS
CEC Log message: GetPhysicalAddress - OS returned physical address 0000
CEC Log message: setting HDMI port to 1 on device TV (0)
CEC Log message: Recorder 1 (1): physical address changed from ffff to 1000
CEC Log message: << Recorder 1 (1) -> broadcast (F): physical address 1000
CEC Log message: << 1f:84:10:00:01
CEC Log message: using persisted autonomous mode setting: 'enabled'
CEC Log message: using persisted CEC version setting: '1.4'
CEC Log message: using persisted logical address setting: 'Recorder 1'
CEC Log message: using persisted device type setting: 'recording device'
CEC Log message: >> 01:46
Got event 4 with data ({'initiator': 0, 'parameters': '', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 70},)
CEC Log message: << Recorder 1 (1) -> TV (0): OSD name 'python-cec'
CEC Log message: >> TV (0) -> Recorder 1 (1): give osd name (46)
CEC Log message: << 10:47:70:79:74:68:6f:6e:2d:63:65:63
CEC Log message: using persisted logical address mask setting: '206'
CEC Log message: using persisted physical address setting: '1000'
CEC Log message: CEC client registered: libCEC version = 4.0.4, client version = 4.0.4, firmware version = 9, firmware build date: Fri Nov 2 10:08:56 2018 +0000, logical address(es) = Recorder 1 (1) , base device: TV (0), HDMI port number: 1, physical address: 1.0.0.0, compiled on Linux-4.4.0-161-generic ... , features: P8_USB, DRM, P8_detect, randr, Exynos, AOCEC
CEC Log message: << Recorder 1 (1) -> TV (0): OSD name 'python-cec'
CEC Log message: << 10:47:70:79:74:68:6f:6e:2d:63:65:63
CEC Log message: << requesting power status of 'TV' (0)
CEC Log message: << 10:8f
CEC Log message: RECEIVE_FAILED
CEC Log message: >> 01:90:00Creating Device object for TV
Got event 4<function cb at 0x7f61ce15e2d0>
with data ({'initiator': 0, 'parameters': '\x00', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 144},)
CEC Log message: TV (0): power status changed from 'unknown' to 'on'
CEC Log message: expected response received (90: report power status)
CEC Log message: >> TV (0) -> Recorder 1 (1): report power status (90)
<function log_cb at 0x7f61ce15e250>
CEC Log message: >> 01:46
Got event 4 with data ({'initiator': 0, 'parameters': '', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 70},)
CEC Log message: << Recorder 1 (1) -> TV (0): OSD name 'python-cec'
CEC Log message: << 10:47:70:79:74:68:6f:6e:2d:63:65:63
CEC Log message: >> TV (0) -> Recorder 1 (1): give osd name (46)
CEC Log message: >> 0e
CEC Log message: << POLL: TV (0) -> Free use (e)
CEC Log message: >> 0e
CEC Log message: << POLL: TV (0) -> Free use (e)
CEC Log message: >> 0f:80:30:00:30:00
Got event 4 with data ({'initiator': 0, 'parameters': '0\x000\x00', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 128},)
CEC Log message: >> TV (0) -> Broadcast (F): routing change (80)
CEC Log message: >> 0f:86:30:00
Got event 4 with data ({'initiator': 0, 'parameters': '0\x00', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 134},)
CEC Log message: >> TV (0) sets stream path to physical address 3000
CEC Log message: >> TV (0) -> Broadcast (F): set stream path (86)
CEC Log message: >> 01
CEC Log message: << POLL: TV (0) -> Recorder 1 (1)
CEC Log message: >> 0f:80:10:00:10:00
Got event 4 with data ({'initiator': 0, 'parameters': '\x10\x00\x10\x00', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 128},)
CEC Log message: making Recorder 1 (1) the active source
CEC Log message: marking the adapter as active source
CEC Log message: >> TV (0) -> Broadcast (F): routing change (80)
CEC Log message: >> source activated: Recorder 1 (1)
Got event 64 with data (True, 1)
CEC Log message: sending active source message for 'Recorder 1'
CEC Log message: << requesting vendor ID of 'TV' (0)
CEC Log message: 'give device vendor id' is marked as unsupported feature for device 'TV'
CEC Log message: << powering on 'TV' (0)
CEC Log message: << 10:04
CEC Log message: << Recorder 1 (1) -> broadcast (F): active source (1000)
CEC Log message: << 1f:82:10:00
CEC Log message: << Recorder 1 (1) -> TV (0): menu state 'activated'
CEC Log message: << 10:8e:00
CEC Log message: >> 0f:86:10:00
Got event 4 with data ({'initiator': 0, 'parameters': '\x10\x00', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 134},)
CEC Log message: >> TV (0) sets stream path to physical address 1000
CEC Log message: Recorder 1 (1) was already marked as active source
CEC Log message: >> source activated: Recorder 1 (1)
Got event 64 with data (True, 1)
CEC Log message: << Recorder 1 (1) -> broadcast (F): active source (1000)
CEC Log message: << 1f:82:10:00
CEC Log message: >> TV (0) -> Broadcast (F): set stream path (86)
CEC Log message: >> 01:46
Got event 4 with data ({'initiator': 0, 'parameters': '', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 70},)
CEC Log message: << Recorder 1 (1) -> TV (0): OSD name 'python-cec'
CEC Log message: << 10:47:70:79:74:68:6f:6e:2d:63:65:63
CEC Log message: >> TV (0) -> Recorder 1 (1): give osd name (46)
CEC Log message: >> 01:8d:02
Got event 4 with data ({'initiator': 0, 'parameters': '\x02', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 141},)
CEC Log message: << Recorder 1 (1) -> TV (0): menu state 'activated'
CEC Log message: << 10:8e:00
CEC Log message: >> TV (0) -> Recorder 1 (1): menu request (8D)
CEC Log message: >> 01:46
Got event 4 with data ({'initiator': 0, 'parameters': '', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 70},)
CEC Log message: << Recorder 1 (1) -> TV (0): OSD name 'python-cec'
CEC Log message: << 10:47:70:79:74:68:6f:6e:2d:63:65:63
CEC Log message: >> TV (0) -> Recorder 1 (1): give osd name (46)
CEC Log message: >> 01:8d:02
Got event 4 with data ({'initiator': 0, 'parameters': '\x02', 'ack': False, 'opcode_set': True, 'destination': 1, 'eom': True, 'transmit_timeout': 1000, 'opcode': 141},)
CEC Log message: << Recorder 1 (1) -> TV (0): menu state 'activated'
CEC Log message: << 10:8e:00
CEC Log message: >> TV (0) -> Recorder 1 (1): menu request (8D)
CEC Log message: >> 03
CEC Log message: << POLL: TV (0) -> Tuner 1 (3)
CEC Log message: >> 03
CEC Log message: << POLL: TV (0) -> Tuner 1 (3)
CEC Log message: >> 04
CEC Log message: << POLL: TV (0) -> Playback 1 (4)
^CTraceback (most recent call last):
File "/home/user/Documents/Python works/event-test.py", line 42, in <module>
while True:
KeyboardInterrupt
It should stop as soon as it sees the request change but it doesn't. arrrrggg
last update I tried a few different things after someone suggested print(message)so I tried this but I think the 0f:86:30:00 needs to be written in different format and have no idea how to to do that.
def log_cb(event, level, time, message):
print("CEC Log message:", message)
print(message)
if '0f:86:30:00' in message:
exit()
log message snipped with few lines ether side of the event :
CEC Log message: << POLL: TV (0) -> Recorder 2 (2)
CEC Log message: >> 0f:80:30:00:30:00
Got event 4 with data ({'initiator': 0, 'parameters': '0\x000\x00', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 128},)
CEC Log message: >> TV (0) -> Broadcast (F): routing change (80)
CEC Log message: >> 0f:86:30:00
Got event 4 with data ({'initiator': 0, 'parameters': '0\x00', 'ack': True, 'opcode_set': True, 'destination': 15, 'eom': True, 'transmit_timeout': 1000, 'opcode': 134},)
CEC Log message: >> TV (0) sets stream path to physical address 3000

log_cb is a callback you provide to the cec module with cec.add_callback(log_cb, cec.EVENT_LOG). This is clearly a logging handler that cec calls automatically on certain events; it's not something that makes sense for you to call yourself. This handler seems working since you've shown the output from its print statement.
message contains the substring you're interested in, so move your substring check into log_cb and get rid of the while True: block which will (probably) freeze your program (I'm not familiar with the cec library, but it seems like the wrong way to keep the program alive to poll for events and I don't see it mentioned in the docs):
def log_cb(event, level, time, message):
print("CEC Log message:", message)
if "routing change (80)" in message:
print("routing change (80) was in the message")
Note that the line if "routing change (80)" in '$log_cb': is nonsensical because it's always false. '$log_cb' is a string literal, not a variable holding a value like you may think.
In your updated code:
if (message == "routing change(80)"):
There are two problems:
The real substring in the log you posted is "routing change (80)", not "routing change(80)" (the space matters).
message == "routing change (80)" is not the correct logic and will likely never be true based on the log you showed. "routing change (80)" in message is the correct logic because it checks whether the desired string is a substring of message rather than an exact match.

Your code is checking if "routing change(80)" is a substring of the string "$log_cb". If you are intending to run the function log_cb, you need to call it using log_cb():
while True:
if "routing change(80)" in log_cb():
print("it worked ")
You will need to pass arguments for event, level, time and message, otherwise you will get a TypeError
Hope this helps!

Related

Unable to connect socket.io server | iOS client

I'm not able to connect the ios client app to the server.
Android is working fine.
Following socket client version i'm using.
We tried the following links:
https://socket.io/docs/v4/troubleshooting-connection-issues/
https://github.com/socketio/socket.io/issues/3794
Socket Server Version(node):
"socket.io": "^4.5.2"
iOS: Socket Client Version
pod 'Socket.IO-Client-Swift','16.0.0'
Android: Socket Client Version
'io.socket:socket.io-client:2.0.1'
Here is the error log.
2022-11-09 15:36:13.806244+0530 Chat[11058:250537] LOG SocketManager: Manager is being released
2022-11-09 15:36:13.809821+0530 Chat[11058:250537] LOG SocketIOClient{/}: Handling event: statusChange with data: [connecting, 2]
2022-11-09 15:36:13.810822+0530 Chat[11058:250537] LOG SocketIOClient{/}: Joining namespace /
2022-11-09 15:36:13.811809+0530 Chat[11058:250537] LOG SocketManager: Tried connecting socket when engine isn't open. Connecting
2022-11-09 15:36:13.812649+0530 Chat[11058:250537] LOG SocketManager: Adding engine
2022-11-09 15:36:13.816521+0530 Chat[11058:250965] LOG SocketEngine: Starting engine. Server: https://socketserver.com/
2022-11-09 15:36:13.817360+0530 Chat[11058:250965] LOG SocketEngine: Handshaking
2022-11-09 15:36:13.891828+0530 Chat[11058:250537] [UICollectionViewRecursion] cv == 0x7fc7f28afe00 Disabling recursion trigger logging
2022-11-09 15:36:14.011073+0530 Chat[11058:250979] [boringssl] boringssl_metrics_log_metric_block_invoke(144) Failed to log metrics
2022-11-09 15:36:14.031883+0530 Chat[11058:250936] LOG SocketEngine: Got message: 0{"sid":"MZvaOLNP7rHRyHPmAACE","upgrades":[],"pingInterval":25000,"pingTimeout":20000,"maxPayload":1000000}
2022-11-09 15:36:14.066076+0530 Chat[11058:250537] LOG SocketIOClient{/}: Handling event: websocketUpgrade with data: [["Connection": "upgrade", "Sec-WebSocket-Accept": "7Pq2JXa4nY+2HM4/iTfQnlr36zI=", "Server": "nginx/1.20.1", "Upgrade": "websocket", "Date": "Wed, 09 Nov 2022 10:06:14 GMT"]]
SocketAnyEvent: Event: websocketUpgrade items: Optional([["Connection": "upgrade", "Sec-WebSocket-Accept": "7Pq2JXa4nY+2HM4/iTfQnlr36zI=", "Server": "nginx/1.20.1", "Upgrade": "websocket", "Date": "Wed, 09 Nov 2022 10:06:14 GMT"]])
2022-11-09 15:36:14.068315+0530 Chat[11058:250537] LOG SocketManager: Engine opened Connect
2022-11-09 15:36:14.069540+0530 Chat[11058:250936] LOG SocketEngine: Writing ws: 0/, has data: false
2022-11-09 15:36:14.070357+0530 Chat[11058:250936] LOG SocketEngineWebSocket: Sending ws: 0/, as type: 4
2022-11-09 15:36:14.092916+0530 Chat[11058:250936] LOG SocketEngine: Got message: 44{"message":"invalid"}
2022-11-09 15:36:14.094201+0530 Chat[11058:250537] LOG SocketParser: Parsing 4{"message":"invalid"}
2022-11-09 15:36:14.098295+0530 Chat[11058:250537] LOG SocketParser: Decoded packet as: SocketPacket {type: 4; data: [{
message = invalid;
}]; id: -1; placeholders: -1; nsp: /}
2022-11-09 15:36:14.099612+0530 Chat[11058:250537] LOG SocketIOClient{/}: Handling event: error with data: [{
message = invalid;
}]
SocketAnyEvent: Event: error items: Optional([{
message = invalid;
}])
2022-11-09 15:36:39.094504+0530 Chat[11058:250935] LOG SocketEngine: Got message: 2
2022-11-09 15:36:39.094918+0530 Chat[11058:250935] LOG SocketEngine: Writing ws: has data: false
2022-11-09 15:36:39.094992+0530 Chat[11058:250537] LOG SocketIOClient{/}: Handling event: ping with data: []
SocketAnyEvent: Event: ping items: Optional([])
2022-11-09 15:36:39.095224+0530 Chat[11058:250935] LOG SocketEngineWebSocket: Sending ws: as type: 3

ngx-socket-io connected false but flask_socketio logs show 200 OK

Any tips to debug would help, this is just the basic implementation.
I am using the exact tutorial as here to setup the ngx socket client:
https://www.npmjs.com/package/ngx-socket-io
flask-socketio for the server
https://flask-socketio.readthedocs.io/en/latest/
Server-side shows no error, but the registered handler methods to emit/receive seem blind.
Server Logs:
127.0.0.1 - - [28/Jan/2021 10:58:51] "GET /socket.io/?EIO=3&transport=polling&t=NT8Dtbg HTTP/1.1" 200 418 0.000640
(12285) accepted ('127.0.0.1', 37400)
fa1a1d40bbc349c384a121302ef567c7: Received request to upgrade to websocket
127.0.0.1 - - [28/Jan/2021 10:58:51] "GET /socket.io/?EIO=3&transport=polling&t=NT8Dtcd&sid=fa1a1d40bbc349c384a121302ef567c7 HTTP/1.1" 200 235 0.000408
127.0.0.1 - - [28/Jan/2021 10:58:51] "GET /socket.io/?EIO=3&transport=polling&t=NT8DtdE&sid=fa1a1d40bbc349c384a121302ef567c7 HTTP/1.1" 200 235 0.000268
fa1a1d40bbc349c384a121302ef567c7: Upgrade to websocket successful
5002732d42184ba6b453e7d4f35e864e: Received packet PING data None
5002732d42184ba6b453e7d4f35e864e: Sending packet PONG data None
Client logs:
config: {url: "http://127.0.0.1:5000/", options: {…}}
emptyConfig: {url: "", options: {…}}
eventObservables$: {}
ioSocket: Socket
acks: {}
connected: false
disconnected: true
flags: {}
ids: 0
io: Manager
autoConnect: true
backoff: Backoff {ms: 1000, max: 5000, factor: 2, jitter: 0.5, attempts: 0}
connecting: [Socket]
decoder: Decoder {reconstructor: null, _callbacks: {…}}
encoder: Encoder {}
encoding: false
engine: Socket {secure: false, agent: false, hostname: "127.0.0.1", port: "5000", query: {…}, …}
lastPing: Thu Jan 28 2021 11:00:56
Server code (no print)
#socketio.on('connect')
def test_connect():
print('\n\nClient connected')
Why can't I get the connection working? Thanks
Double check npm/python environment of current versions of socketio and engineio.
https://github.com/miguelgrinberg/python-socketio
d7e95928d73c42fab431e94ce2df40fc: Sending packet OPEN data {'sid': 'd7e95928d73c42fab431e94ce2df40fc', 'upgrades': ['websocket'], 'pingTimeout': 60000, 'pingInterval': 25000}
Client connected
d7e95928d73c42fab431e94ce2df40fc: Sending packet MESSAGE data 0

Node rdkafka consumer stops fetching messages

Consumer stops fetching after getting following error
{ Error: Local: Broker transport failure at Error (native) origin: 'local', message: 'broker transport failure', code: -1, errno: -1, stack: 'Error: Local: Broker transport failure\n at Error (native)' }
All kafka servers are healthy even then I am getting the transport failure .
After this error consumers stops fetching further messages

Cant connect to scassandra (stubbed cassandra) using datastax-driver

I have troubles connecting to cassandra.
Im trying to connect to s-cassandra (which is a stubbed cassandra as can be reviewed here), with a datastax node.js cassandra driver.
For some reason passing "127.0.0.1:8042" as a contact point to the driver
results in a DriverInternalError:( tough sometimes it does work randomly and I havent still figured out why sometimes it does and sometime i doesnt..)
The DriverInternalError I get:
{"name": "DriverInternalError",
"stack": "...",
"message": "Local datacenter could not be
determined",
"info": "Represents a bug inside the driver or in a
Cassandra host." }
That is what I see from Cassandra Driver's log:
log event: info -- Adding host 127.0.0.1:8042
log event: info -- Getting first connection
log event: info -- Connecting to 127.0.0.1:8042
log event: verbose -- Socket connected to 127.0.0.1:8042
log event: info -- Trying to use protocol version 4
log event: verbose -- Sending stream #0
log event: verbose -- Sent stream #0 to 127.0.0.1:8042
{"name":"application-storage","hostname":"Yuris-MacBook-Pro.local","pid":1338,"level":30,"msg":"Kafka producer is initialized","time":"2016-08-05T12:53:53.124Z","v":0}
log event: verbose -- Received frame #0 from 127.0.0.1:8042
log event: info -- Protocol v4 not supported, using v2
log event: verbose -- Done receiving frame #0
log event: verbose -- disconnecting
log event: info -- Connection to 127.0.0.1:8042 closed
log event: info -- Connecting to 127.0.0.1:8042
log event: verbose -- Socket connected to 127.0.0.1:8042
log event: info -- Trying to use protocol version 2
log event: verbose -- Sending stream #0
log event: verbose -- Sent stream #0 to 127.0.0.1:8042
log event: verbose -- Received frame #0 from 127.0.0.1:8042
log event: info -- Connection to 127.0.0.1:8042 opened successfully
log event: info -- Connection pool to host 127.0.0.1:8042 created with 1 connection(s)
log event: info -- Control connection using protocol version 2
log event: info -- Connection acquired to 127.0.0.1:8042, refreshing nodes list
log event: info -- Refreshing local and peers info
log event: verbose -- Sending stream #1
log event: verbose -- Done receiving frame #0
log event: verbose -- Sent stream #1 to 127.0.0.1:8042
log event: verbose -- Received frame #1 from 127.0.0.1:8042
log event: warning -- No local info provided
log event: verbose -- Sending stream #0
log event: verbose -- Done receiving frame #1
log event: verbose -- Sent stream #0 to 127.0.0.1:8042
log event: verbose -- Received frame #0 from 127.0.0.1:8042
log event: info -- Peers info retrieved
log event: error -- Tokenizer could not be determined
log event: info -- Retrieving keyspaces metadata
log event: verbose -- Sending stream #1
log event: verbose -- Done receiving frame #0
log event: verbose -- Sent stream #1 to 127.0.0.1:8042
log event: verbose -- Received frame #1 from 127.0.0.1:8042
log event: verbose -- Sending stream #0
log event: verbose -- Done receiving frame #1
log event: verbose -- Sent stream #0 to 127.0.0.1:8042
log event: verbose -- Received frame #0 from 127.0.0.1:8042
log event: info -- ControlConnection connected to 127.0.0.1:8042 and is up to date
Ive tried playing with the firewall and open application but help is not there.. tough sometimes it does work randomly and I havent still figured out why..
I have a mac OS X El Capitan
The Solution that helped me:
I needed to prime the system.local table as a prime-query-single
{
query: 'prime-query-single',
header: {'Content-Type': 'application/json'},
body: {
"when": {
"query": "SELECT * FROM system.local WHERE key='local'"
},
"then": {
"rows": [
{
"cluster_name": "custom cluster name",
"partitioner": "org.apache.cassandra.dht.Murmur3Partitioner",
"data_center": "dc1",
"rack": "rc1",
"tokens": [
"1743244960790844724"
],
"release_version": "2.0.1"
}
],
"result": "success",
"column_types": {
"tokens": "set<text>"
}
}
}
}

tshark SIP protocol display collapse

I'm using tshark protocol filter as I need to parse the contents of the SIP Packets.
tshark -r df32c2248fe646a6793ce9a63b124b34#0.0.0.0.pcap -O sip
I get this:
Frame 14: 553 bytes on wire (4424 bits), 553 bytes captured (4424 bits)
Linux cooked capture
Internet Protocol Version 4, Src: 4.4.4.4 (4.4.4.4), Dst: 3.3.3.3 (3.3.3.3)
User Datagram Protocol, Src Port: 5060 (5060), Dst Port: 5060 (5060)
Session Initiation Protocol (200)
Status-Line: SIP/2.0 200 OK
Status-Code: 200
[Resent Packet: False]
[Request Frame: 11]
[Response Time (ms): 115]
[Release Time (ms): 115]
Message Header
Via: SIP/2.0/UDP 2.2.2.2:5060;received=3.3.3.3;branch=z9hG4bK18f6609d-1c76-4a8b-a96b-2cf7d8036d36_6772d868_3067109296759172
Transport: UDP
Sent-by Address: 2.2.2.2
Sent-by port: 5060
Received: 3.3.3.3
Branch: z9hG4bK18f6609d-1c76-4a8b-a96b-2cf7d8036d36_6772d868_3067109296759172
Contact: <sip:14082186500#1.1.1.1:17060>
Contact URI: sip:14082186500#1.1.1.1:17060
Contact URI User Part: 14082186500
Contact URI Host Part: 1.1.1.1
Contact URI Host Port: 17060
To: <sip:14082186500#spicyramen.ippbx.com;user=phone>;tag=83174026
SIP to address: sip:14082186500#spicyramen.ippbx.com;user=phone
SIP to address User Part: 14082186500
SIP to address Host Part: spicyramen.ippbx.com
SIP To URI parameter: user=phone
SIP to tag: 83174026
From: <sip:anonymous#sip.ie1.sipprovider.com>;tag=87638703_6772d868_18f6609d-1c76-4a8b-a96b-2cf7d8036d36
SIP from address: sip:anonymous#sip.ie1.sipprovider.com
SIP from address User Part: anonymous
SIP from address Host Part: sip.ie1.sipprovider.com
SIP from tag: 87638703_6772d868_18f6609d-1c76-4a8b-a96b-2cf7d8036d36
Call-ID: df32c2248fe646a6793ce9a63b124b34#0.0.0.0
CSeq: 44365 BYE
Sequence Number: 44365
Method: BYE
User-Agent: 3CXPhoneSystem 14.0.44198.522 (44097)
Content-Length: 0
As you can see output is not collapse. I want to see something like this:
Frame 14: 553 bytes on wire (4424 bits), 553 bytes captured (4424 bits)
Linux cooked capture
Internet Protocol Version 4, Src: 4.4.4.4 (4.4.4.4), Dst: 3.3.3.3 (3.3.3.3)
User Datagram Protocol, Src Port: 5060 (5060), Dst Port: 5060 (5060)
Session Initiation Protocol (200)
Status-Line: SIP/2.0 200 OK
Message Header
Via: SIP/2.0/UDP 2.2.2.2:5060;received=3.3.3.3;branch=z9hG4bK18f6609d-1c76-4a8b-a96b-2cf7d8036d36_6772d868_3067109296759172
Contact: <sip:14082186500#1.1.1.1:17060>
To: <sip:14082186500#spicyramen.ippbx.com;user=phone>;tag=83174026
From: <sip:anonymous#sip.ie1.sipprovider.com>;tag=87638703_6772d868_18f6609d-1c76-4a8b-a96b-2cf7d8036d36
Call-ID: df32c2248fe646a6793ce9a63b124b34#0.0.0.0
CSeq: 44365 BYE
User-Agent: 3CXPhoneSystem 14.0.44198.522 (44097)
Content-Length: 0
WiresharkYou can use Wireshark to do the job.
Apply a display filter:
sip
Go to the the Packet Details pane.
Expand "Session Initiation Protocol"
Expand Request-Line, Message Header and Message Body* (do not Expand Subtrees)
Go to File - Export - Export Packet Dissections... - As "Plain Text" File...
Packet Format section: select "Packet Summery Line" and "Packet Details: As Displayed"
Add a file name and save the file
*Note
I have used sample file: aaa.pcap
Message Body: see packet 223
TShark
You can use -T Fields and add all the fields you need.
For example:
tshark -r aaa.pcap -Y sip -E header=y -E separator="?" -T fields -e frame.number -e sip.Request-Line -e sip.r-uri -e sip.Via -e sip.From -e sip.To -e sip.Call-ID -e sip.Contact -e sip.Expires -e sip.CSeq -e sip.User-Agent -e sip.Content-Length > aaa.csv

Resources