After I upgraded to python 3 am getting error cannot use a string pattern on a bytes-like object.
Below is my code, am getting error on the 2nd line as there is string and byte mismatch.
manually_resync_time = b'2020-09-07T03:28:55Z chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)\n2020-09-07T03:28:55Z Could not open IPv6 command socket : Address family not supported by protocol\n2020-09-07T03:28:55Z Frequency -9.450 +/- 0.094 ppm read from /var/lib/chrony/drift\n2020-09-07T03:29:28Z System clock wrong by 0.000071 seconds (step)\n2020-09-07T03:29:28Z chronyd exiting\n'
seconds = re.search( "([0-9]*.[0-9]*) seconds", manually_resync_time).group(0)
self.assertLess(0.01, seconds)
I have tried using struct unpack to convert manually_resync_time to float
struct.unpack('f', manually_resync_time)
and now its giving me
struct.error: unpack requires a buffer of 4 bytes
How can I resolve this.