a !c@sdZddlmZddlmZddlmZddlmZddlZ ddl Z ddl Z ddl Z e e jdZe dZd d Zd d Zd dZddZdS)z/Various utility functions, and a utility class.)absolute_import)unicode_literals) format_number)_N SC_CLK_TCKdnfcCs t|tS)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)Zjiffiesr 1/usr/lib/python3.9/site-packages/dnf/cli/utils.pyjiffies_to_secondssr cCsj|dkr0d|d|dd|dd|dfS|dkrVd|d|dd|dfSd|d|dfS)aReturn 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 iQz%d day(s) %d:%02d:%02di<z %d:%02d:%02dz %02d:%02dr )Zsecondsr r r seconds_to_ui_time)s  rcCst|}tjd|r4tjdr4tjd|s8dSi}td||}|D]f}|ddkr`qN|dddd}t|d krqNtj |dd |d<|d ||d  <qNWdn1s0Yd |vrdSd |vrdSd}td>}|D](}| drt|tdd}q(qWdn1s>0Y|durVdStd|h}| }|t|d|d<tdtdtdtdtdd|d td|d<Wdn1s0Y|S)z!Return info dict about a process.z/proc/%d/statusz /proc/statz /proc/%d/statN z: z kBrvmrssvmsizezbtime  start_timeZRunningZSleepingZUninterruptibleZZombiezTraced/Stopped)RSDZTZUnknownstate)rospathexistsopensplitlenrutilZrtrimstriplower startswithreadr rget)pidpsZ status_filelinedataZ boot_timeZ stat_fileZps_statr r r get_process_info<sR   <  (   (r.cCst|}|s$td}t||dStd||df}td|ttdtt|ddtt|d dttt|d }ttd tj |d |ttd |d dS)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: %snamez%sz Memory : %5s RSS (%5sB VSZ)rirrz Started: %s - %s agoz State : %sr) r.rloggerZcriticalrrrtimerr$Znormalize_time)r*r+msgZagor r r show_lock_ownerls"    r3)__doc__Z __future__rrZdnf.cli.formatrZdnf.i18nrZdnf.utilrZloggingrr1sysconf sysconf_namesr Z getLoggerr0r rr.r3r r r r s      0