o ¯b« ã@s@dZdgZddlmZddlmZmZmZmZGdd„dƒZ dS)zƒ Integration with systemd. Currently only the minimum APIs necessary for using systemd's socket activation feature are supported. Ú ListenFDsé)Úgetpid)ÚIterableÚListÚMappingÚOptionalc@sleZdZdZdZdeeddfdd„Ze  dde e e e fd e eddfd d „ƒZ de efd d „ZdS)raM L{ListenFDs} provides access to file descriptors inherited from systemd. Typically L{ListenFDs.fromEnvironment} should be used to construct a new instance of L{ListenFDs}. @cvar _START: File descriptors inherited from systemd are always consecutively numbered, with a fixed lowest "starting" descriptor. This gives the default starting descriptor. Since this must agree with the value systemd is using, it typically should not be overridden. @ivar _descriptors: A C{list} of C{int} giving the descriptors which were inherited. éÚ descriptorsÚreturnNcCs ||_dS)z @param descriptors: The descriptors which will be returned from calls to C{inheritedDescriptors}. N)Ú _descriptors)Úselfr ©r ú8/usr/lib/python3/dist-packages/twisted/python/systemd.pyÚ__init__%s zListenFDs.__init__ÚenvironÚstartc Cs¶|dur ddlm}|}|dur|j}g}zt|dƒ}Wnttfy+Y||ƒSw|tƒkrWzt|dƒ}WnttfyGY||ƒSwtt|||ƒƒ}|d=|d=||ƒS)a¶ @param environ: A dictionary-like object to inspect to discover inherited descriptors. By default, L{None}, indicating that the real process environment should be inspected. The default is suitable for typical usage. @param start: An integer giving the lowest value of an inherited descriptor systemd will give us. By default, L{None}, indicating the known correct (that is, in agreement with systemd) value will be used. The default is suitable for typical usage. @return: A new instance of C{cls} which can be used to look up the descriptors which have been inherited. Nr)rÚ LISTEN_PIDÚ LISTEN_FDS) ÚosrÚ_STARTÚintÚKeyErrorÚ ValueErrorrÚlistÚrange)ÚclsrrÚ_environr ÚpidÚcountr r rÚfromEnvironment,s,  ô ú zListenFDs.fromEnvironmentcCs t|jƒS)z6 @return: The configured descriptors. )rr )r r r rÚinheritedDescriptorsYs zListenFDs.inheritedDescriptors)NN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrÚ classmethodrrÚstrrrr r r r rrsýþý ü,N) r$Ú__all__rrÚtypingrrrrrr r r rÚs