%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/timezone.pyc

�
���^c@@szdZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddl
ZddlZddlZddlZddlZddlmZmZeje�ZdZd�Zd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)dS(u5
Module for managing timezone on POSIX-like systems.
i(tabsolute_importtprint_functiontunicode_literalsN(tSaltInvocationErrortCommandExecutionErrorutimezonecC@s<tjjj�rtdfStjjj�r8tdfStS(u)
    Only work on POSIX-like systems
    u�The timezone execution module failed to load: win_timezone.py should replace this module on Windows.There was a problem loading win_timezone.py.u�The timezone execution module failed to load: mac_timezone.py should replace this module on macOS.There was a problem loading mac_timezone.py.(tsalttutilstplatformt
is_windowstFalset	is_darwint__virtualname__(((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyt__virtual__s


cC@sOtddgdt�}|ddkrKdj|d�}t|��n|S(u'
    get the output of timedatectl
    ucmd.run_allutimedatectltpython_shelluretcodeiutimedatectl failed: {0}ustderr(t__salt__R	tformatR(trettmsg((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyt_timedatectl.s
cC@s�d}tjjj|d��h}x^|D]V}tjjj|�}d|kr(|jd�jd�d}|jd�p}dSq(WWdQXt	d	|��dS(
Nu
/etc/TIMEZONEuruTZ=u
u=i����u'"uUTCuUnable to get timezone from (
RRtfilestfopentstringutilst
to_unicodetrstriptsplittstripR(ttzfiletfp_tlinetzonepart((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyt_get_zone_solaris;s
cC@skd}tjj|�r>ddd|g}td|dt�Stjjd�rctd|��nd	Sd	S(
uA
    Return the timezone in /etc/adjtime of the system clock
    u/etc/adjtimeutailu-nu1ucmd.runR
u/dev/rtcu$Unable to get hwclock timezone from N(tostpathtexistsRR	RtNone(tadjtime_filetcmd((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyt_get_adjtime_timezoneFscC@s�d}tjjj|d���}x�|D]z}tjjj|�}tjd|�r[q(nd|kr(d|kr(|jd�j	d�d}|j
d�p�d	Sq(WWdQXtd
|��dS(Nu/etc/sysconfig/clockuru^\s*#uZONEu=u
i����u'"uUTCuUnable to get timezone from (RRRRRRtretmatchRRRR(RRRR((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyt_get_zone_sysconfigWs
cC@s�t�}d}t|�}yEtjjtjjdtj|���}|j|�r_||SWnRtk
r�}|j	t	j
kr�dtdkr�t�St
|d��q�|j	t	jkr�dtdkr�t�Stj|d|d�tjdd	�}tjjj||�}x�tjjj|�D]z\}}}	xh|	D]`}
tjj||
�}||}|d
tjkr�qFn|tjjj||�krF|SqFWq0Wq�nXt
d��dS(Nu/usr/share/zoneinfo/u/etcuFreeBSDu	os_familyu does not existu- is not a symbolic link, attempting to match u to zoneinfo filesu	hash_typeumd5iuUnable to determine timezone(t_get_localtime_pathtlenRR tnormpathtjointreadlinkt
startswithtOSErrorterrnotENOENTt
__grains__tget_zonecodeRtEINVALtlogtwarningt__opts__tgetRRt	hashutilstget_hashtos_walktstringtascii_lowercase(Rttzdirt	tzdir_lent
olson_nametexct	hash_typettzfile_hashtroottdirsRtfilenamet	full_path((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyt_get_zone_etc_localtimeds<		!%

cC@sd}yDtjjj|d��&}tjjj|j��j�SWdQXWn.tk
rz}t	dj
||j���nXdS(Nu
/etc/timezoneuru&Problem reading timezone file {0}: {1}(RRRRRRtreadRtIOErrorRRtstrerror(RRRA((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyt_get_zone_etc_timezone�s)cC@s�d}tjjj|d��h}x^|D]V}tjjj|�}d|kr(|jd�jd�d}|jd�p}dSq(WWdQXt	d	|��dS(
Nu/etc/environmenturuTZ=u
u=i����u'"uUTCuUnable to get timezone from (
RRRRRRRRRR(RRRR((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyt
_get_zone_aix�s
cC@sZtjjjd�r�t�}x_d�tjjj|dd�D�D]7}ytjd|�j	d�SWqEt
k
r{qEXqEWdj|d�}t|��n�t
dj�d	kr�t�St
d
}x!dD]}||kr�t�Sq�Wx!dD]}||kr�t�Sq�W|dkr$t�Sd|kr7t�Sd|krJt�Std��dS(u,
    Get current timezone (i.e. America/Denver)

    .. versionchanged:: 2016.11.4

    .. note::

        On AIX operating systems, Posix values can also be returned
        'CST6CDT,M3.2.0/2:00:00,M11.1.0/2:00:00'

    CLI Example:

    .. code-block:: bash

        salt '*' timezone.get_zone
    utimedatectlcs@s|]}|j�VqdS(N(R(t.0tx((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pys	<genexpr>�sustdoutu
uTime ?zone:\s+(\S+)iuKFailed to parse timedatectl output: {0}
Please file an issue with SaltStackuosucentosu	os_familyuRedHatuSuseuDebianuGentoouFreeBSDuOpenBSDuNetBSDu	NILinuxRTuSolarisuAIXuUnable to get timezoneN(uRedHatuSuse(uDebianuGentoo(uFreeBSDuOpenBSDuNetBSDu	NILinuxRT(RRR twhichRt	itertoolsRR&R'tgrouptAttributeErrorRRR2tlowerRHR(RLRRM(RRRt	os_familytfamily((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pytget_zone�s4	-




cC@stdddgdt�S(u�
    Get current timezone (i.e. PST, MDT, etc)

    CLI Example:

    .. code-block:: bash

        salt '*' timezone.get_zonecode
    ucmd.runudateu+%ZR
(RR	(((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyR3�s
cC@sidtdkr*tdddgdt�Sd}tjj|�sOdj|�Std|dgdt�S(	u�
    Get current numeric timezone offset from UCT (i.e. -0700)

    CLI Example:

    .. code-block:: bash

        salt '*' timezone.get_offset
    uAIXu	os_familyucmd.runudateu+%zR
u/opt/salt/bin/dateu)date in salt binaries does not exist: {0}(R2RR	RR R!R(t	salt_path((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyt
get_offset�s

c
C@sitjjjd�rGytddj|��WqGtk
rCqGXndtdksgdtdkrydj|�}ndj|�}tjj	|�r�dtdkr�d	j|�St
�}tjj	|�r�tj|�ndtdkrtd
ddd
j|��ndtdkr�t�}d|g}td|dt
�}|dkr^tSd|g}td|dt
�t
Stj||�dtdkr�td
dddj|��n�dtdkr�td
dddj|��nsdtdksdtdkretjjjdd��6}|jtjjj|�j��|jd�WdQXntS(u{
    Unlinks, then symlinks /etc/localtime to the set timezone.

    The timezone is crucial to several system processes, each of which SHOULD
    be restarted (for instance, whatever you system uses as its cron and
    syslog daemons). This will not be automagically done and must be done
    manually!

    CLI Example:

    .. code-block:: bash

        salt '*' timezone.set_zone 'America/Denver'

    .. versionchanged:: 2016.11.4

    .. note::

        On AIX operating systems, Posix values are also allowed, see below

    .. code-block:: bash

        salt '*' timezone.set_zone 'CST6CDT,M3.2.0/2:00:00,M11.1.0/2:00:00'

    utimedatectlucmd.runutimedatectl set-timezone {0}uSolarisu	os_familyuAIXu/usr/share/lib/zoneinfo/{0}u/usr/share/zoneinfo/{0}uZone does not exist: {0}ufile.sedu/etc/default/initu^TZ=.*uTZ={0}uchtzucmd.retcodeR
iuRedHatu/etc/sysconfig/clocku^ZONE=.*u
ZONE="{0}"uSuseu^TIMEZONE=.*uTIMEZONE="{0}"uDebianuGentoou
/etc/timezoneuwu
N(RRR RPRRRR2RR!R)tunlinkRWR	tTruetsymlinkRRtwriteRtto_strR(ttimezonetzonepathRtcurtzstringR$tresulttofh((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pytset_zone�sJ
 #
		 "cC@sdtdks dtdkr-|t�kSdtdkrbtjjt��sb|t�kSnt�}t|�}ytj||dt	�SWnmt
k
r}|j}||kr�tdj
|���n*||kr�tdj
||j���n�nXdS(	uf
    Compares the given timezone name with the system timezone name.
    Checks the hash sum between the given timezone, and the one set in
    /etc/localtime. Returns True if names and hash sums match, and False if not.
    Mostly useful for running state checks.

    .. versionchanged:: 2016.3.0

    .. note::

        On Solaris-link operating systems only a string comparison is done.

    .. versionchanged:: 2016.11.4

    .. note::

        On AIX operating systems only a string comparison is done.

    CLI Example:

    .. code-block:: bash

        salt '*' timezone.zone_compare 'America/Denver'
    uSolarisu	os_familyuAIXuFreeBSDtshallowu!Can't find a local timezone "{0}"u5Failed to read {0} to determine current timezone: {1}N(R2RWRR tisfileR)t_get_zone_filetfilecmptcmpR	R/RFRRRRK(R_RR`RAtproblematic_file((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pytzone_compare@s& 
		cC@s(dtdkr$dtdkr$dSdS(Nu	NILinuxRTu	os_familyunilrtulsb_distrib_idu/etc/natinst/share/localtimeu/etc/localtime(R2(((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyR)ps cC@s
dj|�S(Nu/usr/share/zoneinfo/{0}(R(R_((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyRgvsc	
C@sjtjjjd�r�t�}x|d�|dj�D�D]`}d|j�kr9y1|jd�dj�j�dkr}dSd	SWq�t	k
r�q�Xq9q9Wd
j
|d�}t|��n�td}x!d&D]}||kr�t
�Sq�Wdtdkr�y�tjjjdd���}x�|D]x}tjjj|�}tjd|�rUq"nd|kr"|jd�jd�dj�}|dkr�d	SdSq"q"WWdQXWntk
r�}nXt
�Sdtdkr�tjjd�s�d}y�tjjj|d���}x�|D]x}tjjj|�}|jd�r|jd�}|jd�djd�}|d	krt|S|dkr�dSqqWtdj
|���WdQXWq�tk
r�}tdj
||j���q�Xnt
�Sd tdkr�d!}ybtjjj|d��D}x6|D].}tjjj|�}|jd"�rd	SqWdSWdQXWq�tk
r�}|jtjkr�d	Stdj
||j���q�Xnd#tdkrfd$}ybtjjj|d��D}x6|D].}tjjj|�}|jd%�r�d	Sq�WdSWdQXWqftk
rb}|jtjkrDd	Stdj
||j���qfXndS('u�
    Get current hardware clock setting (UTC or localtime)

    CLI Example:

    .. code-block:: bash

        salt '*' timezone.get_hwclock
    utimedatectlcs@s|]}|j�VqdS(N(R(RNRO((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pys	<genexpr>�sustdouturtc in local tzu:i����uyesu	localtimeuUTCuKFailed to parse timedatectl output: {0}
Please file an issue with SaltStacku	os_familyuRedHatuSuseu	NILinuxRTuDebianu/etc/default/rcSuru^\s*#uUTC=u
u=NuGentoou/etc/adjtimeu/etc/conf.d/hwclockuclock=u'"ulocaluLOCALu%Correct offset value not found in {0}u$Problem reading offset file {0}: {1}uSolarisu/etc/rtc_configu
zone_info=GMTuAIXu/etc/environmentuTZ=UTC(uRedHatuSuseu	NILinuxRT(RRR RPRt
splitlinesRTRRt
IndexErrorRRR2R%RRRRR&R'RRJRR!R.RKR0R1(	RRRRURVRtis_utcRAtoffset_file((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pytget_hwclockzs�
	!%




"


cC@s�tjjjd�rPdd|dkr-dndg}td|dt�dkStd	}|d/kr�|j�dkr�td
��nt	St
�}dtd	kr%|j�d0kr�td��ndtdkr�td��ndd|j�dkrdn|g}td|dt�dkSdj|�}tjj
|�s^tdj|���ntjd�tj|d�dtd	kr�dd|dkr�dndg}td|dt�dkSdtd	kr�tddddj|��n�d td	kr&tddd!d"j|��n�d#td	kr|d$krYtdd%d&d'�q�|dkr�tdd%d&d(�q�n`d)td	kr�|d1kr�td*��n|dkr�d+}ntdd,d-d.j|��nt	S(2u�
    Sets the hardware clock to be either UTC or localtime

    CLI Example:

    .. code-block:: bash

        salt '*' timezone.set_hwclock UTC
    utimedatectlu
set-local-rtcu	localtimeutrueufalseucmd.retcodeR
iu	os_familyuAIXu	NILinuxRTuutcuUTC is the only permitted valueuSolarisu/localtime and UTC are the only permitted valuesusparcucpuarchu-UTC is the only choice for SPARC architectureurtcu-zuGMTu/usr/share/zoneinfo/{0}uZone '{0}' does not existu/etc/localtimeuArchutimezonectluRedHatufile.sedu/etc/sysconfig/clocku^ZONE=.*u
ZONE="{0}"uSuseu^TIMEZONE=.*uTIMEZONE="{0}"uDebianuUTCu/etc/default/rcSu^UTC=.*uUTC=yesuUTC=nouGentoou&Only 'UTC' and 'localtime' are allowedulocalu/etc/conf.d/hwclocku	^clock=.*uclock="{0}"(uAIXu	NILinuxRT(u	localtimeuutc(uUTCu	localtime(RRR RPRR	R2RTRR[RWRRR!RRZR\(tclockR$RUR_R`((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pytset_hwclock�sd

	'
	(*t__doc__t
__future__RRRRhRR0tloggingR&R<tsalt.utils.filesRtsalt.utils.hashutilstsalt.utils.itertoolstsalt.utils.pathtsalt.utils.platformtsalt.utils.stringutilstsalt.exceptionsRRt	getLoggert__name__R5RRRRR%R(RHRLRMRWR3RYRdRkR)RgRpRr(((s9/usr/lib/python2.7/site-packages/salt/modules/timezone.pyt<module>sB		
			
	&			1	
		L	0			q

Zerion Mini Shell 1.0