Closed revansSZ closed 3 years ago
I have the pull request placed, here is some added detail for handling of format of /etc/sysconfig/clock in centos 8.
file -s clock clock: symbolic link to /etc/localtime
Compare that to centos 6 which has: file -s clock clock: ASCII text
Hmm. Another case of a config file containing tz data instead of the timezone name. Maybe we need to handle that.
Hi Team,
Reporting an issue for pulling in localzone, is this known to the team on Centos 8?
timedatectl Local time: Mon 2020-09-28 11:14:33 AWST Universal time: Mon 2020-09-28 03:14:33 UTC RTC time: Mon 2020-09-28 03:14:33 Time zone: Australia/Perth (AWST, +0800) System clock synchronized: yes NTP service: active RTC in local TZ: no
File "/root/xxx/env/lib64/python3.6/site-packages/tzlocal/unix.py", line 165, in get_localzone _cache_tz = _get_localzone() File "/root/xxx/env/lib64/python3.6/site-packages/tzlocal/unix.py", line 110, in _get_localzone data = tzfile.readlines() File "/usr/lib64/python3.6/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 44: invalid start byte
Skipping the below code block did the trick for me in tzlocal/unix.py
for filename in ('etc/sysconfig/clock', 'etc/conf.d/clock'): tzpath = os.path.join(_root, filename) try: continue with open(tzpath, 'rt') as tzfile: data = tzfile.readlines()
Because there is an error decoding bytes in /etc/sysconfig/clock it dies. The exception is only looking for IOError and doesn't handle other error types, I added this.
I'll pull down the code in a bit and will submit a PR.