parameters: ()
docstring: List info of all currently running processes emulating ps aux
      output.
docstring_summary: List info of all currently running processes emulating ps aux
      output.
docstring_tokens: List info of all currently running processes emulating ps aux output .
function: def test():
      """List info of all currently running processes emulating ps aux
      output.
      """
      import datetime
      from psutil._compat import print_
  
      today_day = datetime.date.today()
      templ = "%-10s %5s %4s %4s %7s %7s %-13s %5s %7s  %s"
      attrs = ['pid', 'cpu_percent', 'memory_percent', 'name', 'cpu_times',
               'create_time', 'memory_info']
      if _POSIX:
          attrs.append('uids')
          attrs.append('terminal')
      print_(templ % ("USER", "PID", "%CPU", "%MEM", "VSZ", "RSS", "TTY",
                      "START", "TIME", "COMMAND"))
      for p in process_iter():
          try:
              pinfo = p.as_dict(attrs, ad_value='')
          except NoSuchProcess:
              pass
          else:
              if pinfo['create_time']:
                  ctime = datetime.datetime.fromtimestamp(pinfo['create_time'])
                  if ctime.date() == today_day:
                      ctime = ctime.strftime("%H:%M")
                  else:
                      ctime = ctime.strftime("%b%d")
              else:
                  ctime = ''
              cputime = time.strftime("%M:%S",
                                      time.localtime(sum(pinfo['cpu_times'])))
              try:
                  user = p.username()
              except KeyError:
                  if _POSIX:
                      if pinfo['uids']:
                          user = str(pinfo['uids'].real)
                      else:
                          user = ''
                  else:
                      raise
              except Error:
                  user = ''
              if _WINDOWS and '\\' in user:
                  user = user.split('\\')[1]
              vms = pinfo['memory_info'] and \
                  int(pinfo['memory_info'].vms / 1024) or '?'
              rss = pinfo['memory_info'] and \
                  int(pinfo['memory_info'].rss / 1024) or '?'
              memp = pinfo['memory_percent'] and \
                  round(pinfo['memory_percent'], 1) or '?'
              print_(templ % (user[:10],
                              pinfo['pid'],
                              pinfo['cpu_percent'],
                              memp,
                              vms,
                              rss,
                              pinfo.get('terminal', '') or '?',
                              ctime,
                              cputime,
                              pinfo['name'].strip() or '?'))
function_tokens: def test ( ) : import datetime from psutil . _compat import print_ today_day = datetime . date . today ( ) templ = "%-10s %5s %4s %4s %7s %7s %-13s %5s %7s  %s" attrs = [ 'pid' , 'cpu_percent' , 'memory_percent' , 'name' , 'cpu_times' , 'create_time' , 'memory_info' ] if _POSIX : attrs . append ( 'uids' ) attrs . append ( 'terminal' ) print_ ( templ % ( "USER" , "PID" , "%CPU" , "%MEM" , "VSZ" , "RSS" , "TTY" , "START" , "TIME" , "COMMAND" ) ) for p in process_iter ( ) : try : pinfo = p . as_dict ( attrs , ad_value = '' ) except NoSuchProcess : pass else : if pinfo [ 'create_time' ] : ctime = datetime . datetime . fromtimestamp ( pinfo [ 'create_time' ] ) if ctime . date ( ) == today_day : ctime = ctime . strftime ( "%H:%M" ) else : ctime = ctime . strftime ( "%b%d" ) else : ctime = '' cputime = time . strftime ( "%M:%S" , time . localtime ( sum ( pinfo [ 'cpu_times' ] ) ) ) try : user = p . username ( ) except KeyError : if _POSIX : if pinfo [ 'uids' ] : user = str ( pinfo [ 'uids' ] . real ) else : user = '' else : raise except Error : user = '' if _WINDOWS and '\\' in user : user = user . split ( '\\' ) [ 1 ] vms = pinfo [ 'memory_info' ] and int ( pinfo [ 'memory_info' ] . vms / 1024 ) or '?' rss = pinfo [ 'memory_info' ] and int ( pinfo [ 'memory_info' ] . rss / 1024 ) or '?' memp = pinfo [ 'memory_percent' ] and round ( pinfo [ 'memory_percent' ] , 1 ) or '?' print_ ( templ % ( user [ : 10 ] , pinfo [ 'pid' ] , pinfo [ 'cpu_percent' ] , memp , vms , rss , pinfo . get ( 'terminal' , '' ) or '?' , ctime , cputime , pinfo [ 'name' ] . strip ( ) or '?' ) )