관리-도구
편집 파일: pmPlugin.cpython-36.pyc
3 e�$g+ � @ s� d dl Z d dlZd dlZyd dlmZ dZdZdZW n ek rT dZdZdZY nX d d � Z dd� Z d d� Zdd� Zdd� Z dd� ZdS )� N)�__version__z/etc/dnf/plugins/spacewalk.confzdnf-plugin-spacewalk�dnfz$/etc/yum/pluginconf.d/rhnplugin.confzyum-rhn-pluginZyumc C sN d} d}t � r6d}t� r*t� s4t� d} qFt� d} ntjjd�rFd}|| fS )z!Enables plugin, may throw IOErrorr � z(/usr/lib/zypp/plugins/services/spacewalk)�PluginPackagePresent�PluginConfPresent� PluginEnabled�enablePlugin�createDefaultPluginConf�os�path�exists)Zconf_changedZplugin_present� r �/usr/lib/python3.6/pmPlugin.py�pluginEnable s r c C s t j� } | jdt�}|j� S )zO Returns positive number if plugin package is installed, otherwise it return 0 Zprovidename)�rpmZTransactionSetZdbMatch�PM_PLUGIN_NAME�count)ZtsZheadersr r r r % s r c C s( yt jt� dS tk r" dS X dS )z- Returns true if PM_PLUGIN_CONF is presented TFN)r �stat�PM_PLUGIN_CONF�OSErrorr r r r r + s r c C s t td�} | jd� | j� dS )z1 Create file PM_PLUGIN_CONF, with default values �wz[main] enabled = 1 gpgcheck = 1N)�openr �write�close)�fr r r r 3 s r c C s� t td�} | j� }| j� d}d}xZ|D ]R}tjd|�rNtjd|�rJd}nd}|r(tjd|�}|r(t|jd��rvd}q(d}q(W |S )zM Returns True if plugin is enabled Can thrown IOError exception. �rFz^\[.*]z^\[main]Tz^\s*enabled\s*=\s*([0-9])r )r r � readlinesr �re�match�int�group)r �lines�main_section�result�line�mr r r r ; s"