관리-도구
편집 파일: device.cpython-36.pyc
3 E�Ud(� � @ s d Z ddlmZ ddlZddlZddlZddlZddlmZmZm Z m Z ddlmZm Z mZmZmZ ddlmZ ddlmZ dd lT dd lmZmZ ddlmZ ddlmZmZmZmZ ej d �Z!defe"ee" eee" d�dd�Z#G dd� de$�Z%ddgZ&dS )at This module contains the definition of the `Device` class, used to represent a physical storage device connected to the system. Once initialized, class members contain all relevant information about the device, including its model, serial number, firmware version, and all SMART attribute data. Methods are provided for initiating self tests and querying their results. � )�print_functionN)�time�strptime�mktime�sleep)�Tuple�Union�List�Dict�Optional� )� Attribute)�Diagnostics)�*)�Smartctl�SMARTCTL)� TestEntry)� smartctl_type�smartctl_isvalid_type�any_in�all_inZpySMART)� disk_name� interface�smartctl�returnc C s~ d}|j tjjd| jdd��|�}|d }d|krR|jd�d j� d krNd }nd}d|krz|jd�d j� d krvd }nd}|S )a� This function gets the SMART Health Status of the disk (IF the disk is SMART capable and smart is enabled on it else returns None). This function is to be used only in abridged mode and not otherwise, since in non-abridged mode update gets this information anyways. Args: disk_name (str): name of the disk interface (str, optional): interface type of the disk (e.g. 'sata', 'scsi', 'nvme',... Defaults to None.) Returns: str: SMART Health Status of the disk. Returns None if the disk is not SMART capable or smart is not enabled on it. Possible values are 'PASS', 'FAIL' or None. Nz/dev/�nvd�nvme� z$SMART overall-health self-assessment�:r �PASSED�PASS�FAILzSMART Health Status�OK)Zhealth�os�path�join�replace�split�strip)r r r � assessment�raw�line� r, �1/tmp/pip-build-81p2_6r0/pySMART/pySMART/device.py�smart_health_assement0 s r. c @ s� e Zd ZdZdddefeee eeee e df e d�dd�Zeee d�dd ��Z eee d�d d��Zeee d�dd ��Zeed�dd��Zeee d�dd��Zeee d�dd��Zeeeef d�dd��Zeee d�dd��Zeed�dd��Zeed�dd��Zdd� Zd<dd �Zd!d"� Zeeee e f d#�d$d%�Zefd&d'�Zd(d)� Z ed�d*d+�Z!d,d-� Z"d.d/� Z#d=d0d1�Z$d2d3� Z%d>d5d6�Z&d?d8d9�Z'd:d;� Z(dS )@�Devicez� Represents any device attached to an internal storage interface, such as a hard drive or DVD-ROM, and detected by smartmontools. Includes eSATA (considered SATA) but excludes other external devices (USB, Firewire). NF)�namer �abridged� smart_optionsr c C sD |dkpt |j� �s$tdj||���|p.|dk| _|dk rXt|t�rN|jd�}|j|� || _ |j dd�j dd�| _d| _d| _ d| _d| _|dkr�dn|| _d| _d| _d| _d| jk| _d| jk| _d| _g | _d| jkr�d nd | _d| _dgd | _d d| jkd| jkd d d�| _g | _d | _d| _d| _t � | _!d| _"i | _#d| _$d| _%d| _&| jdk�rvt'j(d j|�� dS | jdk�r$| j �r$t)j*dj| j�� | j j+dd| j,g�\}}t-|�dk�ry0|d jd�d | _| jdk�r�d | _d | _W n d| _d | _.Y nX nt'j(d j|�� dS | jdk �s8| j�r@| j/� dS )z9Instantiates and initializes the `pySMART.device.Device`.Nz(Unknown interface: {0} specified for {1}zUNKNOWN INTERFACE� z/dev/� r r TF� )�offline�short�long� conveyance� selectivez> Device '{0}' does not exist! This object should be destroyed.z"Determining interface of disk: {0}z-d�testr � �'r ���)0r �lower� ValueError�formatr1 � isinstance�strr'