o
    Ìv›a2  ã                   @   sJ  d Z ddlZddlZddlZddlZdZdZdZzddlmZ	 W n e
y2   edƒ e d¡ Y nw dd	lmZ dd
lmZ ddlmZ z	e ejd¡ W n ejy\   edƒ Y nw ejdk sodej  krmdk rxn n	edƒ e d¡ dZedd„ e	 d¡D ƒƒZeek r“edƒ e d¡ dd„ Zdd„ Zdd„ Zdd„ ZdS )zInit the Glances software.é    Nz3.2.4.2z'Nicolas Hennion <nicolas@nicolargo.com>ZLGPLv3)Ú__version__z/psutil library not found. Glances cannot start.é   )Úlogger)ÚGlancesMain)ÚCounterÚ z8Warning: Unable to set locale. Expect encoding problems.)é   é   )é   r   )r
   é   z3Glances requires at least Python 2.7 or 3.4 to run.)é   r
   r   c                 C   s   g | ]}t |ƒ‘qS © )Úint)Ú.0Znumr   r   ú2/usr/lib/python3/dist-packages/glances/__init__.pyÚ
<listcomp>=   s    r   Ú.z7psutil 5.3.0 or higher is needed. Glances cannot start.c                 C   s
   t ƒ  dS )zCallback for CTRL-C.N)Úend)ÚsignalÚframer   r   r   Ú__signal_handlerC   s   
r   c                   C   s8   zt  ¡  W n	 ty   Y nw t d¡ t d¡ dS )zStop Glances.z$Glances stopped (keypressed: CTRL-C)r   N)Úmoder   Ú	NameErrorr   ÚinfoÚsysÚexitr   r   r   r   r   H   s   ý
r   c                 C   sÎ   t ƒ }t ¡ rddlm} n+t ¡ r$t ¡ rddlm} nddl	m
} nt ¡ r/ddlm} n
t ¡ r9ddlm} t d |j¡¡ || |dat d	 | ¡ ¡¡ |jsX|jr]t ¡  nt ¡  t ¡  d
S )zStart Glances.r   )ÚGlancesStandalone)ÚGlancesClientBrowser)ÚGlancesClient)ÚGlancesServer)ÚGlancesWebServerzStart {} mode©ÚconfigÚargszGlances started in {} secondsN)r   ÚcoreZis_standaloneZglances.standaloner   Z	is_clientZis_client_browserZglances.client_browserr   Zglances.clientr   Z	is_serverZglances.serverr   Zis_webserverZglances.webserverr    r   r   ÚformatÚ__name__r   ÚdebugÚgetZstdout_issueZstdout_apidocZserve_issueZserve_foreverr   )r"   r#   Zstart_durationZGlancesModer   r   r   ÚstartW   s$   
r)   c                   C   s\   t   t jt¡ t d t¡¡ t d t ¡ t 	¡ t
jt¡¡ tƒ att ¡ t ¡ d dS )zdMain entry point for Glances.

    Select the mode (standalone, client or server)
    Run it...
    zStart Glances {}z!{} {} ({}) and psutil {} detectedr!   N)r   ÚSIGINTr   r   r   r%   r   ÚplatformZpython_implementationZpython_versionr   Ú
executableÚpsutil_versionr   r$   r)   Z
get_configZget_argsr   r   r   r   Úmain|   s   ür.   )Ú__doc__Úlocaler+   r   r   r   Ú
__author__Z__license__Zpsutilr-   ÚImportErrorÚprintr   Zglances.loggerr   Zglances.mainr   Zglances.timerr   Ú	setlocaleÚLC_ALLÚErrorÚversion_infoZpsutil_min_versionÚtupleÚsplitZpsutil_version_infor   r   r)   r.   r   r   r   r   Ú<module>   sD   þÿ$

%