def _copy_xauthority_file(self, directory):
""" Copy .Xauthority file to directory, if it exists in /home
"""
# If running under xvfb, as jenkins does,
# xsession will fail to start without xauthority file
# Thus if the Xauthority file is in the home directory
# make sure we copy it to our temp home directory
xauth = os.path.expanduser(os.path.join(os.environ.get('HOME'),
'.Xauthority'))
if os.path.isfile(xauth):
logger.debug("Copying .Xauthority to %s" % directory)
shutil.copyfile(
os.path.expanduser(os.path.join(os.environ.get('HOME'),
'.Xauthority')),
os.path.join(directory, '.Xauthority'))