o
    •Û_S  ã                   @   s>   d dl Z d dlZddlmZ d dlmZ G dd„ dejƒZdS )é    Né   )Úbase)Úcommandsc                       s,   e Zd ZdZ‡ fdd„Z‡ fdd„Z‡  ZS )Ú
virt_checkz§
	Checks whether running inside virtual machine (VM) or on bare metal.
	If running inside VM expands to argument 1, otherwise expands to
	argument 2 (even on error).
	c                    s   t t| ƒ ddd¡ d S )Nr   é   )Úsuperr   Ú__init__)Úself©Ú	__class__© úN/usr/lib/python3/dist-packages/tuned/profiles/functions/function_virt_check.pyr      s   zvirt_check.__init__c                    sJ   t t| ƒ |¡s
d S | j dg¡\}}|dkr!t|ƒdkr!|d S |d S )Nz	virt-whatr   r   )r   r   ÚexecuteÚ_cmdÚlen)r	   ÚargsÚretÚoutr
   r   r   r      s   zvirt_check.execute)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r   r   r
   r   r      s    r   )	ÚosÚ
tuned.logsÚtunedÚ r   Útuned.utils.commandsr   ÚFunctionr   r   r   r   r   Ú<module>   s
    