Mini Shell
3
Z��e � @ s d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
ddlmZ ddl
mZmZ dd lmZ dd
lmZ ddlmZ ddlmZ ee�Zd
ddddddddddddddddddd d!d"d#d$d%d&d'd(gZd)Zd*Zd+d,� Zd9d-d.�Zd/d0� Zd1d2� Z d3d4� Z!d5d6� Z"d7d8� Z#dS ):z�
Module providing functions for getting the list of timezones, writing timezone
configuration, valid timezones recognition etc.
� N)�OrderedDict)�util)�THREAD_STORAGE)�flags)�
BOOTLOADER)�TIMEZONE�STORAGE)�is_module_available)� threadMgr)�arch)�get_module_loggerzGMT+1zGMT+2zGMT+3zGMT+4zGMT+5zGMT+6zGMT+7zGMT+8zGMT+9zGMT+10zGMT+11zGMT+12zGMT-1zGMT-2zGMT-3zGMT-4zGMT-5zGMT-6zGMT-7zGMT-8zGMT-9zGMT-10zGMT-11zGMT-12zGMT-13zGMT-14ZUTCZGMTZchronyZchronydc C sz t j� rdS | j rDtj rDtjt� tj t
�}|j� }| j|� d}dg}| jr`|j
d� n
|j
d� tj||� dS )z�
Try to guess if RTC uses UTC time or not, set timezone.isUtc properly and
set system time from RTC using the UTC guess.
Guess is done by searching for bootable ntfs devices.
:param timezone_proxy: DBus proxy of the timezone module
N�hwclockz --hctosysz--utcz--localtime)r �is_s390�IsUTCr ZautomatedInstallr
�waitr r � get_proxyr Z
DetectWindowsZSetIsUTC�appendr �execWithRedirect)�timezone_proxyZbootloader_proxyZis_utc�cmd�args� r � /usr/lib64/python3.6/timezone.py�time_initialize6 s
r c C sZ t j� rdS tt�sdS | s$tj� } d}dg}| jr@|jd� n
|jd� tj||� dS )zf
Save system time to HW clock.
:param timezone_proxy: DBus proxy of the timezone module
Nr
z --systohcz--utcz--local) r r r r r r r r r )r r r r r r �
save_hw_clockS s
r c C s t j| d�}|sdS |d S )aj
Get the preferred timezone for a given territory. Note that this function
simply returns the first timezone in the list of timezones for a given
territory.
:param territory: territory to get preferred timezone for
:type territory: str
:return: preferred timezone for the given territory or None if no found
:rtype: str or None
)ZterritoryIdNr )� langtableZlist_timezones)Z territoryZ timezonesr r r �get_preferred_timezonem s
r c C sn t � } xVtjD ]L}|jdd�}t|�dkr|d | krDt� | |d <