예제 #1
0
def getRainTicks():
    global ticks
    global temperature
    os.system('rm -Rf '+json_rain_sensor)
    time.sleep(0.5)
    cmd = "rtl_433 -R 37 -E -F json:"+json_rain_sensor
    try:
        stdout=Proc(cmd).call(timeout=120).stdout
        time.sleep(0.5)
        with open(json_rain_sensor) as f:
            data = json.loads(f.readline())
        if "temperature_C" in data:
            temperature = float(data["temperature_C"])
        if "rain" in data:
            ticks = int(data["rain"])
    except:
        print(CRED+'[NOK] rtl_433 timed out'+CEND)
        from easyprocess import EasyProcess
        s=EasyProcess("lsusb").call().stdout
        for line in s.splitlines():
            if line.find('Realtek')!=-1:
                cmd = "sudo usb_reset /dev/bus/usb/"+line[4:7]+"/"+line[15:18]
                stdout=Proc(cmd).call().stdout
                print(cmd + ' ' +stdout)
    return ticks, temperature
예제 #2
0
 def backend_version(self):
     stdout = EasyProcess([PROGRAM, "-version"]).call().stdout
     s = stdout.splitlines()[0]
     return extract_version(s.replace("-", " "))
예제 #3
0
    gtk.gdk.flush()  # doesn't do anything here..

    for disp in disps:
        thisdisp = gtk.gdk.Display(disp[1])
        dispscr = thisdisp.get_default_screen()
        print("d {} {} {} {} {}".format(disp[1], thisdisp,
                                        thisdisp.get_n_screens(), dispscr,
                                        dispscr.get_n_monitors()))

    for disp in disps:
        os.environ["DISPLAY"] = disp[1]
        winlist = EasyProcess(
            'wmctrl -l').call().stdout  # prints according to current DISPLAY
        print("winlist: {}".format(winlist))
        # first, try remove the decoration/titlebar from all windows
        for line in iter(winlist.splitlines()):
            hexidstr = line.split()[0]  # split() no args, split on whitespace
            hexid = int(
                hexidstr, 0
            )  # "You must specify 0 as the base in order to invoke this prefix-guessing behavior"
            print("hex: {} {}".format(hexidstr, hexid))
            EasyProcess('./toggle-decorations ' + hexidstr).call()
        # to call with hex id, use wmctrl -i -r 0x00...
        # the nemo is/may be maximized, so we have to unmaximize it first
        EasyProcess('wmctrl -r tmp -b remove,maximized_horz').call()
        EasyProcess('wmctrl -r tmp -b remove,maximized_vert').call()
        EasyProcess('wmctrl -r tmp -e 0,0,0,{},{}'.format(
            int(wdeskhalf * wp1), int(hdeskhalf * hp1))).call()
        # Giggle/Terminal is not maximised, so we can manipulate it immediately:
        #  also, for some reason, the terminal is smaller in height than needed (maybe due to removed decorations?), so there's a bit of a gap
        EasyProcess([