;ò
€/Ac           @   s;   d  k  Z  d  k Z d  k Z d  k Z d f  d „  ƒ  YZ d  S(   Ns   dateBackendc           B   s}   t  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s    t  |  _ t  |  _ |  i ƒ  d  S(   N(   s   Nones   selfs   ntpFiles	   ntpServers   readNtpConf(   s   self(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   __init__   s    		
c         C   s   t  i t  i  ƒ  ƒ } | Sd  S(   N(   s   times	   localtimes   times(   s   selfs   times(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   getDate    s    c         C   s¢   | \ }	 } } | \ } } } | d } d |	 | | f }
 t	 i
 |
 d ƒ } | i ƒ  } | i ƒ  d | | | f }
 t	 i
 |
 d ƒ } | i ƒ  } | i ƒ  d  S(   Ni   s   /bin/date -s %d/%d/%ds   rs   /bin/date -s %s:%s:%s(   s   sysDates   years   months   days   sysTimes   hours   mins   secs   paths   oss   popens   fds	   readliness   liness   close(   s   selfs   sysDates   sysTimes   hours   mins   liness   fds   months   secs   years   paths   day(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   writeDateConfig$   s    

c         C   s1   t  i d t  i ƒ d j o t  i d ƒ n d  S(   Ns   /sbin/hwclocki   s   /sbin/hwclock --systohc(   s   oss   accesss   F_OKs   system(   s   self(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   syncHardwareClock5   s    c         C   s  d } d } g  } |  i oöx—|  i D]Œ} y t i | ƒ } Wn t
 Sn Xt i | d ƒ }
 |
 d j om t i | ƒ } | d d d j o | d d j o | o | i d | d ƒ d } q²| i | ƒ q& t i | d ƒ } | d j o­ t i | ƒ } | d d d j o | d d j o | o_ | d d j o( | i | ƒ | i d	 | ƒ d } q¡| d d
 j o | i | ƒ q¡q²| i | ƒ q& | i | ƒ q& W| o | i d | d ƒ n t d d ƒ }	 x | D] } |	 i | ƒ qíW|	 i ƒ  n‡ t d d ƒ }	 |	 i ƒ  } |	 i ƒ  t d d ƒ }	 xE | D]= } | d  d j o |	 i d | d ƒ qM|	 i | ƒ qMW|	 i ƒ  | o. t d d ƒ }	 |	 i | d ƒ |	 i ƒ  n | o? t d d ƒ }	 x | D] } |	 i | d ƒ qêW|	 i ƒ  n d Sd  S(   Ni    s   servers   #s   server s   
i   s   restricts   defaults9   restrict %s mask 255.255.255.255 nomodify notrap noquery
s	   127.0.0.1s   /etc/ntp.confs   ws*   /usr/share/system-config-date/ntp.templates   ri   s   /etc/ntp/step-tickerss   /etc/ntp/ntpservers(   s   serverFounds   restrictFounds   ntpFileLists   selfs   ntpFiles   lines   sockets   gethostbynames
   timeServers   serverIPs   Nones   strings   finds   locations   splits   tokenss   appends   restricts   opens   fds   writes   closes	   readliness   liness   ntpServerLists   server(   s   selfs
   timeServers   ntpServerLists   tokenss   serverFounds   restrictFounds   liness   serverIPs   servers   fds   locations   ntpFileLists   lines   restrict(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   writeNtpConfig=   sr    

 .
.
 
 
 c         C   sO   |  i ƒ  d j o
 d } n d } d } | d d g } t i | ƒ } | Sd  S(   Ni   s&   /sbin/service ntpd restart > /dev/nulls$   /sbin/service ntpd start > /dev/nulls   /sbin/services   ntpds   restart(   s   selfs   isNtpRunnings   fullPaths   paths   argss   oss   systems   retval(   s   selfs   waits   argss   paths   fullPaths   retval(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   startNtpService–   s    
c         C   s   d } t i | ƒ d  S(   Ns"   /sbin/chkconfig --level 35 ntpd on(   s   paths   oss   system(   s   selfs   path(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   chkconfigOn¡   s    c         C   s   d } t i | ƒ d  S(   Ns#   /sbin/chkconfig --level 35 ntpd off(   s   paths   oss   system(   s   selfs   path(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   chkconfigOff¥   s    c         C   sA   |  i ƒ  d j o* d } t i | ƒ d } t i | ƒ n d  S(   Ni   s#   /sbin/service ntpd stop > /dev/nulls#   /sbin/chkconfig --level 35 ntpd off(   s   selfs   isNtpRunnings   paths   oss   system(   s   selfs   path(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   stopNtpService©   s
    c         C   sc   t  i d t  i ƒ o d Sn d } t  i | ƒ } y | d j o d Sn d SWn t Sn Xd  S(   Ns   /etc/ntp.confi    s%   /sbin/service ntpd status > /dev/nulli   (   s   oss   accesss   R_OKs   commands   systems   results   None(   s   selfs   commands   result(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   isNtpRunning°   s    c         C   sé   d } |  i oÕ xŸ |  i D]” } t i | d ƒ } | d j oo t i | ƒ } | d d d j o | d d j o | o. y | d |  _	 d } Wqª t
 |  _	 qª Xq® q q W|  i	 d j p |  i	 t
 j o t
 Sqå |  i	 Sn d  S(   Ni    s   servers   #i   s   127.127.1.0(   s   serverFounds   selfs   ntpFiles   lines   strings   finds   locations   splits   tokenss	   ntpServers   None(   s   selfs   serverFounds   tokenss   locations   line(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   getNtpServerÅ   s     

 .
 c         C   s>   y, t  d d ƒ } | i ƒ  |  _ | i ƒ  Wn d  Sn Xd  S(   Ns   /etc/ntp.confs   r(   s   opens   fds	   readliness   selfs   ntpFiles   close(   s   selfs   fd(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   readNtpConfÜ   s    c         C   s¢   g  |  _ t i d t i ƒ d j or t d d ƒ } | i ƒ  } xI | D]A } t
 i | ƒ } | o | d d j o |  i i | ƒ qG qG W|  i Sn d g Sd  S(   Ns   /etc/ntp/ntpserversi   s   ri    s   #s    (   s   selfs   ntpServerLists   oss   accesss   R_OKs   opens   fds	   readliness   liness   lines   strings   strips   append(   s   selfs   liness   fds   line(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   readServersFileä   s    	 (   s   __name__s
   __module__s   __init__s   getDates   writeDateConfigs   syncHardwareClocks   writeNtpConfigs   startNtpServices   chkconfigOns   chkconfigOffs   stopNtpServices   isNtpRunnings   getNtpServers   readNtpConfs   readServersFile(    (    (    s1   /data/usr-share/system-config-date/dateBackend.pys   dateBackend   s   					Y							(   s   oss   times   strings   sockets   dateBackend(   s   dateBackends   sockets   oss   strings   time(    (    s1   /data/usr-share/system-config-date/dateBackend.pys   ?   s   				