From 130148ade851550a2c1dc418e1d887843ec229be Mon Sep 17 00:00:00 2001
From: Thomas Zimmermann <zimmermann@vdm-design.de>
Date: Mon, 21 Feb 2011 21:19:16 +0100
Subject: [PATCH] shr_ntp: check /etc/default/rcS for UTC value and set hwclock to UTC if requeired
Signed-off-by: Thomas Zimmermann <zimmermann@vdm-design.de>
---
shr_settings_modules/shr_ntp.py | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/shr_settings_modules/shr_ntp.py b/shr_settings_modules/shr_ntp.py
index 6cb2f14..c8c66ce 100644
|
a
|
b
|
except IOError: |
| 17 | 17 | class NTP(module.AbstractModule): |
| 18 | 18 | name = _("NTP settings") |
| 19 | 19 | ntpconf = "/etc/ntp.conf" |
| | 20 | rcsconf = "/etc/default/rcS" |
| 20 | 21 | |
| 21 | 22 | def GetNTPServer(self): |
| 22 | 23 | server="unknown" |
| … |
… |
class NTP(module.AbstractModule): |
| 44 | 45 | |
| 45 | 46 | |
| 46 | 47 | def btClicked(self, obj, *args, **kwargs): |
| | 48 | utcmode=False |
| | 49 | try: |
| | 50 | rcsfile = open(self.rcsconf, "r") |
| | 51 | while True: |
| | 52 | line = rcsfile.readline() |
| | 53 | if line=="": #EOF |
| | 54 | break |
| | 55 | |
| | 56 | li = line.strip('\t\n').split('=') |
| | 57 | if li[0]=="UTC": |
| | 58 | if li[1]=="yes": |
| | 59 | utcmode=True |
| | 60 | break |
| | 61 | rcsfile.close() |
| | 62 | except: |
| | 63 | print "could not open "+self.ntpconf+" for reading" |
| | 64 | |
| 47 | 65 | self.SetNTPServer(self.NTPserver.entry_get()) |
| 48 | 66 | #os.system("ntpclient -s -h "+self.NTPserver.entry_get()+" && hwclock -w") |
| 49 | | os.system("ntpd -q -n -p "+self.NTPserver.entry_get()+" && hwclock -w") |
| | 67 | if utcmode==True: |
| | 68 | os.system("ntpd -q -n -p "+self.NTPserver.entry_get()+" && hwclock -uw") |
| | 69 | else |
| | 70 | os.system("ntpd -q -n -p "+self.NTPserver.entry_get()+" && hwclock -w") |
| 50 | 71 | |
| 51 | 72 | def createButton(self): |
| 52 | 73 | self.bt = elementary.Button(self.window) |