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.
This commit is contained in:
Marek Marczykowski 2013-01-25 03:10:12 +01:00
parent 75fc222545
commit 5de6f5ad10

View File

@ -831,14 +831,19 @@ class QubesVm(object):
# FIXME: should be outside of QubesVM? # FIXME: should be outside of QubesVM?
def get_timezone(self): def get_timezone(self):
clock_config = open('/etc/sysconfig/clock', "r") # fc18
clock_config_lines = clock_config.readlines() if os.path.islink('/etc/localtime'):
clock_config.close() return '/'.join(os.readlink('/etc/localtime').split('/')[-2:])
zone_re = re.compile(r'^ZONE="(.*)"') # <=fc17
for line in clock_config_lines: elif os.path.exists('/etc/sysconfig/clock'):
line_match = zone_re.match(line) clock_config = open('/etc/sysconfig/clock', "r")
if line_match: clock_config_lines = clock_config.readlines()
return line_match.group(1) 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 return None