From 5de6f5ad10acd5ff5d11dfa5c90ea52924cec6a2 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Fri, 25 Jan 2013 03:10:12 +0100 Subject: [PATCH] dom0/core: get timezone from /etc/localtime symlink Fedora 18 doesn't have /etc/sysconfig/clock. Instead have /etc/localtime symlinked to real timezone (instead of hardlinked like before), so now it is easy to get destination TZ name. --- dom0/qvm-core/qubes.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/dom0/qvm-core/qubes.py b/dom0/qvm-core/qubes.py index 3b9b1fb5..f6e0d5cf 100755 --- a/dom0/qvm-core/qubes.py +++ b/dom0/qvm-core/qubes.py @@ -831,14 +831,19 @@ class QubesVm(object): # FIXME: should be outside of QubesVM? def get_timezone(self): - clock_config = open('/etc/sysconfig/clock', "r") - clock_config_lines = clock_config.readlines() - clock_config.close() - zone_re = re.compile(r'^ZONE="(.*)"') - for line in clock_config_lines: - line_match = zone_re.match(line) - if line_match: - return line_match.group(1) + # fc18 + if os.path.islink('/etc/localtime'): + return '/'.join(os.readlink('/etc/localtime').split('/')[-2:]) + # <=fc17 + elif os.path.exists('/etc/sysconfig/clock'): + clock_config = open('/etc/sysconfig/clock', "r") + clock_config_lines = clock_config.readlines() + clock_config.close() + zone_re = re.compile(r'^ZONE="(.*)"') + for line in clock_config_lines: + line_match = zone_re.match(line) + if line_match: + return line_match.group(1) return None