3 BQw@sddlZddlZddlZddlZdBdCdDdEdFdGdHdIdJdKdLg ZdMdNdOdPdQdRdSdTdUdVdWg Zd"d#ZGd$d%d%eZeeZ eeZ yej dd&d'Z Wn e k rej dZ YnXe jZdd(d)d*gZd+Zd,Zd+e>d+Zd-d.Zd/d0Zd1d2Ze jZed3\ZZZZZZe jZdZd4d5Z d6d7Z!d8d9Z"d:d;Z#dkrddl&Z&e'e&j(d?krle)e&j(d+Z*nej+Z*e,d@e*e,dAe!e*dS)XNalpha*arm*;i*86"ia64*parisc* powerpc*s390*sparc*sh*!x86_64*32bit64bit:  cCsLtjd}tjd}x.|D]&\}}}tj||rtj||r|SqWdS)Nr)osunameplatformZ architecturefnmatch)Z syscall_listZarchbitsZcandidate_archZcandidate_bitsZ syscall_nrr(/usr/lib/python3.6/ioprio.pyfind_ioprio_syscall_number9s     r*c@seZdZddZdS)IoprioSetErrorc Cs0ytj||_Wntk r*||_YnXdS)N)r#strerrorerr TypeError)selfr-r(r(r)__init__CszIoprioSetError.__init__N)__name__ __module__ __qualname__r0r(r(r(r)r+Bsr+T) use_errnoZrtZbeidle c Cs:ytj|}Wntk r,tjd}YnX|t>|BS)N)PRIORITY_CLASSESindex ValueErrorIOPRIO_CLASS_SHIFT) ioprio_class ioprio_datar(r(r) ioprio_valueYs r>cCs t|t?S)N)r8r;)ioprior(r(r)r<`sr<cCs|t@S)N)IOPRIO_PRIO_MASK)r?r(r(r)r=csr=cCsJt|}tt|}|dd}|ttfkr2d|S|tkr>dSd|SdS)Nzrt/%dr5zbe/%d)sched_getscheduler getpriority PRIO_PROCESS SCHED_FIFOSCHED_RR SCHED_IDLE)pidZ schedulerniceZ ioprio_nicer(r(r)get_ioprio_from_schedls   rLcCsTtdkr dSttt|}|dkr$dSt|}|s8t|S|dkrD|Sd|t|fS)Nz?sysrz?errr5z%s/%d)__NR_ioprio_getsyscallIOPRIO_WHO_PROCESSr<rLr=)rJr?Z prio_classr(r(r)getxs rPc Csftdkrtdt||}tt|||dd}|dkrby tj}Wntk rXd}YnXt|dS)NzNo ioprio_set syscall foundT)r4rzrNctypesZ get_errnoAttributeError)ZwhichZwhor<r=Z ioprio_valretr-r(r(r) set_ioprios   rUcCst|ddkrt|d Sd|krT|jdr2d}n|jdr@d}t|jdd}n|dkrdd}d}d|t>|S) Nr?r6/zrt/zbe/r5)ord startswithintsplitr;)keyZshiftZprior(r(r)sort_keys   r^cCs6d|kr&|jd}|dt|dfS|dkr2dSdS)NrWrr6r5)r5r)NN)r\r[)Z ioprio_strr\r(r(r)to_class_and_datas  r___main__rXzpid:zioprio:)rrr)rrr)rrr)r rr )r rr )r rr)rrr)rrr)rrr)rrr)rrr)rrr)rrr)rrr)r rr)r rr)r rr)rrr)rrr)rrr )rrr)rrr!)-rRr&r#r%ZIOPRIO_GET_ARCH_SYSCALLZIOPRIO_SET_ARCH_SYSCALLr* Exceptionr+rMrQZCDLLZ ctypes_handler.rNr8rOr;r@r>r<r=rDrange SCHED_OTHERrGrH SCHED_BATCHZ SCHED_ISOrIrErFrLrPrUr^r_r1syslenargvr[rJgetpidprintr(r(r(r)sr