def stream_in(p, data):
  if isinstance(data, str):
    data = data.encode()
  stdout, stderr = p.communicate(input=data)
  if p.returncode == 1:
    raise DatException('Node.js error: ' + stderr)
  elif p.returncode == 127:
    raise DatException("It looks like `dat` commandline is missing from PATH.\n",
                   "Are you sure you installed it?\n"
                   "Check http://dat-data.com for instructions")
  else:
    try:
      res = json.loads(stdout.decode())
      if type(res) == dict and res.get('error'):
        return on_error(res)
    except ValueError:
      res = {'stdout': stdout, 'stderr': stderr}

    return res
Constructor for Generator
dataset/ETHPy150Open karissa/datpy/datpy.py/stream_in--crossover with--dataset/ETHPy150Open acil-bwh/SlicerCIP/Scripted/attic/PicasaSnap/atom/__init__.py/Generator.__init__