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:
parent
75fc222545
commit
5de6f5ad10
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user