def get_pid_location(module):
 for dir in ['/var/run', '/var/lib/run', '/run', os.path.expanduser('~/')]:
  try:
   if (os.path.isdir(dir) and os.access(dir, (os.R_OK | os.W_OK))):
    return os.path.join(dir, '.accelerate.pid')
  except:
   pass
 module.fail_json(msg="couldn't find any valid directory to use for the accelerate pid file")

def get_pid_location ( module ) : for dir in [ '/var/run' , '/var/lib/run' , '/run' , os . path . expanduser ( '~/' ) ] : try : if ( os . path . isdir ( dir ) and os . access ( dir , ( os . R_OK | os . W_OK ) ) ) : return os . path . join ( dir , '.accelerate.pid' ) except : pass module . fail_json ( msg = "couldn't find any valid directory to use for the accelerate pid file" )
try to find a pid directory in the common locations .