%PDF- %PDF-
Direktori : /usr/lib/python2.7/site-packages/salt/modules/ |
Current File : //usr/lib/python2.7/site-packages/salt/modules/sysfs.pyo |
� ���^c @@ s� d Z d d l m Z m Z m 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 e j e � Z d � Z d d � Z d � Z d d � Z e d � Z d � Z d S( u� Module for interfacing with SysFS .. seealso:: https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt .. versionadded:: 2016.3.0 i ( t absolute_importt unicode_literalst print_functionN( t sixc C@ s t j j j � S( u Only work on Linux ( t saltt utilst platformt is_linux( ( ( s6 /usr/lib/python2.7/site-packages/salt/modules/sysfs.pyt __virtual__ s c C@ sY t | � } | t k r t St j j | � r2 | S| d k rK t | | � St | � Sd S( u� Access/write a SysFS attribute. If the attribute is a symlink, it's destination is returned :return: value or bool CLI example: .. code-block:: bash salt '*' sysfs.attr block/sda/queue/logical_block_size N( t targett Falset ost patht isdirt Nonet writet read( t keyt value( ( s6 /usr/lib/python2.7/site-packages/salt/modules/sysfs.pyt attr s c C@ s� ym t | � } t j d | | � t j j j | d � �0 } | j t j j j d j | � � � t SWd QXWn t k r� t SXd S( u� Write a SysFS attribute/action CLI example: .. code-block:: bash salt '*' sysfs.write devices/system/cpu/cpu0/cpufreq/scaling_governor 'performance' u Writing %s to %su wu {0} N( R t logt traceR R t filest fopenR t stringutilst to_strt formatt Truet ExceptionR ( R R t twriter( ( s6 /usr/lib/python2.7/site-packages/salt/modules/sysfs.pyR 8 s u c C@ s, t | t j � sa i } xB | D]: } t t j j | | � � } | t k r | | | <q q W| St t j j | | � � } | t k r� t St j j | � rit | � } i } x� | d | d D]� } t t j j | | � � } | t k r� | j d � } | j � } | } t | � rTx4 | D]) } | | k rCi | | <n | | } q$Wn | | | <q� q� W| Sy� t j d | � t j t j | t j t j B� � �o } | j � j � } | s�t Sy t | � } Wn5 t k ry t | � } Wqt k rqXn X| SWd QXWn t k r't SXd S( u Read from SysFS :param key: file or path in SysFS; if key is a list then root will be prefixed on each key :return: the full (tree of) SysFS attributes under key CLI example: .. code-block:: bash salt '*' sysfs.read class/net/em1/statistics u ru rwu /u Reading %s...N( t isinstanceR t string_typesR R R t joinR R R t interfacest splitt popt lenR R t fdopent opent O_RDONLYt O_NONBLOCKt stript intR t float( R t roott rest akeyt arest keyst resultt subkeyt subvalt subkeyst subresultt skeyt treadert val( ( s6 /usr/lib/python2.7/site-packages/salt/modules/sysfs.pyR M sT ( c C@ s} | j d � s'