
Gq]c        -   @   si  d  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 d d l	 m
 Z
 y d d l	 m Z Wnp e k
 r Z e e  j   j d  r e j   d d	 k  r d
 Z e d 7Z e d 7Z e e   q   n Xd d l
 m Z d d l
 m Z d d l
 m Z d d l
 m Z d d l
 m Z d d l
 m Z d d l
 m Z d d l
 m Z d d l
 m Z d d l
 m Z d d l m  Z  d d l m! Z! d d l m" Z" d d l m# Z# d d l m$ Z$ d d l m% Z% d d l m& Z& d d l m' Z' d d l m( Z( d d  l m) Z) d d! l m* Z* e j+ d k rcd d l, Z, n d Z, d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 g Z. d2 Z/ e0 e d3  Z1 e0 e d4  Z2 e, d k rd Z3 n" e, j4 d5 i d d1 6 Z5 e5 j3 Z3 i e
 j6 e j7 6e
 j8 e j9 6e
 j: e j; 6e
 j< e j= 6e
 j> e j? 6e
 j@ e jA 6e
 jB e jC 6e
 jD e jE 6e
 jF e jG 6e
 jH e jI 6e
 jJ e jK 6e/ e jL 6e
 jM e jN 6ZO e, d k	 rd6 e, j4 f d7     YZP eQ   jR eP jS  n  e, d k rd ZT d ZU d8 ZV d" ZW n, d9 e, j4 f d:     YZX eQ   jR eX jS  eY d; d d< d d= d8 d> d" d? d# d@ dA dB d	 dC dD dE dF dG dH dI dJ dK dL dM dN dO dP dQ dR dS dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d`  ZZ d Z[ d Z\ d Z] d Z^ d Z_ d Z` d Za d Zb d Zc d Zd d Ze e!   da    Zf ef   ec k  Zg e db dc dd de df dg g  Zh e dh di dj dk dl dm g  Zi e dn do dp dM dO dQ dS dU dq dr d[ d] ds g  Zj e dt ej jk d  Zl e dv dw do g  Zm e dx dy dz jn em jk   Zo e d{ d| d} d~ d d d g  Zp e! d d  d    Zq d   Zr e d    Zs d   Zt d   Zu e jv Zv d   Zw d   Zx d   Zy d   Zz d   Z{ d   Z| d   Z} d   Z~ e2 re a d   Z n  d d  Z d   Z d   Z d   Z d   Z d a d   Z d   Z d   Z d   Z d e f d     YZ e j Z e j Z e j Z d   Z d d d  Z d   Z d e f d     YZ d S(   s    Windows platform implementation.iN(   t
   namedtuplei   (   t   _common(   t   _psutil_windowss   dll load failedi    i   s3   this Windows version is too old (< Windows Vista); s:   psutil 3.4.2 is the latest version which supports Windows s   2000, XP and 2003 server(   t	   conn_tmap(   t   ENCODING(   t   ENCODING_ERRS(   t   isfile_strict(   t   memoize(   t   memoize_when_activated(   t   parse_environ_block(   t   sockfam_to_enum(   t   socktype_to_enum(   t   usage_percent(   t   long(   t	   lru_cache(   t   PY3(   t   unicode(   t   xrange(   t   ABOVE_NORMAL_PRIORITY_CLASS(   t   BELOW_NORMAL_PRIORITY_CLASS(   t   HIGH_PRIORITY_CLASS(   t   IDLE_PRIORITY_CLASS(   t   NORMAL_PRIORITY_CLASS(   t   REALTIME_PRIORITY_CLASSi   i   t   win_service_itert   win_service_getR   R   R   R   R   R   t   IOPRIO_VERYLOWt
   IOPRIO_LOWt   IOPRIO_NORMALt   IOPRIO_HIGHt   CONN_DELETE_TCBt   AF_LINKt
   DELETE_TCBt   proc_io_priority_gett
   getloadavgt   AddressFamilyt   Priorityc           B   s,   e  Z e Z e Z e Z e Z e Z e Z RS(    (   t   __name__t
   __module__R   R   R   R   R   R   (    (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR$   m   s   i   t
   IOPriorityc           B   s    e  Z d  Z d Z d Z d Z RS(   i    i   i   i   (   R%   R&   R   R   R   R   (    (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR'   }   s   t   num_handlest   ctx_switchest	   user_timet   kernel_timet   create_timet   num_threadsi   t	   io_rcountt	   io_wcounti   t	   io_rbytesi   t	   io_wbytesi	   t   io_count_othersi
   t   io_bytes_othersi   t   num_page_faultsi   t	   peak_wseti   t   wseti   t   peak_paged_pooli   t
   paged_pooli   t   peak_non_paged_pooli   t   non_paged_pooli   t   pagefilei   t   peak_pagefilei   t   mem_privatei   c          C   s   t  j   }  |  j |  j f S(   sB   Usage:
    >>> if get_winver() <= WIN_VISTA:
    ...      ...
    (   t   syst   getwindowsversiont   majort   minor(   t   wv(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt
   get_winver   s    t	   scputimest   usert   systemt   idlet	   interruptt   dpct   svmemt   totalt	   availablet   percentt   usedt   freet   pmemt   rsst   vmst   peak_nonpaged_poolt   nonpaged_poolt   privatet   pfullmemt   usst   pmmap_groupedt   patht	   pmmap_exts   addr perms t    t   piot
   read_countt   write_countt
   read_bytest   write_bytest   other_countt   other_bytest   maxsizei   c         C   sH   d j  |  j d  d   } t j |  } t j j  | |  t |   S(   s   Convert paths using native DOS format like:
        "\Device\HarddiskVolume1\Windows\systemew\file.txt"
    into:
        "C:\Windows\systemew\file.txt"
    s   \i   (   t   joint   splitt   cextt   win32_QueryDosDevicet   osRY   t   len(   t   st   rawdrivet   driveletter(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   convert_dos_path   s    c         C   s1   t  r
 |  St |  t  r |  S|  j t t  Sd S(   sm   Encode a unicode string to a byte string by using the default fs
    encoding + "replace" error handler.
    N(   R   t
   isinstancet   strt   encodeR   R   (   Rj   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   py2_strencode   s
    c           C   s
   t  j   S(   N(   Rf   t   getpagesize(    (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyRr      s    c          C   so   t  j   }  |  \ } } } } } } | } | } | }	 | | }
 t | | | d d } t | | | |
 |	  S(   s&   System virtual memory as a namedtuple.t   round_i   (   Rf   t   virtual_memR   RJ   (   t   memt   totphyst	   availphyst   totpageft
   availpageft   totvirtt   freevirtRK   t   availRO   RN   RM   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   virtual_memory   s    
c          C   s[   t  j   }  |  d } |  d } | | } t | | d d } t j | | | | d d  S(   s=   Swap system memory as a (total, used, free, sin, sout) tuple.i   i   Rs   i   i    (   Rf   Rt   R   R   t   sswap(   Ru   RK   RO   RN   RM   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   swap_memory  s    


c         C   sw   t  r- t |  t  r- |  j t d d }  n  t j |   \ } } | | } t | | d d } t j	 | | | |  S(   s'   Return disk usage associated with path.t   errorst   strictRs   i   (
   R   Rn   t   bytest   decodeR   Rf   t
   disk_usageR   R   t
   sdiskusage(   RY   RK   RO   RN   RM   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    
c         C   s/   t  j |   } g  | D] } t j |   ^ q S(   s   Return disk partitions.(   Rf   t   disk_partitionsR   t	   sdiskpart(   t   allt   rawlistt   x(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   +  s    c          C   sb   t  j   \ }  } } t g  t t  j     D] } t |  ^ q+   } t |  | | | j | j  S(   s)   Return system CPU times as a named tuple.(   Rf   t	   cpu_timesRD   t   zipt   per_cpu_timest   sumRH   RI   (   RE   RF   RG   t   nt   percpu_summed(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   6  s    1c          C   sU   g  }  xH t  j   D]: \ } } } } } t | | | | |  } |  j |  q W|  S(   s6   Return system per-CPU times as a list of named tuples.(   Rf   R   RD   t   append(   t   retRE   RF   RG   RH   RI   t   item(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   A  s
    "c           C   s
   t  j   S(   s0   Return the number of logical CPUs in the system.(   Rf   t   cpu_count_logical(    (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   J  s    c           C   s
   t  j   S(   s6   Return the number of physical CPU cores in the system.(   Rf   t   cpu_count_phys(    (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   cpu_count_physicalO  s    c          C   s4   t  j   \ }  } } } d } t j |  | | |  S(   s   Return CPU statistics.i    (   Rf   t	   cpu_statsR   t	   scpustats(   R)   t
   interruptst   dpcst   syscallst   soft_interrupts(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   T  s    c          C   s:   t  j   \ }  } d } t j t |   | t |   g S(   sM   Return CPU frequency.
    On Windows per-cpu frequency is not supported.
    g        (   Rf   t   cpu_freqR   t   scpufreqt   float(   t   currt   max_t   min_(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   \  s    c          C   sK   t  s t j   t a  n  t j   }  t g  |  D] } t | d  ^ q/  S(   s   Return the number of processes in the system run queue averaged
        over the last 1, 5, and 15 minutes respectively as a tuplei   (   t   _loadavg_inititializedRf   t   init_loadavg_countert   TrueR"   t   tuplet   round(   t	   raw_loadst   load(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR"   h  s
    
	c      	   C   sX  |  t  k rG t d |  d j g  t  D] } t |  ^ q"  f   n  t  |  \ } } t j | | |  } t   } x | D] } | \ } }	 }
 } } } } | r t j |   } n  | r t j |   } n  t	 | } t
 |	  }	 t |
  }
 | d k rt j | |	 |
 | | | |  } n t j | |	 |
 | | |  } | j |  q| Wt |  S(   s   Return socket connections.  If pid == -1 return system-wide
    connections (as opposed to connections opened by one process only).
    s+   invalid %r kind argument; choose between %ss   , i(   R   t
   ValueErrorRd   t   reprRf   t   net_connectionst   setR   t   addrt   TCP_STATUSESR
   R   t   sconnt   pconnt   addt   list(   t   kindt   _pidR   t   familiest   typesR   R   R   t   fdt   famt   typet   laddrt   raddrt   statust   pidt   nt(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   {  s(    5	
$c          C   s   i  }  t  j   } x | j   D] \ } } t sa t | t  sR t t |    t |  } n  | \ } } } } t	 t
 d  r t
 j |  } n  t
 j | | | |  |  | <q W|  S(   s)   Get NIC stats (isup, duplex, speed, mtu).t	   NicDuplex(   Rf   t   net_if_statst   itemsR   Rn   R   t   AssertionErrorR   Rq   t   hasattrR   R   t	   snicstats(   R   t   rawdictt   nameR   t   isupt   duplext   speedt   mtu(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    ! c          C   sA   t  j   }  t g  |  j   D] \ } } t |  | f ^ q  S(   ss   Return network I/O statistics for every network interface
    installed on the system as a dict of raw tuples.
    (   Rf   t   net_io_counterst   dictR   Rq   (   R   t   kt   v(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    c          C   sN   g  }  xA t  j   D]3 } t |  } t | d  | d <|  j |  q W|  S(   s,   Return the addresses associated to each NIC.i    (   Rf   t   net_if_addrsR   Rq   R   (   R   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    c          C   s   t  j   \ }  } } } |  d k } t | d @ } t | d @ } | rN d S| sZ | rf t j } n | d k r~ t j } n  t j | | |  S(   s   Return battery information.i   i   i   iN(   Rf   t   sensors_batteryt   boolt   NoneR   t   POWER_TIME_UNLIMITEDt   POWER_TIME_UNKNOWNt   sbattery(   t   acline_statust   flagsRM   t   secsleftt   power_pluggedt
   no_batteryt   charging(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    c          C   s:   t  t j    }  t |  t  d k r, t S|  a |  Sd S(   s:   The system boot time expressed in seconds since the epoch.i   N(   R   Rf   t	   boot_timet   abst   _last_btime(   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s
    c          C   sj   g  }  t  j   } xQ | D]I } | \ } } } t |  } t j | d | | d  } |  j |  q W|  S(   s:   Return currently connected users as a list of namedtuples.N(   Rf   t   usersRq   R   t   suserR   R   (   t   retlistR   R   RE   t   hostnamet   tstampR   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    c          c   s;   x4 t  j   D]& \ }  } t t |   t |   Vq Wd S(   s*   Yields a list of WindowsService instances.N(   Rf   t   winservice_enumeratet   WindowsServiceRq   (   R   t   display_name(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    c         C   s&   t  |  d  } | j   d | _ | S(   sB   Open a Windows service and return it as a WindowsService instance.R   N(   R   R   t   _query_configt   _display_name(   R   t   service(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    R   c           B   s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 e
 j d    Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s(   Represents an installed Windows service.c         C   s   | |  _  | |  _ d  S(   N(   t   _nameR   (   t   selfR   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   __init__  s    	c         C   s*   d |  j  |  j f } d |  j j | f S(   Ns   (name=%r, display_name=%r)s   %s%s(   R   R   t	   __class__R%   (   R   t   details(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   __str__  s    c         C   s   d |  j    t |   f S(   Ns
   <%s at %s>(   R   t   id(   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   __repr__  s    c         C   s#   t  | t  s t S|  j | j k S(   N(   Rn   R   t   NotImplementedR   (   R   t   other(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   __eq__  s    c         C   s   |  | k S(   N(    (   R   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   __ne__  s    c         C   sh   |  j    # t j |  j  \ } } } } Wd  QXt d t |  d t |  d t |  d t |   S(   NR   t   binpatht   usernamet
   start_type(   t   _wrap_exceptionsRf   t   winservice_query_configR   R   Rq   (   R   R   R   R   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    $c         C   sS   |  j     t j |  j  \ } } Wd  QX| d k r@ d  } n  t d | d |  S(   Ni    R   R   (   R   Rf   t   winservice_query_statusR   R   R   (   R   R   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   _query_status(  s
    	c         c   s   y	 d VWn t  k
 r } t |  rO t d d d |  j d d |  j   q | j t j t j f k r t	 d d d |  j d d |  j   q   n Xd S(   s{   Ctx manager which translates bare OSError and WindowsError
        exceptions into NoSuchProcess and AccessDenied.
        NR   R   t   msgs2   service %r is not querable (not enough privileges)s   service %r does not exist)(
   t   OSErrort   is_permission_errt   AccessDeniedR   R   t   winerrorRf   t   ERROR_INVALID_NAMEt   ERROR_SERVICE_DOES_NOT_EXISTt   NoSuchProcess(   R   t   err(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   /  s    	c         C   s   |  j  S(   s   The service name. This string is how a service is referenced
        and can be passed to win_service_get() to get a new
        WindowsService instance.
        (   R   (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   F  s    c         C   s   |  j  S(   s_   The service display name. The value is cached when this class
        is instantiated.
        (   R   (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   M  s    c         C   s   |  j    d S(   sw   The fully qualified path to the service binary/exe file as
        a string, including command line arguments.
        R   (   R   (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   S  s    c         C   s   |  j    d S(   s,   The name of the user that owns this service.R   (   R   (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   Y  s    c         C   s   |  j    d S(   sR   A string which can either be "automatic", "manual" or
        "disabled".
        R   (   R   (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   ]  s    c         C   s   |  j    d S(   sz   The process PID, if any, else None. This can be passed
        to Process class to control the service's process.
        R   (   R   (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   e  s    c         C   s   |  j    d S(   s   Service status as a string.R   (   R   (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR   k  s    c         C   s   t  t j |  j     S(   s   Service long description.(   Rq   Rf   t   winservice_query_descrR   (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   descriptiono  s    c         C   sS   |  j    } | j |  j    |  j   | d <|  j   | d <|  j   | d <| S(   sU   Utility method retrieving all the information above as a
        dictionary.
        R   R   R  (   R   t   updateR   R   R   R  (   R   t   d(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   as_dictu  s    (   R%   R&   t   __doc__R   R   R   R   R   R   R   t
   contextlibt   contextmanagerR   R   R   R   R   R   R   R   R  R  (    (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s$   															c         C   sX   t  |  t  s t |    |  j t j t j f k pW t |  d d  t j t j	 f k S(   s*   Return True if this is a permission error.R  i(
   Rn   R   R   t   errnot   EPERMt   EACCESt   getattrRf   t   ERROR_ACCESS_DENIEDt   ERROR_PRIVILEGE_NOT_HELD(   t   exc(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    c         C   si   t  |  t  s t |    t |   r: t d | d |  S|  j t j k r_ t d | d |  S|   d S(   s3   Convert OSError into NoSuchProcess or AccessDenied.R   R   N(   Rn   R   R   R   R  R  t   ESRCHR  (   R  R   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   convert_oserror  s    c            s"   t  j      f d    } | S(   sD   Decorator which converts OSError into NoSuchProcess or AccessDenied.c            sL   y   |  | |  SWn1 t  k
 rG } t | d |  j d |  j  n Xd  S(   NR   R   (   R   R  R   R   (   R   t   argst   kwargsR  (   t   fun(    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   wrapper  s    (   t	   functoolst   wraps(   R  R  (    (   R  s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   wrap_exceptions  s    t   Processc           B   s-  e  Z d  Z d d d d g Z d   Z d   Z d   Z e e d     Z	 e d	    Z
 e d
    Z e d    Z e d    Z d   Z d   Z e d    Z e d    Z d   Z e d    Z e d    Z e d* d   Z e d    Z e d    Z e d    Z e d    Z e d    Z e d    Z e d    Z e d    Z e d    Z e d d   Z  e d     Z! e d!    Z" e# re d"    Z$ e d#    Z% n  e d$    Z& e d%    Z' e d&    Z( e d'    Z) e d(    Z* e d)    Z+ RS(+   s1   Wrapper class around underlying C implementation.R   R   t   _ppidt   _cachec         C   s   | |  _  d  |  _ d  |  _ d  S(   N(   R   R   R   R   (   R   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    		c         C   s   |  j  j |   d  S(   N(   t   oneshot_infot   cache_activate(   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   oneshot_enter  s    c         C   s   |  j  j |   d  S(   N(   R"  t   cache_deactivate(   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   oneshot_exit  s    c         C   s4   t  j |  j  } t |  t t  k s0 t  | S(   sO   Return multiple information about this process as a
        raw tuple.
        (   Rf   t	   proc_infoR   Ri   t	   pinfo_mapR   (   R   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR"    s    c         C   sq   |  j  d k r d S|  j  d k r& d Sy  t t j j |  j     SWn$ t k
 rl t t j |  j    SXd S(   sb   Return process name, which on Windows is always the final
        part of the executable.
        i    s   System Idle Processi   t   SystemN(	   R   Rq   Rh   RY   t   basenamet   exeR  Rf   t	   proc_name(   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s     c         C   sj   t  s t j |  j  } nE |  j d k rB t |  j |  j   n  t j |  j  } t |  } t |  S(   Ni    i   (   i    i   (   t	   IS_WIN_XPRf   t   proc_exeR   R  R   Rm   Rq   (   R   R+  (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR+    s    c         C   s   t  j t  j k rq y t  j |  j d t } Wq t k
 rm } t |  rg t  j |  j d t } qn   q Xn t  j |  j d t } t	 r | Sg  | D] } t
 |  ^ q Sd  S(   Nt   use_peb(   Rf   t   WINVERt   WINDOWS_8_1t   proc_cmdlineR   R   R   R   t   FalseR   Rq   (   R   R   R  Rj   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   cmdline  s    
c         C   sS   t  j |  j  } | rC t rC t | t  sC t t |    n  t t	 |   S(   N(
   Rf   t   proc_environR   R   Rn   R   R   R   R	   Rq   (   R   t   ustr(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   environ#  s    $c         C   s?   y t    |  j SWn& t k
 r: t |  j |  j   n Xd  S(   N(   t   ppid_mapR   t   KeyErrorR  R   (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   ppid*  s    c         C   s   y t  j |  j  SWn t k
 r } t |  r |  j   } | t d | t d | t d | t d | t d | t d | t d | t d | t d	 | t d
 f
 S  n Xd  S(   NR4   R5   R6   R7   R8   R9   R:   R;   R<   R=   (   Rf   t   proc_memory_infoR   R   R   R"  R(  (   R   R  t   info(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   _get_raw_meminfo0  s     c         C   s4   |  j    } | d } | d } t | | f |   S(   Ni   i   (   R=  RP   (   R   t   tRQ   RR   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   memory_infoF  s    

c         C   s<   |  j    } t j |  j  } | t   9} t | | f   S(   N(   R?  Rf   t   proc_memory_ussR   Rr   RV   (   R   t	   basic_memRW   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   memory_full_infoP  s    c         c   s   y t  j |  j  } Wn+ t k
 rC } t | |  j |  j   n} Xxy | D]q \ } } } } t |  } t s t | t	  s t
 t |    t |  } n  t |  } | | | | f VqK Wd  S(   N(   Rf   t   proc_memory_mapsR   R   R  R   Rm   R   Rn   R   R   R   Rq   t   hex(   R   t   rawR  R   t   permRY   RQ   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   memory_mapsW  s    !c         C   s   t  j |  j  S(   N(   Rf   t	   proc_killR   (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   killg  s    c         C   s   t  j |  j |  d  S(   N(   Rh   RI  R   (   R   t   sig(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   send_signalk  s    c         C   s=  | d  k r t j } n t | d  } t t d t j  } | d  k	 rV |   | n d  } y t j |  j |  } WnE t j k
 r t | |  j |  j	   n t j
 k
 r d  } n Xd } xs t r8t |  j  s | S| r|   | k rt | d |  j d |  j	  n  t j |  t | d d  } q Wd  S(   Ni  t	   monotonicg-C6?R   R   i   g{Gz?(   R   Rf   t   INFINITEt   intR  t   timet	   proc_waitR   t   TimeoutExpiredR   t   TimeoutAbandonedR   t
   pid_existst   sleept   min(   R   t   timeoutt   cext_timeoutt   timert   stop_att	   exit_codet   delay(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   waito  s&    	
	!c         C   sC   |  j  d k r d St j |  j   \ } } t |  d t |  S(   Ni    i   s   NT AUTHORITY\SYSTEMs   \(   i    i   (   R   Rf   t   proc_usernameRq   (   R   t   domainRE   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    c         C   se   |  j  d k r t   Sy t j |  j   SWn4 t k
 r` } t |  rZ |  j   t d S  n Xd  S(   Ni    i   R,   (   i    i   (   R   R   Rf   t   proc_create_timeR   R   R"  R(  (   R   R  (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR,     s    c         C   s   |  j    t d S(   NR-   (   R"  R(  (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR-     s    c         C   sX   t  j |  j  } g  } x9 | D]1 \ } } } t j | | |  } | j |  q W| S(   N(   Rf   t   proc_threadsR   R   t   pthreadR   (   R   R   R   t	   thread_idt   utimet   stimet   ntuple(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   threads  s    c         C   s   y t  j |  j  \ } } WnM t k
 rk } t |  s@   n  |  j   } | t d } | t d } n Xt j | | d d  S(   NR*   R+   g        (	   Rf   t   proc_cpu_timesR   R   R   R"  R(  R   t	   pcputimes(   R   RE   RF   R  R<  (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    c         C   s   t  j |  j t  d  S(   N(   Rf   t   proc_suspend_or_resumeR   R   (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   suspend  s    c         C   s   t  j |  j t  d  S(   N(   Rf   Ri  R   R3  (   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   resume  s    c         C   sO   |  j  d k r' t |  j  |  j   n  t j |  j   } t t j j |   S(   Ni    i   (   i    i   (	   R   R  R   Rf   t   proc_cwdRq   Rh   RY   t   normpath(   R   RY   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   cwd  s    c         C   s   |  j  d k r g  St   } t j |  j   } x] | D]U } t |  } t |  r5 t sh t |  } n  t j	 | d  } | j
 |  q5 q5 Wt |  S(   Ni    i   i(   i    i   (   R   R   Rf   t   proc_open_filesRm   R   R   Rq   R   t	   popenfileR   R   (   R   R   t   raw_file_namest   _fileRe  (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt
   open_files  s    	t   inetc         C   s   t  | d |  j S(   NR   (   R   R   (   R   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   connections  s    c         C   s1   t  j |  j  } t d  k	 r- t |  } n  | S(   N(   Rf   t   proc_priority_getR   t   enumR   R$   (   R   t   value(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   nice_get  s    c         C   s   t  j |  j |  S(   N(   Rf   t   proc_priority_setR   (   R   Rx  (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   nice_set  s    c         C   s1   t  j |  j  } t d  k	 r- t |  } n  | S(   N(   Rf   R!   R   Rw  R   R'   (   R   R   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt
   ionice_get  s    c         C   sW   | r t  d   n  | t t t t f k r@ t d |   n  t j |  j |  d  S(   Ns&   value argument not accepted on Windowss   %s is not a valid priority(	   t	   TypeErrorR   R   R   R   R   Rf   t   proc_io_priority_setR   (   R   t   ioclassRx  (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt
   ionice_set  s    c         C   s   y t  j |  j  } Wny t k
 r } t |  s:   n  |  j   } | t d | t d | t d | t d | t d | t d f } n Xt |   S(   NR.   R/   R0   R1   R2   R3   (   Rf   t   proc_io_countersR   R   R   R"  R(  R\   (   R   R   R  R<  (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   io_counters  s    c         C   s*   t  j |  j  } | r t j St j Sd  S(   N(   Rf   t   proc_is_suspendedR   R   t   STATUS_STOPPEDt   STATUS_RUNNING(   R   t	   suspended(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR     s    c         C   s%   d   } t  j |  j  } | |  S(   Nc         S   s+   g  t  d  D] } d | >|  @r | ^ q S(   Ni@   i   (   R   (   R   t   i(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   from_bitmask(  s    (   Rf   t   proc_cpu_affinity_getR   (   R   R  t   bitmask(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   cpu_affinity_get&  s    	c         C   s   d   } t  t t t      } xU | D]M } | | k r+ t | t t f  se t d |   qx t d |   q+ q+ W| |  } t	 j
 |  j |  d  S(   Nc         S   sB   |  s t  d |    n  d } x |  D] } | d | O} q& W| S(   Ns   invalid argument %ri    i   (   R   (   t   lt   outt   b(    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt
   to_bitmask/  s    s&   invalid CPU %r; an integer is requireds   invalid CPU %r(   R   t   rangeRi   R   Rn   RN  R   R}  R   Rf   t   proc_cpu_affinity_setR   (   R   Rx  R  t   allcpust   cpuR  (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   cpu_affinity_set-  s    	c         C   sO   y t  j |  j  SWn4 t k
 rJ } t |  rD |  j   t d S  n Xd  S(   NR(   (   Rf   t   proc_num_handlesR   R   R   R"  R(  (   R   R  (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR(   F  s    c         C   s$   |  j    t d } t j | d  S(   NR)   i    (   R"  R(  R   t   pctxsw(   R   R)   (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   num_ctx_switchesO  s    N(,   R%   R&   R  t	   __slots__R   R$  R&  R  R   R"  R   R+  R4  R7  R:  R=  R?  RB  RG  RI  RK  R   R\  R   R,   R-   Rf  R   Rj  Rk  Rn  Rs  Ru  Ry  R{  t   HAS_PROC_IO_PRIORITYR|  R  R  R   R  R  R(   R  (    (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyR    sT   						
	*				(   i   i   (   i
   i    (   i   i   (   i   i   (   i   i    (   i   i    (   i   i   (   i   i   (   RW   (   R  R  R  R  Rh   R>   RO  t   collectionsR    t    R   R   Rf   t   ImportErrorR  Ro   t   lowert
   startswithR?   R   t   RuntimeErrorR   R   R   R   R   R   R	   R
   R   R   t   _compatR   R   R   R   R   R   R   R   R   R   R   t   version_infoRw  R   t   __extra__all__R   R   R  t   HAS_GETLOADAVGR   t   IntEnumR#   t   CONN_ESTABLISHEDt   MIB_TCP_STATE_ESTABt   CONN_SYN_SENTt   MIB_TCP_STATE_SYN_SENTt   CONN_SYN_RECVt   MIB_TCP_STATE_SYN_RCVDt   CONN_FIN_WAIT1t   MIB_TCP_STATE_FIN_WAIT1t   CONN_FIN_WAIT2t   MIB_TCP_STATE_FIN_WAIT2t   CONN_TIME_WAITt   MIB_TCP_STATE_TIME_WAITt
   CONN_CLOSEt   MIB_TCP_STATE_CLOSEDt   CONN_CLOSE_WAITt   MIB_TCP_STATE_CLOSE_WAITt   CONN_LAST_ACKt   MIB_TCP_STATE_LAST_ACKt   CONN_LISTENt   MIB_TCP_STATE_LISTENt   CONN_CLOSINGt   MIB_TCP_STATE_CLOSINGt   MIB_TCP_STATE_DELETE_TCBt	   CONN_NONEt   PSUTIL_CONN_NONER   R$   t   globalsR	  t   __members__R   R   R   R   R'   R   R(  R  t   ZombieProcessR  RQ  t   WIN_10t   WIN_8t   WIN_7t   WIN_SERVER_2008t	   WIN_VISTAt   WIN_SERVER_2003t   WIN_XPRC   R-  RD   RJ   RP   t   _fieldsRV   RX   Rd   RZ   R\   Rm   Rq   Rr   R}   R   t   disk_io_countersR   R   R   R   R   R   R   R   R3  R   R"   R   R   R   R   R   R   R   R   R   R   t   objectR   t   pidsRS  R8  R   R  R  R  (    (    (    s0   lib/python2.7/site-packages/psutil/_pswindows.pyt   <module>   sJ  

			
		
				
																									
	