docs: def shell_cmd(args, cwd=None):
    '''Returns stdout as string or None on failure
    '''
    if cwd is None:
      cwd = os.path.abspath('.')
    if not isinstance(args, (list, tuple)):
      args = [args]
    ps = Popen(args, shell=True, cwd=cwd, stdout=PIPE, stderr=PIPE,
               close_fds=True)
    stdout, stderr = ps.communicate()
    if ps.returncode != 0:
      if stderr:
        stderr = stderr.strip()
      raise IOError('Shell command %s failed (exit status %r): %s' %\
        (args, ps.returncode, stderr))
    return stdout.strip()