§
    öÛgH  ã                   ó”  — d Z ddlZddlZddlZddlZddlZddlZddlmZm	Z	 ddl
mZ ddlmZmZmZ ddlmZ ddlmZ dd	lmZ d
„ Zd„ Zdd„Zdd„Z G d„ dej        ¦  «        Zefd„Zedk    rWej        dd…         r" eej        d         ¦  «        Z ee¦  «        Zn
 e¦   «         Zddl m!Z!  e" e!e¦  «        ¦  «         dS dS )z9
Collect and access PostgreSQL installation information.
é    N)ÚcycleÚchain)Ú
itemgetteré   )Úfind_executableÚ	close_fdsÚplatform_exe)Úversionstring)Úapi)Ústringc                 ó˜  — t          | ¦  «        d„ |D ¦   «         z   }t          j        |t          t          j        t          j        t          j        d¬¦  «        }|j                             ¦   «          |j                             ¦   «          	 	 |                     ¦   «         }n.# t          $ r }|j
        t          j        k    r‚ Y d }~nd }~ww xY wŒD|dk    rd S |j        5  t          j        |j        ¦  «        5 }|                     ¦   «         cd d d ¦  «         cd d d ¦  «         S # 1 swxY w Y   d d d ¦  «         d S # 1 swxY w Y   d S )Nc                 ó@   — g | ]}|®d|                      ¦   «         z   ‘ŒS )Nú--)Ústrip)Ú.0Úxs     úM/granary/edev/quantum/lib/python3.11/site-packages/postgresql/installation.pyú
<listcomp>z&get_command_output.<locals>.<listcomp>   s-   € ð ð ð Ø A M€$ˆ�Š‰ŒÑ M M Mó    F)r   ÚstdoutÚstderrÚstdinÚshellTr   )ÚlistÚ
subprocessÚPopenr   ÚPIPEr   Úcloser   ÚwaitÚOSErrorÚerrnoÚEINTRr   ÚioÚTextIOWrapperÚread)ÚexeÚargsÚpaÚpÚrvÚeÚtxts          r   Úget_command_outputr-      sõ  € Ý
ˆ3�i„ið ð Ø ðñ ô ñ €õ Ô�bÝÝŒ?ÝŒ?Ý
Œ/Ø
ðñ ô €ð „‡‚�„€Ø„‡‚ÑÔÐð
ð
Ø	�Š‰Œ€2ØøÝ	ð 
ð 
ð 
Ø„g•”ÒÐØ	ð ÐÐÐÐøøøøð
øøøð	
ð ˆ!‚G€GØ	ˆØ„hð ð •Ô  ¤Ñ*Ô*ð ¨cØ	�Š‰Œðð ð ð ñ ô ð ð ð ð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð ð ð ñ ô ð ð ð ð ð ð ð øøøð ð ð ð ð ð sN   ÂB# Â#
CÂ-CÃCÃ D?Ã:D'ÄD?Ä'D+	Ä+D?Ä.D+	Ä/D?Ä?EÅEc            	      óz  — t          | ¦  «        }|�Ÿi }|                     ¦   «         D ]†}|r-|                     ¦   «         s|                     d¦  «        dk    rŒ2|                     dd¦  «        \  }}|                     ¦   «         ||                     ¦   «                              ¦   «         <   Œ‡|S g }t          | d¦  «                             ¦   «         D ]T}|                     d¦  «        }|dk    rŒ|                     d|¦  «        }	|                     ||dz   |	…         ¦  «         ŒUd|v r|                     d¦  «         d	|v r|                     d	¦  «         t          t          |t          | g|¢R Ž                      ¦   «         ¦  «        ¦  «        }t          | d	¦  «                             ¦   «         |d	<   |S )
zÅ
	Create a dictionary of the information available in the given
	pg_config_path. This provides a one-shot solution to fetching information
	from the pg_config binary. Returns a dictionary object.
	Nú=éÿÿÿÿr   Úhelpr   ú é   Úversion)r-   Ú
splitlinesÚisspaceÚfindÚsplitr   ÚlowerÚappendÚremoveÚdictÚzip)
Úpg_config_pathÚdefault_outputÚdr   ÚkÚvÚoptÚlÚdash_posÚsp_poss
             r   Úpg_config_dictionaryrG   /   s³  € õ % ^Ñ4Ô4€ØÐØ€!Ø×$Ò$Ñ&Ô&ð $ð $€aØ
ð ˆq�yŠy‰{Œ{ð ˜aŸfšf S™kœk¨RÒ/Ð/ØØ
�'Š'�#�q‰/Œ/�4€1€aàŸ'š'™)œ)€1€Q‡W‚W�Y„Y‡_‚_ÑÔÑÐØ	
€(ð 
€Ý
˜^¨VÑ
4Ô
4×
?Ò
?Ñ
AÔ
Að #ð #€QØ�VŠV�D‰\Œ\€(Ø�‚^€^ØØ�6Š6�#�xÑ Ô €&à‡*‚*ˆQˆx˜‰z˜&Ð Ô!Ñ"Ô"Ð"Ð"Ø
ˆc€M€MØ‡*‚*ˆVÑÔÐØ�ÐÐØ‡*‚*ˆYÑÔÐå�ˆCÕ# NÐ9°SÐ9Ð9Ð9×DÒDÑFÔFÑGÔGÑHÔH€Ý" >°9Ñ=Ô=×CÒCÑEÔE€€9�Ø	€r   ú'"ú-'"c              #   óŠ  K  — | dd…         |v r| dd…         }n| dd …         |v r	| d         }nd}t          j        | |d¬¦  «        }|dz  }|D ]s}||v r|                     ||¦  «        }|                     |¦  «                             dd¦  «        d	gz   }|d                              d
d¦  «        }|r||d         fV — Œtd S )Nr   r   r0   ú'r2   )Úsepr3   r/   Tú-Ú_)Úpg_strÚsplit_usingÚreplacer   r8   )	ÚconfoptÚquotesÚdash_and_quotesÚquoteÚpartsÚqqr   ÚkvÚkeys	            r   Úparse_configure_optionsrZ   Y   s  è è € ð ˆAˆaˆC„L�FÐÐà
�!�A�#Œ,€%€%Øˆbˆcˆc„l�fÐÐà
�"Œ+€%€%ð €%õ 
Ô	˜G U°#Ð	6Ñ	6Ô	6€Øˆa�i€Ø
ð ð €QØˆ1€W€Wà‡y‚y��UÑÔ€1ð
 	‡w‚wˆÑÔ×%Ò% c¨1Ñ-Ô-°°Ñ6€"Ø
ˆ1Œ�Š�c˜#ÑÔ€#àð Ø
ˆr�!ŒuˆÐÐÐøðð r   Ú	pg_configÚPGINSTALLATIONc                 ó€   — t           j                             |¦  «        }|rt          |¦  «        S t	          | ¦  «        S )z¦
	Get the default `pg_config` executable on the system.

	If 'PGINSTALLATION' is in the environment, use it.
	Otherwise, look through the system's PATH environment.
	)ÚosÚenvironÚgetr	   r   )ÚexecnameÚenvkeyr>   s      r   Údefault_pg_configrc   y   s;   € õ ”*—.’. Ñ(Ô(€Øð &å	�nÑ	%Ô	%Ð%Ý˜Ñ!Ô!Ð!r   c                   ón   — e Zd ZdZdZdZdZdZdZdZ	dZ
dZd„ Zdj        fd„Zd	efd
„Zed„ ¦   «         ZdS )ÚInstallationzN
	Class providing a Python interface to PostgreSQL installation information.
	N)r[   ÚpsqlÚinitdbÚpg_resetxlogÚpg_controldataÚ	clusterdbÚpg_ctlÚpg_dumpÚ
pg_dumpallÚpostgresÚ
postmasterÚ	reindexdbÚvacuumdbÚipccleanÚcreatedbÚecpgÚ
createuserÚ
createlangÚdroplangÚdropuserÚ
pg_restore)ÚlibpqÚlibecpgÚ
libpgtypesÚlibecpg_compat)ÚbindirÚdocdirÚ
includedirÚpkgincludedirÚincludedir_serverÚlibdirÚ	pkglibdirÚ	localedirÚmandirÚsharedirÚ
sysconfdirc              #   ó  K  — t          | j                             ¦   «         ¦  «        }|                     t	          d¦  «        ¬¦  «         d| j        fV — |r/dt          j                             d„ |D ¦   «         ¦  «        fV — d S d S )Nr   )rY   r4   Úconfigure_optionsc              3   ó8   K  — | ]\  }}|d u r|n|dz   |z   V — ŒdS )Tr/   N© )r   rA   rB   s      r   ú	<genexpr>z(Installation._e_metas.<locals>.<genexpr>Ä   sN   è è € ð ð á	ˆˆ1ð ˆtˆ)ˆ)€Q€Q˜˜S™ 1™ðð ð ð ð ð r   )	r   rŠ   ÚitemsÚsortr   r4   r^   ÚlinesepÚjoin)ÚselfrD   s     r   Ú_e_metaszInstallation._e_metas¾   s³   è è € Ý
ˆ4Ô!×'Ò'Ñ)Ô)Ñ*Ô*€!Ø‡&‚&�z˜!‰}Œ}€&ÑÔÐØ	�D”LÐ!Ð!Ð!Ð!Øð Ø
Ý„Z×Òð ð àðñ ô ñ ô ð
ð ð ð ð ð ðð r   z{mod}.{name}({info!r})c                 óp   —  |t          | ¦  «        j        t          | ¦  «        j        | j        ¬¦  «        S )N)ÚmodÚnameÚinfo)ÚtypeÚ
__module__Ú__name__r—   )r’   Úformats     r   Ú__repr__zInstallation.__repr__Ê   s8   € Ø	ˆÝ	ˆd‰ŒÔ	Ý
ˆt‰*Œ*Ô
Ø
Œ)ð
ñ 
ô 
ð r   r—   c                 óx  — || _         | j         d         | _        | j                             ¦   «         \  | _        }t	          j        t	          j        |¦  «        ¦  «        | _        t          t          | j          	                    dd¦  «        ¦  «        ¦  «        | _
        t          ¦   «         | _        t          j        j        }t          j        j        }| j        D ]$}| j          	                    |¦  «        | j        |<   Œ%| j          	                    d¦  «        }|€;| j                             t%          | j        t)          d¦  «        ¦  «        ¦  «         nC| j        D ];}t+           |||¦  «        ¦  «        } ||¦  «        r|| j        |<   Œ1d| j        |<   Œ<| j                             | j        ¦  «         dS )zI
		Initialize the Installation using the given information dictionary.
		r4   Ú	configureÚ r~   N)N)r—   r4   r8   r˜   r
   Ú	normalizeÚversion_infor<   rZ   r`   rŠ   Úpathsr^   ÚpathÚexistsr‘   Úpg_directoriesÚupdater=   Úpg_executablesr   r	   Ú__dict__)r’   r—   Úvsr¤   r‘   rA   Úbindir_pathr£   s           r   Ú__init__zInstallation.__init__Ñ   sƒ  € ð €$„)Ø”˜9Ô%€$„,Ø”,×$Ò$Ñ&Ô&�-€$„)ˆRÝ#Ô-­mÔ.AÀ"Ñ.EÔ.EÑFÔF€$ÔÝÝ˜4œ9Ÿ=š=¨°bÑ9Ô9Ñ:Ô:ñô €$Ôõ ‰vŒv€$„*åŒ7Œ>€&Ý	ŒŒ€$ØÔð $ð $€aØ”9—=’= Ñ#Ô#€4„:ˆa�=€=ð ”	—’˜hÑ'Ô'€+ØÐØ„:×Ò•S˜Ô,­e°G©n¬nÑ=Ô=Ñ>Ô>Ð>Ð>àÔð ð €qÝ˜˜˜[¨!Ñ,Ô,Ñ-Ô-€DØ€vˆd�|„|ð Ø€T„Z��]€]à€T„Z��]€]Ø„-×Ò�t”zÑ"Ô"Ð"Ð"Ð"r   c                 ó   — d| j         v S )z=
		Whether the installation was compiled with SSL support.
		Úwith_openssl)rŠ   )r’   s    r   ÚsslzInstallation.sslñ   s   € ð
 
˜4Ô1Ð	1Ð1r   )rš   r™   Ú__qualname__Ú__doc__r4   r¡   r˜   rŠ   r—   r§   Úpg_librariesr¥   r“   r›   rœ   r<   r«   Úpropertyr®   rŒ   r   r   re   re   †   s±   € € € € € ðð ð €Ø€Ø€ØÐà€ð€ð0€ð€ð
ð 
ð 
ð 6Ô<ð ð ð ð ð#˜4ð #ð #ð #ð #ð@ ð2ð 2ñ „(ð2ð 2ð 2r   re   c                 óV   — t          ¦   «         }|€dS  | t          |¦  «        ¦  «        S )zX
	Get the default Installation.

	Uses default_pg_config() to identify the executable.
	N)rc   rG   )Útypr£   s     r   Údefaultrµ   ø   s2   € õ 	ÑÔ€Ø€LØ	ˆØˆÕ  Ñ&Ô&Ñ'Ô'Ð'r   Ú__main__)Úformat_element)rH   rI   )r[   r\   )#r°   Úsysr^   Úos.pathr   r#   r!   Ú	itertoolsr   r   Úoperatorr   Ú	python.osr   r   r	   rŸ   r
   r   Úpg_apir   rO   r-   rG   rZ   rc   re   rµ   rš   Úargvr@   ÚiÚpython.elementr·   ÚprintrŒ   r   r   ú<module>rÂ      sè  ððð ð €
€
€
Ø 	€	€	€	Ø €€€Ø Ð Ð Ð Ø 	€	€	€	Ø €€€Ø "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð ðð ð ð2%
ð %
ð %
ðTð ð ð ð@"ð "ð "ð "ðp2ð p2ð p2ð p2ð p2�6Ô&ñ p2ô p2ð p2ðd ð 	(ð 	(ð 	(ð 	(ð ˆzÒÐØ„HˆQˆRˆR„Lð ØÐ˜3œ8 Aœ;Ñ'Ô'€!Ø€l�1�o„o€!€!à€g�i„i€!Ø+Ð+Ð+Ð+Ð+Ð+Ø€€~€~�aÑÔÑÔÐÐÐð Ðr   