<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
ft`                 @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZ	ddl
Z
ddlZddlZejejd Ze
jdZd	d
 Zdd Zdd Zdd ZdS )z/Various utility functions, and a utility class.    )absolute_import)unicode_literals)format_number)_N
SC_CLK_TCKdnfc             C   s   t | t S )zConvert a number of jiffies to seconds. How many jiffies are in a second
    is system-dependent, e.g. 100 jiffies = 1 second is common.

    :param jiffies: a number of jiffies
    :return: the equivalent number of seconds
    )int_USER_HZ)Zjiffies r
   /usr/lib/python3.6/utils.pyjiffies_to_seconds   s    r   c             C   sj   | dkr0d| d	 | d
 d | d d | d f S | dkrVd| d | d d | d f S d| d | d f S )a  Return a human-readable string representation of the length of
    a time interval given in seconds.

    :param seconds: the length of the time interval in seconds
    :return: a human-readable string representation of the length of
      the time interval
    <      z%d day(s) %d:%02d:%02dz%d:%02d:%02dz	%02d:%02di  iQ i  iQ i  i  i  r
   )Zsecondsr
   r
   r   seconds_to_ui_time)   s    

r   c             C   s  t | } tjjd|   s:tjjd s:tjjd|   r>dS i }td|  v}xn|D ]f}|d dkrhqV|dd jdd}t|dk rqVtjj	|d d	|d< |d j
 ||d
 j
 j < qVW W dQ R X d|krdS d|krdS d}td4}x,|D ]$}|jdrt |tdd }P qW W dQ R X |dkr6dS td|  ^}|j j }|t|d  |d< tdtdtdtdtddj|d td|d< W dQ R X |S )z!Return info dict about a process.z/proc/%d/statusz
/proc/statz/proc/%d/statN   
z:	   z kBr   vmrssvmsizezbtime    
start_timeZRunningZSleepingZUninterruptibleZZombiezTraced/Stopped)RSDZTZUnknownstater   r   )r   ospathexistsopensplitlenr   utilZrtrimstriplower
startswithreadr   r   get)pidpsZstatus_filelinedataZ	boot_timeZ	stat_fileZps_statr
   r
   r   get_process_info<   sJ    
*



r.   c             C   s   t | }|s$td}tj||  dS td| |d f }tjd| tjtdtt|d d tt|d	 d  tttj |d
  }tjtdtj	j
|d
 | tjtd|d  dS )z0Output information about process holding a lock.z=Unable to find information about the locking process (PID %d)Nz$  The application with PID %d is: %snamez%sz    Memory : %5s RSS (%5sB VSZ)r   i   r   r   z    Started: %s - %s agoz    State  : %sr   )r.   r   loggerZcriticalr   r   r   timer   r$   Znormalize_time)r*   r+   msgZagor
   r
   r   show_lock_ownerl   s    

r3   )__doc__Z
__future__r   r   Zdnf.cli.formatr   Zdnf.i18nr   Zdnf.utilr   Zloggingr   r1   sysconfsysconf_namesr	   Z	getLoggerr0   r   r   r.   r3   r
   r
   r
   r   <module>   s   

0