Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/sos/report/plugins/__pycache__/pulpcore.cpython-36.pyc

3

�f��@sBddlmZddlmZddlmZmZmZGdd�dee�ZdS)�)�match)�quote)�Plugin�IndependentPlugin�	PluginOptc@sneZdZdZdZdZdZedddd�gZd	Z	d
Z
dZdZdZ
d
ZdeiZdd�Zdd�Zddd�Zdd�ZdS)�PulpCorezPulp-3 aka pulpcoreZpulpcore�pulpcore-manager�/etc/pulp/settings.pyz	task-days�zdays of task history)�defaultZdescZ	localhosti8�z/var/lib/pulp/assetsz/var/lib/pulp/media/upload�
PGPASSWORDcCsbd}ddd�}�y*tdddd���}�x|j�jd	d
�jdd�jd
d�j�D]�}|sL|ddkrdqL|jd�rtd}qLd}|r�t|d|�r�||�|_|r�t|d|�r�||�|_|r�t|d|�r�||�|_|r�t|d|�r�||�|_	|r�d
|kr�d}|jd��r||dd�|_
|jd�rL||dd�|_qLWWdQRXWntk
�rPYnXd|j	i|_
dS)z Parse pulp settings F�:cSsP|j|�dj�jd�}|jd�r,|jd�s@|jd�rL|jd�rL|dd�}|S)N��,�"�'���)�split�lstrip�rstrip�
startswith�endswith)�line�sep�val�r�/usr/lib/python3.6/pulpcore.py�separate_value's
z6PulpCore.parse_settings_config.<locals>.separate_valuez/etc/pulp/settings.py�rzUTF-8)�encodingrz,
�{z{
�}z
}r�#Z	DATABASESTz\s*['|\"]%s['|\"]\s*:\s*\S+ZHOSTZPORT�NAMEZPASSWORDzSTATIC_ROOT = �=)rzCHUNKED_UPLOAD_DIR = Nr
)r)�open�read�replace�
splitlinesrr�dbhost�dbport�dbname�dbpasswd�
staticroot�	uploaddir�IOError�env)�selfZdatabases_scoper�filer�patternrrr�parse_settings_config#s<
	





 zPulpCore.parse_settings_configcCs�|j�|jddg�|jd�|jddd�dddd	�}|jd
|d�x"|j|jgD]}|jd|�qVW|jd
�}x4dD],}d||f}|j|�}|j||j|d�q|W|jd�}|j|d|jd�dS)Nz/etc/pulp/settings.pyz/etc/pki/pulp/*z/etc/pki/pulp/**/*.keyz.curl -ks https://localhost/pulp/api/v3/status/Zpulp_status)�suggest_filenamezen_US.UTF-8zpulpcore.app.settings)�LC_ALLZ
PULP_SETTINGSZDJANGO_SETTINGS_MODULEz
dynaconf list)r1zls -l %sz	task-days�	core_task�core_taskgroup�core_groupprogressreport�core_progressreportz`select * from %s where pulp_last_updated > NOW() - interval '%s days' order by pulp_last_updated)r1r6a[SELECT table_name, pg_size_pretty(total_bytes) AS total, pg_size_pretty(index_bytes) AS INDEX , pg_size_pretty(toast_bytes) AS toast, pg_size_pretty(table_bytes) AS TABLE FROM ( SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME, c.reltuples AS row_estimate, pg_total_relation_size(c.oid) AS total_bytes, pg_indexes_size(c.oid) AS index_bytes, pg_total_relation_size(reltoastrelid) AS toast_bytes FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE relkind = 'r') a) a order by total_bytes DESCZpulpcore_db_tables_sizes)r6r1)r8r9r:r;)	r5Z
add_copy_specZadd_forbidden_pathZadd_cmd_outputr.r/Z
get_option�build_query_cmdr1)r2Zdynaconf_envZ_dirZ	task_days�tableZ_queryZ_cmdrrr�setupVs0



zPulpCore.setupFcCs*|rd|}d}||j|j|jt|�fS)aI
        Builds the command needed to invoke the pgsql query as the postgres
        user.
        The query requires significant quoting work to satisfy both the
        shell and postgres parsing requirements. Note that this will generate
        a large amount of quoting in sos logs referencing the command being run
        z>COPY (%s) TO STDOUT WITH (FORMAT 'csv', DELIMITER ',', HEADER)z2psql --no-password -h %s -p %s -U pulp -d %s -c %s)r*r+r,r)r2ZqueryZcsvZ_dbcmdrrrr<�s
zPulpCore.build_query_cmdcCs(d}d}|jd||�|jd||�dS)Nz_((?:SECRET_KEY|AUTH_LDAP_BIND_PASSWORD)(?:\<.+\>)?(\s*=)?|(password|PASSWORD)(\"|'|:)+)\s*(\S*)z\1 ********z/etc/pulp/settings.pyz
dynaconf list)Zdo_path_regex_subZdo_cmd_output_sub)r2Zkey_pass_re�replrrr�postproc�szPulpCore.postprocN)r)r	)F)�__name__�
__module__�__qualname__Z
short_descZplugin_nameZcommands�filesrZoption_listr*r+r,r-r.r/r1r5r>r<r@rrrrrs 3/
rN)	�rerZshlexrZsos.report.pluginsrrrrrrrr�<module>s

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists