def name_by_pid(pid):
 process_name = None
 if stem.util.proc.is_available():
  try:
   process_name = stem.util.proc.stats(pid, stem.util.proc.Stat.COMMAND)[0]
  except IOError:
   pass
 if (not process_name):
  try:
   results = call((GET_NAME_BY_PID_PS % pid))
  except OSError:
   results = None
  if (results and (len(results) == 2) and (results[0] == 'COMMAND')):
   process_name = results[1].strip()
 return process_name

def name_by_pid ( pid ) : process_name = None if stem . util . proc . is_available ( ) : try : process_name = stem . util . proc . stats ( pid , stem . util . proc . Stat . COMMAND ) [ 0 ] except IOError : pass if ( not process_name ) : try : results = call ( ( GET_NAME_BY_PID_PS % pid ) ) except OSError : results = None if ( results and ( len ( results ) == 2 ) and ( results [ 0 ] == 'COMMAND' ) ) : process_name = results [ 1 ] . strip ( ) return process_name
attempts to determine the name a given process is running under .