'Copy the binaries from the temporary unpack location.
We need to first stop the running service or we might not be able to write
on the binary. We then copy the entire directory where we are running from
into the location indicated by "Client.install_path".'

def RunOnce(self):

    self.StopPreviousService()
    executable_directory = os.path.dirname(sys.executable)
    install_path = config.CONFIG['Client.install_path']
    logging.info('Installing    binaries    %s    ->    %s', executable_directory, config.CONFIG['Client.install_path'])
    try:
        shutil.rmtree(install_path)
    except OSError:
        pass
    try:
        os.makedirs(install_path)
    except OSError:
        pass
    for (root, dirs, files) in os.walk(executable_directory):
        for name in dirs:
            src_path = os.path.join(root, name)
            relative_path = os.path.relpath(src_path, executable_directory)
            dest_path = os.path.join(install_path, relative_path)
            try:
                os.mkdir(dest_path)
            except OSError:
                pass
        for name in files:
            src_path = os.path.join(root, name)
            relative_path = os.path.relpath(src_path, executable_directory)
            dest_path = os.path.join(install_path, relative_path)
            shutil.copy(src_path, dest_path)
