view service/iot2/iot2_linux.nim @ 710:94610b5263e4

add browser_test server for playing with /graph resource Ignore-this: 6112c234b93e0fb99ffe918a022e5a49
author drewp@bigasterisk.com
date Mon, 03 Feb 2020 23:45:15 -0800
parents e3eceee54937
children
line wrap: on
line source

import nimpy

proc setup_python(): PyObject =
  let sys = pyImport("sys")
  discard sys.path.extend([
    ".", # for devices.py itself
    "build/py/lib/python3.7/site-packages" # for deeper imports
  ])

  pyImport("devices")

import json
import osproc
proc getSomeTemp(): float =
  let sensorsJson = execProcess("sensors", args=["-j"], options={poUsePath})
  let res = parseJson(sensorsJson)
  res["coretemp-isa-0000"]["Core 0"]["temp2_input"].getFloat





echo "iot2_linux starting"
echo getSomeTemp()
let devices = setup_python()
discard devices.hello()