Removes directory tree as a superuser.

  Args:
    dir_name: name of the directory to remove.

  This function is necessary to cleanup directories created from inside a
  Docker, since they usually written as a root, thus have to be removed as a
  root.

def sudo_remove_dirtree(dir_name):
  """Removes directory tree as a superuser.

  Args:
    dir_name: name of the directory to remove.

  This function is necessary to cleanup directories created from inside a
  Docker, since they usually written as a root, thus have to be removed as a
  root.
  """
  try:
    subprocess.check_output(['sudo', 'rm', '-rf', dir_name])
  except subprocess.CalledProcessError as e:
    raise WorkerError('Can''t remove directory {0}'.format(dir_name), e)