Beispiel #1
0
        object = TemperatureI()
        adapter.add(object, ic.stringToIdentity("Temperature"))
        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(" ")
Beispiel #2
0
                        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"))
    sys.stdout.flush()
    print txt.bold(txt.green("Running"))

    thread = Thread(target=object.checkSensor)
    thread.start()
Beispiel #3
0
import x10
from Colors import Colors

txt = Colors()
status = 0
ic = None
try:
    sys.stdout.write(txt.warning("Connecting to x10server...\t"))
    sys.stdout.flush()
    ic = Ice.initialize(sys.argv)
    base = ic.stringToProxy(ic.getProperties().getProperty("x10view.Proxy"))
    net = x10.NetPrx.checkedCast(base)
    if not net:
        raise RuntimeError("Invalid proxy")

    print txt.green(txt.bold("Done"))
    while True:
        entry = raw_input(">> ")
        if entry == "show environment":
            print net.showEnvironment()
        elif entry.find("deactivate") != -1:
            words = entry.split(" ")
            net.setInactive(words[1])
        elif entry.find("activate") != -1:
            words = entry.split(" ")
            net.setActive(words[1])

except:
    traceback.print_exc()
    status = 1