
    b                         d dl mZ ddlmZmZmZmZmZm	Z	m
Z
mZmZmZmZmZ d ZddZed dfdZed dd fd	Zdd
ZddZddZddZddZdS )    )	AF_UNSPEC   )__version__bootednotify_listen_fds_listen_fds_with_names_is_fifo
_is_socket_is_socket_inet_is_socket_sockaddr_is_socket_unix_is_mqLISTEN_FDS_STARTc                 P    	 |                                  S # t          $ r | cY S w xY wN)filenoAttributeError)fileobjs    0/usr/lib/python3/dist-packages/systemd/daemon.py_convert_fileobjr      s;    ~~   s    %%Nc                 @    t          |           }t          ||          S r   )r   r
   r   pathfds      r   is_fifor      s    	'	"	"BB    c                 D    t          |           }t          ||||          S r   )r   r   )r   familytype	listeningr   s        r   	is_socketr#      s#    	'	"	"Bb&$	222r   c                 F    t          |           }t          |||||          S r   )r   r   )r   r    r!   r"   portr   s         r   is_socket_inetr&      s%    	'	"	"B2vtY===r   c                 F    t          |           }t          |||||          S )aa  Check socket type, address and/or port, flowinfo, listening state.

    Wraps sd_is_socket_inet_sockaddr(3).

    `address` is a systemd-style numerical IPv4 or IPv6 address as used in
    ListenStream=. A port may be included after a colon (":").
    See systemd.socket(5) for details.

    Constants for `family` are defined in the socket module.
    )r   r   )r   addressr!   flowinfor"   r   s         r   is_socket_sockaddrr*   "   s'     
'	"	"Br7D(IFFFr   c                 D    t          |           }t          ||||          S r   )r   r   )r   r!   r"   r   r   s        r   is_socket_unixr,   0   s#    	'	"	"B2tY555r   c                 @    t          |           }t          ||          S r   )r   r   r   s      r   is_mqr.   4   s    	'	"	"B"dr   Tc                 t    t          |           }t          t          t          t          |z                       S )aZ  Return a list of socket activated descriptors

    Example::

      (in primary window)
      $ systemd-socket-activate -l 2000 python3 -c \
          'from systemd.daemon import listen_fds; print(listen_fds())'
      (in another window)
      $ telnet localhost 2000
      (in primary window)
      ...
      Execing python3 (...)
      [3]
    )r   listranger   )unset_environmentnums     r   
listen_fdsr4   8   s1     '
(
(C&(83(>??@@@r   c                     t          |           }i }t          d|d                   D ]}|d|z            ||t          z   <   |S )a  Return a dictionary of socket activated descriptors as {fd: name}

    Example::

      (in primary window)
      $ systemd-socket-activate -l 2000 -l 4000 --fdname=2K:4K python3 -c \
          'from systemd.daemon import listen_fds_with_names; print(listen_fds_with_names())'
      (in another window)
      $ telnet localhost 2000
      (in primary window)
      ...
      Execing python3 (...)
      [3]
    r   r   )r	   r1   r   )r2   	compositeretvalis       r   listen_fds_with_namesr9   J   sT     ''899IF1il## 4 4%.qs^q!!""Mr   r   )r   r   r   )r   r   N)T)socketr   
_AF_UNSPEC_daemonr   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r#   r&   r*   r,   r.   r4   r9    r   r   <module>r>      sx   * * * * * *( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (      )qB 3 3 3 3 $.A! > > > >G G G G6 6 6 6   A A A A$     r   