JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrJFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr 0iV dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddlm&Z&ddlm'Z'ddlm(Z(ddlm)Z)ddlm*Z*dd lm+Z+dd!lm,Z,dd"lm-Z-dd#lm.Z.dd$lm/Z/dd%lm0Z0dd&lm1Z1dd'lm2Z2dd(lm3Z3dd)lm4Z4dd*lm5Z5dd+lm6Z6dd,lm7Z7dd-lm8Z8dd.lm9Z9dd/lm:Z:dd0lm;Z;dd1lmZ>dd4lm?Z@er!d5ZAdd6lmBZCdd7lBmDZDdd8lBmEZEdd9lBmFZFdd:lBmGZGne7rIdd;lmHZCddlImLZLdd?lImMZMdd@lImNZNddAlImOZOddBlHmPZPddClHmQZQddDlHmRZRddElHmSZSddFlHmTZTnLe rddGlmUZCnCerddHlmVZCn:e6rddIlmWZCddJlWmXZXddKlWmYZYd5ZAn#er ddLlmZZCd5ZAndMe jdNZ\e]e\gdOZ^e^jeCjeaeCjdPrlecZddZeefeCjD]LZeeejdQseejs&ejeCjeeedee<e^jeeN[d[eeCjZldRZmdSZneodTenjdUDZqeje dVe jZrdasdateuZvewenjdUdWejeCjdXdk7rdYeCjjdZZ\e\d[z Z\eaeCjdXr>dUje{e|eCjjZ~e\d\e~d]end^z Z\n e\d_end^z Z\ejeCjd`daZe\dbez Z\e\dcz Z\e e\eaeCddreCjZndeZdfZdgZGdhdiZbefebDchc]}|jdjr|dkvs|c}ZGdldmebZdnZdoZiaeZddpZdqe_drej_ddsZdduZddvZ e j j"eiZ e j j"edtwiZdxZdyZdzZdd{Zej3Zej3Zdd|Zd}ZeaeCd~rddZe^jd~eaeds eaeCdr5eaedrej>Zn eCj>Ze^jddZdZdZddZddZejJe@jde_dej_ddZejJe@jde_dej_ddZdZdZeaeCdrddZe^jdeaeCdrdZe^jdeaeCdrdZe^jddZdZe7rdZdZdZ[>y#e $rdZ YwxYwcc}w#e$riZYwxYw#e$riZYwxYw)a;psutil is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network, sensors) in Python. Supported platforms: - Linux - Windows - macOS - FreeBSD - OpenBSD - NetBSD - Sun Solaris - AIX Supported Python versions are cPython 3.6+ and PyPy. N)_common)AIX)BSD) CONN_CLOSE)CONN_CLOSE_WAIT) CONN_CLOSING)CONN_ESTABLISHED)CONN_FIN_WAIT1)CONN_FIN_WAIT2) CONN_LAST_ACK) CONN_LISTEN) CONN_NONE) CONN_SYN_RECV) CONN_SYN_SENT)CONN_TIME_WAIT)FREEBSD)LINUX)MACOS)NETBSD)NIC_DUPLEX_FULL)NIC_DUPLEX_HALF)NIC_DUPLEX_UNKNOWN)OPENBSD)OSX)POSIX)POWER_TIME_UNKNOWN)POWER_TIME_UNLIMITED) STATUS_DEAD)STATUS_DISK_SLEEP) STATUS_IDLE) STATUS_LOCKED) STATUS_PARKED)STATUS_RUNNING)STATUS_SLEEPING)STATUS_STOPPED)STATUS_TRACING_STOP)STATUS_WAITING) STATUS_WAKING) STATUS_ZOMBIE)SUNOS)WINDOWS) AccessDenied)Error) NoSuchProcess)TimeoutExpired) ZombieProcess)debug)memoize_when_activated) wrap_numbersz/proc)_pslinux)IOPRIO_CLASS_BE)IOPRIO_CLASS_IDLE)IOPRIO_CLASS_NONE)IOPRIO_CLASS_RT) _pswindows)ABOVE_NORMAL_PRIORITY_CLASS)BELOW_NORMAL_PRIORITY_CLASS)HIGH_PRIORITY_CLASS)IDLE_PRIORITY_CLASS)NORMAL_PRIORITY_CLASS)REALTIME_PRIORITY_CLASS)CONN_DELETE_TCB) IOPRIO_HIGH) IOPRIO_LOW) IOPRIO_NORMAL)IOPRIO_VERYLOW)_psosx)_psbsd)_pssunos) CONN_BOUND) CONN_IDLE)_psaixz platform z is not supported)Gr.r/r1r-r0 version_info __version__r$r!r%r r&r'r*rr)r"r(r"r#r rrr r rrrr rr rAF_LINKrrrrrrrrrrrrrr+r,rProcessPopen pid_existspids process_iter wait_procsvirtual_memory swap_memory cpu_times cpu_percentcpu_times_percent cpu_count cpu_statsnet_io_countersnet_connections net_if_addrs net_if_statsdisk_io_countersdisk_partitions disk_usageusers boot_timerlimitRLIMzGiampaolo Rodola'z7.1.3c#2K|]}t|ywN)int).0nums @/opt/hc_python/lib64/python3.12/site-packages/psutil/__init__.py rms@)?#SX)?. monotonicversionzversion conflict: z C extension z.module was built for another version of psutilz (z instead of )z (different than __file__z%the existing psutil install directoryz9; you may try to 'pip uninstall psutil', manually remove z1 or clean the virtual env somehow, then reinstallppid_mapci}tD])} tj|j||<+|S#tt f$rY?wxYw)z{Return a {pid: ppid, ...} dict for all running processes in one shot. Used to speed up Process.children(). )rR _psplatformrOppidr/r1)retpids rl _ppid_mapr{sW6C &..s388:C  "=1  s&;A  A ctj}t||z }|dkrdnd}tjj|j |S)z(Format seconds in a human readable form.iQz%H:%M:%Sz%Y-%m-%d %H:%M:%S)timeridatetime fromtimestampstrftime)secsnowsecs_agofmts rl _pprint_secsrsK ))+C3:H </*5HC    * *4 0 9 9# >>cdttj}||vrd|d|}t|y)z+Check net_connections()'s `kind` parameter.zinvalid kind argument z; valid ones are: N)tupler conn_tmap ValueError)kindkindsmsgs rl_check_conn_kindrs< '## $E 5&th.@Horc,eZdZdZdCdZdDdZdZdZeZdZ dZ d Z d Z e d Zej d ZdEd ZdZdZdZedZdZdZdZdZdZdZdZdCdZe redZ!dZ"dZ#dZ$e%e&jNdrdZ(e%e&jNd rdEd!Z)e%e&jNd"rdCd#Z*e%e&jNd$rdCd%Z+e%e&jNd&rd'Z,e%e&jNd(rd)Z-e.rd*Z/d+Z0d,Z1e%e&jNd-rd.Z2dDd/Z3dCd0Z4ed1Z5ed2Z6d3Z7dFd4Z8e%e&jNd5rdGd6Z9d7Z:dHd8Z;ee rd<Z?d=Z@d>ZAd?ZBd@ZCdAZDdCdBZEy)IrOaRepresents an OS process with the given PID. If PID is omitted current process PID (os.getpid()) is used. Raise NoSuchProcess if PID does not exist. Note that most of the methods of this class do not make sure that the PID of the process being queried has been reused. That means that you may end up retrieving information for another process. The only exceptions for which process identity is pre-emptively checked and guaranteed are: - parent() - children() - nice() (set) - ionice() (set) - rlimit() (set) - cpu_affinity (set) - suspend() - resume() - send_signal() - terminate() - kill() To prevent this problem for all other methods you can use is_running() before querying the process. Nc&|j|yrh)_init)selfrzs rl__init__zProcess.__init__8s  3rc|tj}n6|dkrd|d}t| tjj |||_d|_ d|_ d|_ d|_ d|_ d|_tj |_d|_tj&||_d|_d|_t.|_|j2df|_ |j7|_y#t $r}d}t|||d}~wwxYw#t8$rYyt:$rYyt$r|sd}t||dd|_ YywxYw) Nrz$pid must be a positive integer (got rszprocess PID out of rangerFzprocess PID not foundT)osgetpidrrwcextcheck_pid_range OverflowErrorr/_pid_name_exe _create_time_gone _pid_reused_hash threadingRLock_lock_ppidrO_proc_last_sys_cpu_times_last_proc_cpu_times _SENTINEL _exitcoderz_ident _get_identr-r1)rrz _ignore_nsprerrs rlrz Process._init;sP ;))+CQw>Z   ,".t/@/@"AY%%))'' DJJLALDAqaS! >;K$5rc|jS)zThe process PID.)rrs rlrzz Process.pidsyyrc#K|j5t|drdn |jj||jj||j j|t r|jj||jjd|jj||jj||j j|t r|jj||jjdddy#|jj||jj||j j|t r|jj||jjwxYw#1swYyxYww)a#Utility context manager which considerably speeds up the retrieval of multiple process information at the same time. Internally different process info (e.g. name, ppid, uids, gids, ...) may be fetched by using the same routine, but only one information is returned and the others are discarded. When using this context manager the internal routine is executed once (in the example below on name()) and the other info are cached. The cache is cleared when exiting the context manager block. The advice is to use this every time you retrieve more than one information about the process. If you're lucky, you'll get a hell of a speedup. >>> import psutil >>> p = psutil.Process() >>> with p.oneshot(): ... p.name() # collect multiple info ... p.cpu_times() # return cached value ... p.cpu_percent() # return cached value ... p.create_time() # return cached value ... >>> _cacheN) rhasattrrWcache_activate memory_inforxruidsr oneshot_entercache_deactivate oneshot_exitrs rlrzProcess.oneshotsR6ZZtX& .NN11$7$$33D9II,,T2 006JJ,,.NN33D9$$55d;II..t4 2248JJ++-MZBNN33D9$$55d;II..t4 2248JJ++-MZs6 G%GBE3B G? G%BGGG"G%c Jt}|t|tttt fsdt |}t|t |}||z }|rJdjt|dkDrdnddjtt|}t|i}|xs|}|j5|D]-} |dk(r |j} nt!||} | } | ||</ ddd|S#t"t$f$r|} Y%t&$r|rY[wxYw#1swY|SxYw) aUtility method returning process information as a hashable dictionary. If *attrs* is specified it must be a list of strings reflecting available Process class' attribute names (e.g. ['cpu_times', 'name']) else all public (read only) attributes are assumed. *ad_value* is the value which gets assigned in case AccessDenied or ZombieProcess exception is raised when retrieving that particular process information. Nzinvalid attrs type zinvalid attr name{} {}rsrqrrz)_as_dict_attrnamesrlistrset frozensettype TypeErrorrlenrmapreprrrrzgetattrr-r1NotImplementedError) rattrsad_value valid_namesr invalid_namesretdictlsrrymeths rlas_dictzProcess.as_dict s.)  edE3 %BC+DK=9n$JE!K/M.55}-1CrIIc$ 67!o%  !k \\^u}"hh&tT2"f!$ !$%m4#"C* $s<6D=%C4"D4DD DDDDD"c"ttn td}|j|k(ry|j}|Et |jj } t |}|j |kr|Syy#t $rYywxYw)zReturn the parent process as a Process object pre-emptively checking whether PID has been reused. If no parent is known return None. Nr) _LOWEST_PIDrRrzrxrOrr/)r lowest_pidrx proc_ctimeparents rlrzProcess.parentOs %0$;[ 88z !yy{  !*668J  %%':5!M6 !  s B B Bcvg}|j}|$|j||j}|$|S)zReturn the parents of this process as a list of Process instances. If no parents are known return an empty list. )rappend)rparentsprocs rlrzProcess.parentses@{{} NN4 ;;=Drc2|js |jry |t|jk7|_|jr4tj |jt |jy#t$rYyt $r d|_YywxYw)zReturn whether this process is running. It also checks if PID has been reused by another process, in which case it will remove the process from `process_iter()` internal cache and return False. FT)rrrOrz _pids_reusedaddr/r1rs rlrzProcess.is_runningps ::))  $wtxx'88D   *#DHH--  DJ sAA99 BBBc|jtr|jjS|jxs|jj|_|jS)z`The process parent PID. On Windows the return value is cached after first call. )rrrrxrrs rlrxz Process.ppidsI !!# ::??$ $8tzz'8DJ:: rctr|j |jS|jj}trWt |dk\rI |j }|r6tjj|d}|j|r|} ||_||j_|S#ttf$rY+wxYw)z>The process name. The return value is cached after first call.r) r,rrrrrcmdlinerpathbasename startswithr-r1)rrr  extended_names rlrz Process.names tzz-:: zz  SY"_ -,,.$&GG$4$4WQZ$@M$//5,   !-0    sB00CCcfd}j: jj}|s ||}|_jSjS#t$rY*wxYw#t$r}||cYd}~Sd}~wwxYw)zThe process executable as an absolute path. May also be an empty string. The return value is cached after first call. cbj}|rttdryttdri|d}tjj |rEtjj |r&tj |tjr|St|tr||S)NaccessX_OKr) r rrr isabsisfilerrrr-)fallbackr exers rlguess_itzProcess.exe..guess_its{llnG72x0WR5Haj GGMM#&s+ #rww/J(L1OrN)r)rrrr-)rrrrs` rlrz Process.exes  & 99  jjnn&&4  yytyy(  .-- .s.A( A A%$A%( B1A?9B?Bc6|jjS)z3The command line this process has been called with.)rr rs rlr zProcess.cmdlineszz!!##rcb |jjS#t$r tcYSwxYw)z2The process current status as a STATUS_* constant.)rrr1r*rs rlrzProcess.statuss/ !::$$& & !  !s ..ctrMt d}t||jj} tj |j S|jjS#t$rt|cYSwxYw)ztThe name of the user that owns the process. On UNIX this is calculated by using *real* process uid. z0requires pwd module shipped with standard python) rpwd ImportErrorrrealgetpwuidpw_nameKeyErrorstrrusername)rrreal_uids rlr!zProcess.usernamesw {H!#&&yy{''H %||H-555 ::&&( (  %8}$ %sA..BBcp|j|jj|_|jS)awThe process creation time as a floating point number expressed in seconds since the epoch (seconds since January 1, 1970, at midnight UTC). The return value, which is cached after first call, is based on the system clock, which means it may be affected by changes such as manual adjustments or time synchronization (e.g. NTP). )rrrrs rlrzProcess.create_times1    $ $ 6 6 8D    rc6|jjS)z6Process current working directory as an absolute path.)rcwdrs rlr%z Process.cwdszz~~rc||jjS|j|jj|y)z'Get or set process niceness (priority).N)rnice_getrnice_set)rvalues rlnicez Process.nices8 =::&&( (  % % ' JJ   &rc6|jjS)zVReturn process UIDs as a (real, effective, saved) namedtuple. )rrrs rlrz Process.uids s ::??$ $rc6|jjS)zVReturn process GIDs as a (real, effective, saved) namedtuple. )rgidsrs rlr-z Process.gids's::??$ $rc6|jjS)zVThe terminal associated with this process, if any, else None. )rterminalrs rlr/zProcess.terminal-s::&&( (rc6|jjS)zcReturn the number of file descriptors opened by this process (POSIX only). )rnum_fdsrs rlr1zProcess.num_fds3::%%' 'r io_countersc6|jjS)a Return process I/O statistics as a (read_count, write_count, read_bytes, write_bytes) namedtuple. Those are the number of read/write calls performed and the amount of bytes read and written by the process. )rr3rs rlr3zProcess.io_counters<s::))+ +r ionice_getc|)| d}t||jjS|j|jj ||S)aGet or set process I/O niceness (priority). On Linux *ioclass* is one of the IOPRIO_CLASS_* constants. *value* is a number which goes from 0 to 7. The higher the value, the lower the I/O priority of the process. On Windows only *ioclass* is used and it can be set to 2 (normal), 1 (low) or 0 (very low). Available on Linux and Windows > Vista only. z$'ioclass' argument must be specified)rrr5r ionice_set)rioclassr)rs rlionicezProcess.ioniceHsT$@C$S/)zz,,..))+zz,,We<$U3y/E+F%GH ++DTO>> import psutil >>> p = psutil.Process() >>> p.children() B, C, D >>> p.children(recursive=True) B, X, Y, C, D Note that in the example above if process X disappears process Y won't be listed as the reference to process A is lost. )rr{rOrzrrrr/r1r defaultdictrrpopr) r recursiverurryrzrxchildreverse_ppid_mapseenstack child_pidintimes rlchildrenzProcess.childrens4 !!#;TXX&224 %^^- T488# ' &):):)<<JJu-.L 5 +66t< %^^- T &--c2.5DXXJEiik$; !1#!6I  ' 2",u/@/@/B!B!JJu-!LL3"7& =*=98*=9s%)/E2)AF2FFFFc |duxr|dkD}||dkrd|d}t|txsd fd}|rX|}|jj}t j ||}|jj}nL|j }|j}|}|jj}||||_||_y|j|jz |j|jz z} ||z } ||_||_ | | z dz} | z} t| dS#t$rYywxYw) aReturn a float representing the current process CPU utilization as a percentage. When *interval* is 0.0 or None (default) compares process times to system CPU times elapsed since last call, returning immediately (non-blocking). That means that the first time this is called it will return a meaningful 0.0 value. When *interval* is > 0.0 compares process times to system CPU times elapsed before and after the interval (blocking). In this case is recommended for accuracy that this function be called with at least 0.1 seconds between calls. A value > 100.0 can be returned in case of processes running multiple threads on different CPU cores. The returned value is explicitly NOT split evenly between all available logical CPUs. This means that a busy loop process running on a system with 2 logical CPUs will be reported as having 100% CPU utilization instead of 50%. Examples: >>> import psutil >>> p = psutil.Process(os.getpid()) >>> # blocking >>> p.cpu_percent(interval=1) 2.0 >>> # non-blocking (percentage since last call) >>> p.cpu_percent(interval=None) 2.9 >>> Nrinterval is not positive (got rsrctzSrh)_timer)num_cpussrltimerz"Process.cpu_percent..timer)s8h& &rd) rrZrrWr}sleeprrusersystemroundZeroDivisionError)rintervalblockingrrdst1pt1st2pt2 delta_proc delta_timeoverall_cpus_percentsingle_cpu_percentrcs @rlrXzProcess.cpu_percents_F4':HsN  HqL28,a@CS/ !;#! ' 'C**&&(C JJx 'C**&&(C**C++C'C**&&(C{ck+.(,/)hh)cjj3::.EF 3Y #& $'! 0%/$;s#B ("6!@ +Q/ /)!  s%D>> E  E c6|jjS)a%Return a (user, system, children_user, children_system) namedtuple representing the accumulated process time, in seconds. This is similar to os.times() but per-process. On macOS and Windows children_user and children_system are always set to 0. )rrWrs rlrWzProcess.cpu_times]szz##%%rc6|jjS)aReturn a namedtuple with variable fields depending on the platform, representing memory information about the process. The "portable" fields available on all platforms are `rss` and `vms`. All numbers are expressed in bytes. )rrrs rlrzProcess.memory_infohszz%%''rc6|jjS)a]This method returns the same information as memory_info(), plus, on some platform (Linux, macOS, Windows), also provides additional metrics (USS, PSS and swap). The additional metrics provide a better representation of actual process memory usage. Namely USS is the memory which is unique to a process and which would be freed if the process was terminated right now. It does so by passing through the whole process address. As such it usually requires higher user privileges than memory_info() and is considerably slower. )rmemory_full_infors rlrxzProcess.memory_full_infosszz**,,rcttjj}||vrd|dt |}t ||tj jvr |jn |j}|}t||}txstj}|dkDsd|d}t ||t|z dzS)aCompare process memory to total physical system memory and calculate process memory utilization as a percentage. *memtype* argument is a string that dictates what type of process memory you want to compare against (defaults to "rss"). The list of available strings can be obtained like this: >>> psutil.Process().memory_info()._fields ('rss', 'vms', 'shared', 'text', 'lib', 'data', 'dirty', 'uss', 'pss') zinvalid memtype z; valid types are rz]can't calculate process memory percent because total physical system memory is not positive (rsre)rrwpfullmem_fieldsrrpmemrrxr _TOTAL_PHYMEMrUtotalfloat)rmemtype valid_typesrfunmetricsr) total_phymems rlmemory_percentzProcess.memory_percents;//778 + %"7+.+&)+ S/ !+**222   && %)%>(8(>(> a33?2B!E S/ !l++s22r memory_mapscr|jj}|r[i}|D]*}|d}|dd} ttd|||||<,t j }|Dcgc]}||g||c}St j}|Dcgc]}|| c}S#t$r|||<YwxYwcc}wcc}w)aReturn process' mapped memory regions as a list of namedtuples whose fields are variable depending on the platform. If *grouped* is True the mapped regions with the same 'path' are grouped together and the different memory fields are summed. If *grouped* is False every mapped region is shown as a single entity and the namedtuple will also include the mapped region's address space ('addr') and permission set ('perms'). Nc ||zSrhr)xys rlz%Process.memory_maps..sAr)rrrrrrw pmmap_grouped pmmap_ext) rgroupeditdtuplr numsntrs rlrzProcess.memory_mapss'')BD7D8D'"&s+=qw'M"N$ !..789qt4*!D'*q99 **(*+1A++ $'"&$':,sB"B/ B4B,+B,c6|jjS)zReturn files opened by process as a list of (path, fd) namedtuples including the absolute file name and file descriptor number. )r open_filesrs rlrzProcess.open_filess zz$$&&rcNt||jj|S)aTReturn socket connections opened by process as a list of (fd, family, type, laddr, raddr, status) namedtuples. The *kind* parameter filters for connections that match the following criteria: +------------+----------------------------------------------------+ | Kind Value | Connections using | +------------+----------------------------------------------------+ | inet | IPv4 and IPv6 | | inet4 | IPv4 | | inet6 | IPv6 | | tcp | TCP | | tcp4 | TCP over IPv4 | | tcp6 | TCP over IPv6 | | udp | UDP | | udp4 | UDP over IPv4 | | udp6 | UDP over IPv6 | | unix | UNIX socket (both UDP and TCP protocols) | | all | the sum of all the possible families and protocols | +------------+----------------------------------------------------+ )rrr]rrs rlr]zProcess.net_connectionss!, zz))$//rr]) replacementc&|j|S)Nr)r]rs rl connectionszProcess.connectionss###..rc|jdkrJ|j|j|j|j|j}}}|dk(r d}t | t j ||y#t$r8}trt|rt||||d|_ t|||d}~wt$r}t|||d}~wwxYw)Nrzpreventing sending signal to process with PID 0 as it would affect every process in the process group of the calling process (os.getpid()) instead of PID 0T)rzrrrrrkillProcessLookupErrorrrQr1rr/PermissionErrorr-)rsigrzrxrrrs rl _send_signalzProcess._send_signalsxx!| -TXX -#  % % '"hh DJJtCaxE !o% 7S!% 8z#(T48cA! #C.C7" 7"3-36 7s$(A?? C3B;; C CCctr|j|y|j|tjk7r4|j s$d}t |j|j||jj|y)zSend a signal *sig* to process pre-emptively checking whether PID has been reused (see signal module constants) . On Windows only SIGTERM is valid and is treated as an alias for kill(). zprocess no longer existsrN) rrrsignalSIGTERMrr/rzrr send_signal)rrrs rlrzProcess.send_signalsd    c "  % % 'fnn$T__->0#DHHdjjcBB JJ " "3 'rctr |jtjy|j |j j y)zSuspend process execution with SIGSTOP pre-emptively checking whether PID has been reused. On Windows this has the effect of suspending all process threads. N)rrrSIGSTOPrrsuspendrs rlrzProcess.suspends5    fnn -  % % ' JJ   rctr |jtjy|j |j j y)zResume process execution with SIGCONT pre-emptively checking whether PID has been reused. On Windows this has the effect of resuming all process threads. N)rrrSIGCONTrrresumers rlrzProcess.resumes5    fnn -  % % ' JJ   rctr |jtjy|j |j j y)zTerminate the process with SIGTERM pre-emptively checking whether PID has been reused. On Windows this is an alias for kill(). N)rrrrrrrrs rl terminatezProcess.terminate*s3    fnn -  % % ' JJOO rctr |jtjy|j |j j y)zjKill the current process with SIGKILL pre-emptively checking whether PID has been reused. N)rrrSIGKILLrrrrs rlrz Process.kill5s3    fnn -  % % ' JJOO rc||dk\s d}t||jtur |jS|jj ||_|jS)aWait for process to terminate and, if process is a children of os.getpid(), also return its exit code, else None. On Windows there's no such limitation (exit code is always returned). If the process is already terminated immediately return None instead of raising NoSuchProcess. If *timeout* (in seconds) is specified and process is still alive raise TimeoutExpired. To wait for multiple Process(es) use psutil.wait_procs(). rz"timeout must be a positive integer)rrrrwait)rtimeoutrs rlrz Process.wait?sS  w!|6CS/ ! >> *>> !1~~rrhFNN)rssTinet)Frr __qualname____doc__rrrr__repr__rrrrpropertyrz contextlibcontextmanagerrrrrrr3rxrrr rr!rr%r*rrr-r/r1rrwrOr3r9rerFrGrIr,rLrNrPrQr]rXrWrrxrrrr]rdeprecated_methodrrrrrrrrrrrlrOrOsC6-^!2F<H+*! ? @.@.D-^, :$>(T$!)$ ! '  %  %  %  )  ({""M2 ,{""L1 =,{""H- 7{""$67 =({""I. ({""I. (  , - ({""I. (HT[0z&&((- "3H{""M2 ,6'02W+<=/>/   72 ( !   rrO_>rrrrrerrrrr]rrrrcBeZdZdZdZdZdZdZdZdfd Z xZ S) rPaSame as subprocess.Popen, but in addition it provides all psutil.Process methods in a single class. For the following methods which are common to both classes, psutil implementation takes precedence: * send_signal() * terminate() * kill() This is done in order to avoid killing another process in case its PID has been reused, fixing BPO-6973. >>> import psutil >>> from subprocess import PIPE >>> p = psutil.Popen(["python", "-c", "print 'hi'"], stdout=PIPE) >>> p.name() 'python' >>> p.uids() user(real=1000, effective=1000, saved=1000) >>> p.username() 'giampaolo' >>> p.communicate() ('hi', None) >>> p.terminate() >>> p.wait(timeout=2) 0 >>> ctj|i||_|j|jjdy)NT)r) subprocessrP_Popen__subprocrrzrargskwargss rlrzPopen.__init__s5$))4:6: 4>>%%4 8rcxttttttjzSrh)rBrdirrPrrs rl__dir__z Popen.__dir__s&c#e*s:+;+;'<<=>>rcft|jdr|jj|S)N __enter__)rrrrs rlrzPopen.__enter__s% 4>>; / NN $ $ & rct|jdr|jj|i|S|jr|jj |j r|j j  |j r|j j |jy#|jwxYw)N__exit__)rrrstdoutclosestderrstdinrrs rlrzPopen.__exit__s 4>>: .*4>>**D;F; ;{{ !!#{{ !!# ::JJ$$&  s &B77C c tj||S#t$rN tj|j|cYS#t$r|jd|}t|dwxYwwxYw)Nz has no attribute )object__getattribute__AttributeErrorrr)rrrs rlrzPopen.__getattribute__sw 4**46 6 4 4..t~~tDD! 4**> $ $ 0>>,, ,gl7#$'! rrh) rrrrrrrrrr __classcell__)rs@rlrPrPfs+:9?  4rrPcJttj}|da|S)z&Return a list of current running PIDs.r)rBrwrRrrys rlrRrRs% !!# $Ca&K Jrcf|dkry|dk(rtr |tvStj|S)zReturn True if given PID exists in the current process list. This is faster than doing "pid in psutil.pids()" and should be preferred. rF)rrRrwrQ)rzs rlrQrQs6  Qw e df}%%c**rc# K fd} fd}tj tt}t j }||z }||z }|D] }|| t r1t j }td|||t r1 tt jttj|jz} | D].\}} | ||} || j||| _| 0 ay#t$r ||YHwxYw# awxYww)aReturn a generator yielding a Process instance for all running processes. Every new Process instance is only created once and then cached into an internal table which is updated every time this is used. Cache can optionally be cleared via `process_iter.cache_clear()`. The sorting order in which processes are yielded is based on their PIDs. *attrs* and *ad_value* have the same meaning as in Process.as_dict(). If *attrs* is specified as_dict() is called and the resulting dict is stored as a 'info' attribute attached to returned Process instance. If *attrs* is an empty list it will retrieve all process info (slow). c<t|}||j<|Srh)rOrz)rzrpmaps rlrzprocess_iter..addss|TXX rc*j|dyrh)rU)rzrs rlremovezprocess_iter..removes drz+refreshing Process instance for reused PID N)rr)_pmapcopyrrRkeysrrUr2rBrrdictfromkeysrrr/) rrrrabnew_pids gone_pidsrzrrrs @rlrSrSs%(  ::>> def on_terminate(proc): ... print("process {} terminated".format(proc)) ... >>> for p in procs: ... p.terminate() ... >>> gone, alive = wait_procs(procs, timeout=3, callback=on_terminate) >>> for p in alive: ... p.kill() c |j|}||js$||_j| |yyy#tt jf$rYywxYw)N)r)rrrrr0r)rrrcallbackgones rl check_gonezwait_procs..check_gone7sq #73J%T__->",'TN( .? 9 9:   sA A('A(rz(timeout must be a positive integer, got z callback z is not a callableg?)rrcallablerrbrminr) procsrrrralivedeadliner max_timeoutrs ` @rlrTrTsJ #7a<8 Bo 5D JEHX$6(%78n8g%   7a< DE *K"x&(2[Aa<4)4- % ( D tQ   JU $$rTcn|rtj}ntj}||dkrd}|S)alReturn the number of logical CPUs in the system (same as os.cpu_count()). If *logical* is False return the number of physical cores only (e.g. hyper thread CPUs are excluded). Return None if undetermined. The return value is cached after first call. If desired cache can be cleared like this: >>> psutil.cpu_count.cache_clear() Nr)rwcpu_count_logicalcpu_count_cores)logicalrys rlrZrZrs8++-))+ 37 JrcV|stjStjS)aReturn system-wide CPU times as a namedtuple. Every CPU time represents the seconds the CPU has spent in the given mode. The namedtuple's fields availability varies depending on the platform: - user - system - idle - nice (UNIX) - iowait (Linux) - irq (Linux, FreeBSD) - softirq (Linux) - steal (Linux >= 2.6.11) - guest (Linux >= 2.6.24) - guest_nice (Linux >= 3.2.0) When *percpu* is True return a list of namedtuples for each CPU. First element of the list refers to first CPU, second element to second CPU and so on. The order of the list is consistent across calls. )rwrW per_cpu_timesr@s rlrWrWs%, $$&&((**rr@cht|}tr |t|ddz}|t|ddz}|S)zWGiven a cpu_time() ntuple calculates the total CPU time (including idle time). guestr guest_nice)sumrr)timestots rl _cpu_tot_timers= e*C  wugq)) wulA.. JrcZt|}||jz}|t|ddz}|S)zlGiven a cpu_time() ntuple calculates the busy CPU time. We do so by subtracting all idle CPU times. iowaitr)ridler)rbusys rl_cpu_busy_timer s6  DEJJD GE8Q ''D Krc|j|jk(s J||fg}tjjD]8}t||t||z }t d|}|j |:tj|S)Nr)r{rw scputimesrmaxr)t1t2 field_deltasfield field_deltas rl_cpu_times_deltasrs :: #-b"X- #L&&..b%(72u+== ![) K(/  , //rcxtjj}|duxr|dkD}||dkrd|d}t|d}|sd|r t }t j |n!tj|xs t }t t|<||t|Sg}|r"t d}t j |n#tj|xs t d}t dt|<t|t|D]\}} |j||| |S) aReturn a float representing the current system-wide CPU utilization as a percentage. When *interval* is > 0.0 compares system CPU times elapsed before and after the interval (blocking). When *interval* is 0.0 or None compares system CPU times elapsed since last call or module import, returning immediately (non blocking). That means the first time this is called it will return a meaningless 0.0 value which you should ignore. In this case is recommended for accuracy that this function be called with at least 0.1 seconds between calls. When *percpu* is True returns a list of floats representing the utilization as a percentage for each CPU. First element of the list refers to first CPU, second element to second CPU and so on. The order of the list is consistent across calls. Examples: >>> # blocking, system-wide >>> psutil.cpu_percent(interval=1) 2.0 >>> >>> # blocking, per-cpu >>> psutil.cpu_percent(interval=1, percpu=True) [2.0, 1.0] >>> >>> # non-blocking (percentage since last call) >>> psutil.cpu_percent(interval=None) 2.9 >>> Nr_rr`rsct||}t|}t|} ||z dz}t|dS#t$rYywxYw)Nrerr_)rrr rirj)rr times_delta all_delta busy_delta busy_percs rl calculatezcpu_percent..calculatesY'B/ !+. #K0  '#i/36IA& &!  s8 AATr@) rcurrent_threadidentrrWr}rf_last_cpu_timesget_last_per_cpu_timeszipr rkrAtidrlrrrrytot1rs rlrXrXs"F  " " $ * *Ct#63H1 .xj:o '  B JJx  $$S)8Y[B({_S122 D)D JJx &**3/I9D3ID#,D#9C $ 3C 89FB JJyR( ): rcxtjj}|duxr|dkD}||dkrd|d}t|d}|sd|r t }t j |n!tj|xs t }t t|<||t|Sg}|r"t d}t j |n#tj|xs t d}t dt|<t|t|D]\}} |j||| |S) aSame as cpu_percent() but provides utilization percentages for each specific CPU time as is returned by cpu_times(). For instance, on Linux we'll get: >>> cpu_times_percent() cpupercent(user=4.8, nice=0.0, system=4.8, idle=90.5, iowait=0.0, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0) >>> *interval* and *percpu* arguments have the same meaning as in cpu_percent(). Nr_rr`rscg}t||}t|}dtd|z }|D]:}||z}t|d}t td|d}|j |<t j|S)NgY@rr_)rrrrirrrwr)rrrrrscaler field_percs rlrz$cpu_times_percent..calculateQs'B/ !+. Ay))&K$u,Jz1-JSj159J KK # ' $$d++rTr@) rrrrrWr}rf_last_cpu_times_2r _last_per_cpu_times_2r"rr#s rlrYrY>s#  " " $ * *Ct#63H1 .xl!<o,$  B JJx "&&s+:y{B!*#.s344 D)D JJx (,,S1KYd5KD%.d%;c"$ 5c :;FB JJyR( )< rc*tjS)zReturn CPU statistics.)rwr[rrrlr[r[ys  ""rcpu_freqcvtj}|r|Stt|}|dk(ry|dk(r|dSd\}}}d}|D]D}||jz }t r|j d}'||j z }||jz }F||z }|rdx} } n ||z } ||z } tj|| | S)a:Return CPU frequency as a namedtuple including current, min and max frequency expressed in Mhz. If *percpu* is True and the system supports per-cpu frequency retrieval (Linux only) a list of frequencies is returned for each CPU. If not a list with one element is returned. rNr)r_r_r_FT) rwr-rrcurrentrrrrscpufreq) rAryrccurrsminsmaxsset_nonecpur/min_max_s rlr-r-s""$ JSXH1}Q1v $1!tT CS[[(E#' CGGODCGGOD (*"&&D4(?D(?D''t<.Ks;$:qCF$:rnr) rrrwr` _wrap_numbersrrrArr"values)r?nowraprrawdictrdiskfieldss rlr`r`s@',T' "F**4V4G r&$& )BC i 9B#MMOLD&KGDM,;C)9$:;<>62GCL+~~W^^5E0FG0F1A0FGHHGsBrJcBt|tj|S)aReturn system-wide socket connections as a list of (fd, family, type, laddr, raddr, status, pid) namedtuples. In case of limited privileges 'fd' and 'pid' may be set to -1 and None respectively. The *kind* parameter filters for connections that fit the following criteria: +------------+----------------------------------------------------+ | Kind Value | Connections using | +------------+----------------------------------------------------+ | inet | IPv4 and IPv6 | | inet4 | IPv4 | | inet6 | IPv6 | | tcp | TCP | | tcp4 | TCP over IPv4 | | tcp6 | TCP over IPv6 | | udp | UDP | | udp4 | UDP over IPv4 | | udp6 | UDP over IPv6 | | unix | UNIX socket (both UDP and TCP protocols) | | all | the sum of all the possible families and protocols | +------------+----------------------------------------------------+ On macOS this function requires root privileges. )rrwr]rs rlr]r]s4T  & &t ,,rc|tj}|jdtjt }|D]\}}}}}} t j|}|tjk(r;trdnd}|j|dkr||dz }|j|dkrtj|||||} trM|t j t j"hvr+ tj$| }|| j'|  ||j-| t/|S#t$rStr|dk(rtj}n3ttdr#|tjk(rtj}Y6wxYw#t($r} t+| Yd } ~ d } ~ wwxYw) a*Return the addresses associated to each NIC (network interface card) installed on the system as a dictionary whose keys are the NIC names and value is a list of namedtuples for each address assigned to the NIC. Each namedtuple includes 5 fields: - family: can be either socket.AF_INET, socket.AF_INET6 or psutil.AF_LINK, which refers to a MAC address. - address: is the primary address and it is always set. - netmask: and 'broadcast' and 'ptp' may be None. - ptp: stands for "point to point" and references the destination address on a point to point interface (typically a VPN). - broadcast: and *ptp* are mutually exclusive. Note: you can have more than one address of the same family associated with each interface. c |dS)Nrrrs rlrznet_if_addrs..sqtr)keyrN:-00N) broadcast)rwr^sortrrTrsocket AddressFamilyrr,rNrrcountrsnicaddrAF_INETAF_INET6broadcast_addr_replace Exceptionr2rr) rawlistryrfamaddrmaskrXptp separatorrrs rlr^r^s$&&(G LL^L$  ! !$ 'C18-c4y# *&&s+C +%% % %#I**Y'!+9+R((**Y'!+  c4y# > sv~~v?? 5#2226 (KK)K4 D G29J 9E *3"9!)) Y/C;;N;N4N ")) *4 c  s+D>3F>AFF F;& F66F;c*tjS)aReturn information about each NIC (network interface card) installed on the system as a dictionary whose keys are the NIC names and value is a namedtuple with the following fields: - isup: whether the interface is up (bool) - duplex: can be either NIC_DUPLEX_FULL, NIC_DUPLEX_HALF or NIC_DUPLEX_UNKNOWN - speed: the NIC speed expressed in mega bits (MB); if it can't be determined (e.g. 'localhost') it will be set to 0. - mtu: the maximum transmission unit expressed in bytes. )rwr_rrrlr_r_s  # # %%rsensors_temperaturesc fd}tjt}tj}|j D]p\}}|s |j d\}}}} ||}||}|| } |r| s|} n| r|s| }||jtj|||| |rhrt|S)a<Return hardware temperatures. Each entry is a namedtuple representing a certain hardware sensor (it may be a CPU, an hard disk or something else, depending on the OS and its configuration). All temperatures are expressed in celsius unless *fahrenheit* is set to True. c:|rt|dzdz dzS|Sy)N rV )r)n fahrenheits rlconvertz%sensors_temperatures..convert s,}2<a1 q(B.C!Crr) rrTrrwrjrrUrrshwtempr) rprqryrFrrDlabelr/highcriticals ` rlrjrjs D%%d+224#MMOLD&17A.wh!'*t}"8,#Hd#DD   OOE7D(C, Cyr sensors_fansc*tjS)zReturn fans speed. Each entry is a namedtuple representing a certain hardware sensor. All speed are expressed in RPM (rounds per minute). )rwrvrrrlrvrv s ''))rsensors_batteryc*tjS)aReturn battery information. If no battery is installed returns None. - percent: battery power left as a percentage. - secsleft: a rough approximation of how many seconds are left before the battery runs out of power. May be POWER_TIME_UNLIMITED or POWER_TIME_UNLIMITED. - power_plugged: True if the AC power cable is connected. )rwrxrrrlrxrx- s**,,rc*tjS)a!Return the system boot time expressed in seconds since the epoch (seconds since January 1, 1970, at midnight UTC). The returned value is based on the system clock, which means it may be affected by changes such as manual adjustments or time synchronization (e.g. NTP). )rwrdrrrlrdrdA s  ""rc*tjS)aReturn users currently connected on the system as a list of namedtuples including the following fields. - user: the name of the user - terminal: the tty or pseudo-tty associated with the user, if any. - host: the host name associated with the entry, if any. - started: the creation time as a floating point number expressed in seconds since the epoch. )rwrcrrrlrcrcK s    rc*tjS)zjReturn a generator yielding a WindowsService instance for all Windows services installed. )rwwin_service_iterrrrlr}r}_ s++--rc,tj|S)zjGet a Windows service by *name*. Raise NoSuchProcess if no service with such name exists. )rwwin_service_get)rs rlrre s**400rcddl}t||j_tj j t|y)zZEnable or disable PSUTIL_DEBUG option, which prints debugging messages to stderr. rN)psutil._commonboolr PSUTIL_DEBUGrwr set_debug)r)psutils rl _set_debugro s/"&u+FNNtE{+rrrr)NF)FTr)rrrr~ functoolsrrrZrsysrr}rrrqrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4rC PROCFS_PATHr5rwr6r7r8r9r:_psutil_windowsr;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKplatformrr__all__extend__extra__all__rrOglobals_globalsrrrr isupperrrrN __author__rMrsplitrLrbr}rrrrireplacertrrr rrrwhatrur{rrrrPrRrQrrrrS cache_clearrTrZrWrrrrbr!rr rrXrr*r+rYr[r-r8rUrVrbrar`partialr\r]r^r_rjrvrxrdrcr}rrrQs0rlrsJ     $!%##" ""#$$'') & ""#$#(#""!"#"+2K))++) +<<4468+'&)* '' )$#K'K cll^#4 5C c ""- b{))* ;  )yH E[%%&   F # %k&6&6>HUO NN5 !' %     @):):3)?@@ {DII .  H {3#$i) {//88;= IC ;;C{+ HHT#k..6678 9 A3l;-q11 ";-q11 / D  Ftf MMC >>C c  ; #$$I ?wwz!7|!1<<#4 : A|LGLh+$ u 3l1 #I  X%@.+8/y//177EO    "(()4*@&  0*I\$((*+0028v#  ; #&=P NN: 2| \ Br< ]]  ++  NN< 8v %*( ,,=^ 1y008 (F$$IN0i//7'E#-<:z &* ;./ D NN)* ;'* NN>" ;)* - NN$%# $ . 1,mJ Cj)^ OsGYYYY*$Y&Y'YYY$#Y$'Y21Y2