Example #1
0
## Initialize HEYU system
sys.stdout.write(txt.warning("Initializing x10 system...\t"))
sys.stdout.flush()
proc = subprocess.Popen("sudo heyu start",
                        stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE,
                        shell=True)
(out, err) = proc.communicate()

try:
    ic = Ice.initialize(sys.argv)
    adapter = ic.createObjectAdapterWithEndpoints(
        "NetAdapter",
        ic.getProperties().getProperty("x10server.Endpoints"))
    if err != "":
        print txt.bold(txt.fail("Failed"))
        print txt.fail("Can't open tty line.  Check the permissions.")
        status = 1
        sys.exit(status)
    else:
        print txt.bold(txt.green("Done"))
    status = 0

    props = ic.getProperties().getPropertiesForPrefix("x10server")
    checkModules(props)

    object = NetI()
    adapter.add(object, ic.stringToIdentity("Net"))
    adapter.activate()

    sys.stdout.write(txt.warning("Listening client request...\t"))
Example #2
0
        adapter.activate()
    except:
        status = 1
        traceback.print_exc()

    sys.stdout.write(txt.warning("Monitoring sensor...\t"))
    sys.stdout.flush()
    p = subprocess.Popen("sudo pcsensor",
                         stdout=subprocess.PIPE,
                         stderr=subprocess.STDOUT,
                         shell=True)
    out = p.stdout.readline()
    if out.find("Couldn't find the USB device, Exiting") == -1:
        print txt.bold(txt.green("Running"))
    else:
        print txt.bold(txt.fail("Failed --> " + out))
        sys.exit()
    while True:
        p = subprocess.Popen("sudo pcsensor",
                             stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT,
                             shell=True)
        p.stdout.readline()
        internal = p.stdout.readline()
        ipieces = internal.split(" ")
        T = float(ipieces[3][:-2])
        TF = float(ipieces[2][:-2])
        external = p.stdout.readline()
        epieces = external.split(" ")
        T2 = float(epieces[3][:-2])
        TF2 = float(epieces[2][:-2])