def get_pid_from_file(program_name, pid_files_dir=None):
 pidfile_path = get_pid_path(program_name, pid_files_dir)
 if (not os.path.exists(pidfile_path)):
  return None
 pidfile = open(get_pid_path(program_name, pid_files_dir), 'r')
 try:
  pid = int(pidfile.readline())
 except IOError:
  if (not os.path.exists(pidfile_path)):
   return None
  raise
 finally:
  pidfile.close()
 return pid

def get_pid_from_file ( program_name , pid_files_dir = None ) : pidfile_path = get_pid_path ( program_name , pid_files_dir ) if ( not os . path . exists ( pidfile_path ) ) : return None pidfile = open ( get_pid_path ( program_name , pid_files_dir ) , 'r' ) try : pid = int ( pidfile . readline ( ) ) except IOError : if ( not os . path . exists ( pidfile_path ) ) : return None raise finally : pidfile . close ( ) return pid
reads the pid from <program_name> .