def UploadData(node, data, mode=0600, filename=None):
  if filename:
    quoted_filename = utils.ShellQuote(filename)
    directory = utils.ShellQuote(os.path.dirname(filename))

    cmd = " && ".join([
      "mkdir -p %s" % directory,
      "cat > %s" % quoted_filename,
      "chmod %o %s" % (mode, quoted_filename)])
  else:
    cmd = " && ".join([
      'tmp=$(mktemp --tmpdir gnt.XXXXXX)',
      'chmod %o "${tmp}"' % mode,
      'cat > "${tmp}"',
      'echo "${tmp}"'])

  p = subprocess.Popen(GetSSHCommand(node, cmd),
                       shell=False,
                       stdin=subprocess.PIPE,
                       stdout=subprocess.PIPE)
  p.stdin.write(data)
  p.stdin.close()
  AssertEqual(p.wait(), 0)

  if filename:
    return filename
  else:
    return _GetCommandStdout(p).strip()
Test uninstall-rollback (using test package with a setup.py
dataset/ETHPy150Open ganeti/ganeti/qa/qa_utils.py/UploadData--crossover with--dataset/ETHPy150Open pypa/pip/tests/functional/test_install_upgrade.py/test_uninstall_rollback