U
    TGh                     @   s   d Z dZdZddlZddlZddlmZ ddlmZ ddl	m
Z
mZ eeeeedf edd	d
ZedddZedddZdS )zCopyright 2021, 3LizzGPL version 3zinfo@3liz.org    N)Path)Union)QgisQgsMessageLog)valreturnc                 C   s"   t | tr|  dkS t| S dS )z( Convert lizmap config value to boolean )yestruet1N)
isinstancestrlowerbool)r    r   5/var/www/lizmap/lizmap/plugins/lizmap_server/tools.pyto_bool   s    
r   )r   c                  C   sb   t tjd} t }z|j| dd W n& tk
rP   t	ddt
j Y dS X |d d S d	S )
z% Returns the Lizmap current version. zmetadata.txtutf8)encodingzqError, an UnicodeDecodeError occurred while reading the metadata.txt. Is the locale correctly set on the server ?LizmapNULLgeneralversionN)r   __file__parentjoinpathconfigparserConfigParserreadUnicodeDecodeErrorr   
logMessager   Critical)Z	file_pathconfigr   r   r   r      s     r   c                   C   s*   t tjdds&tddtj dS dS )z! Check the server configuration. Z"QGIS_SERVER_LIZMAP_REVEAL_SETTINGS u   The Lizmap API is currently not enabled. Please read the documentation how to enable the Lizmap API on QGIS server side https://docs.lizmap.com/current/en/install/pre_requirements.html#lizmap-server-plugin An environment variable must be enabled to have Lizmap Web Client ≥ 3.5 working.r   FT)r   osenvirongetr   r    r   r!   r   r   r   r   check_environment_variable/   s    r'   )__copyright____license__	__email__r   r$   pathlibr   typingr   	qgis.corer   r   r   intfloatr   r   r   r'   r   r   r   r   <module>   s   	