Ticket #1266: 0001-shr_ntp-check-etc-default-rcS-for-UTC-value-and-set-.patch

File 0001-shr_ntp-check-etc-default-rcS-for-UTC-value-and-set-.patch, 2.0 KB (added by Heinervdm, 7 years ago)
  • shr_settings_modules/shr_ntp.py

    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: 
    1717class NTP(module.AbstractModule):
    1818    name = _("NTP settings")
    1919    ntpconf = "/etc/ntp.conf"
     20    rcsconf = "/etc/default/rcS"
    2021
    2122    def GetNTPServer(self):
    2223        server="unknown"
    class NTP(module.AbstractModule): 
    4445
    4546
    4647    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
    4765        self.SetNTPServer(self.NTPserver.entry_get())
    4866        #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")
    5071
    5172    def createButton(self):
    5273        self.bt = elementary.Button(self.window)