Best Python code snippet using autotest_python
SystemInfo.py
Source:SystemInfo.py
...7 while fileExists("/dev/dvb/adapter0/video%d"%(idx), 'f'):8 idx += 19 return idx10SystemInfo["NumVideoDecoders"] = getNumVideoDecoders()11SystemInfo["PIPAvailable"] = SystemInfo["NumVideoDecoders"] > 1 and HardwareInfo().get_device_name() != "spark7162" and HardwareInfo().get_device_name() != "sagemcom88" and HardwareInfo().get_device_name() != "esi88" and HardwareInfo().get_device_name() != "nbox" and HardwareInfo().get_device_name() != "dsi87" and HardwareInfo().get_device_name() != "adb2850" and HardwareInfo().get_device_name() != "uhd88"12SystemInfo["CanMeasureFrontendInputPower"] = False13def countFrontpanelLEDs():14 leds = 015 if fileExists("/proc/stb/fp/led_set_pattern"):16 leds += 117 while fileExists("/proc/stb/fp/led%d_pattern" % leds):18 leds += 119 return leds20SystemInfo["12V_Output"] = False21SystemInfo["ZapMode"] = fileCheck("/proc/stb/video/zapmode") or fileCheck("/proc/stb/video/zapping_mode")22SystemInfo["NumFrontpanelLEDs"] = countFrontpanelLEDs()23SystemInfo["FrontpanelDisplay"] = fileExists("/dev/dbox/oled0") or fileExists("/dev/dbox/lcd0")24SystemInfo["FrontpanelDisplayGrayscale"] = fileExists("/dev/dbox/oled0")25SystemInfo["DeepstandbySupport"] = HardwareInfo().get_device_name() != "dm800" and HardwareInfo().get_device_name() != "sagemcom88" and HardwareInfo().get_device_name() != "esi88" and HardwareInfo().get_device_name() != "nbox" and HardwareInfo().get_device_name() != "dsi87" and HardwareInfo().get_device_name() != "adb2850" and HardwareInfo().get_device_name() != "uhd88"26SystemInfo["Fan"] = fileCheck("/proc/stb/fp/fan")27SystemInfo["FanPWM"] = SystemInfo["Fan"] and fileCheck("/proc/stb/fp/fan_pwm")28SystemInfo["StandbyLED"] = fileCheck("/proc/stb/power/standbyled")29SystemInfo["WakeOnLAN"] = not HardwareInfo().get_device_model().startswith("et8000") and fileCheck("/proc/stb/power/wol") or fileCheck("/proc/stb/fp/wol")30SystemInfo["HasExternalPIP"] = not HardwareInfo().get_device_model().startswith("et9") and fileCheck("/proc/stb/vmpeg/1/external")31SystemInfo["VideoDestinationConfigurable"] = fileExists("/proc/stb/vmpeg/0/dst_left")32SystemInfo["hasPIPVisibleProc"] = fileCheck("/proc/stb/vmpeg/1/visible")33SystemInfo["VFD_scroll_repeats"] = not HardwareInfo().get_device_model().startswith("et8500") and fileCheck("/proc/stb/lcd/scroll_repeats")34SystemInfo["VFD_scroll_delay"] = not HardwareInfo().get_device_model().startswith("et8500") and fileCheck("/proc/stb/lcd/scroll_delay")35SystemInfo["VFD_initial_scroll_delay"] = not HardwareInfo().get_device_model().startswith("et8500") and fileCheck("/proc/stb/lcd/initial_scroll_delay")36SystemInfo["VFD_final_scroll_delay"] = not HardwareInfo().get_device_model().startswith("et8500") and fileCheck("/proc/stb/lcd/final_scroll_delay")37SystemInfo["LcdLiveTV"] = fileCheck("/proc/stb/fb/sd_detach") or fileCheck("/proc/stb/lcd/live_enable")38SystemInfo["3DMode"] = fileCheck("/proc/stb/fb/3dmode") or fileCheck("/proc/stb/fb/primary/3d")39SystemInfo["3DZNorm"] = fileCheck("/proc/stb/fb/znorm") or fileCheck("/proc/stb/fb/primary/zoffset")...
main.py
Source:main.py
...13 logging.info("turning screen off")14 call(["vcgencmd", "display_power", "0"])15def on_connect(client, userdata, flags, rc ):16 client.publish(17 f"homeassistant/switch/{CONFIG.get_device_name()}/screen/config",18 f'{{"unique_id": "screen-{CONFIG.get_device_name()}", "name": "{CONFIG.get_device_name()} Screen", "device": {{"identifiers": ["{CONFIG.get_device_name()}"], "name": "{CONFIG.get_device_name()}"}}, "~": "homeassistant/switch/{CONFIG.get_device_name()}/screen", "availability_topic": "~/state", "command_topic": "~/set", "retain": true}}',19 retain=True,20 )21 client.publish(22 f"homeassistant/switch/{CONFIG.get_device_name()}/screen/state",23 "online",24 retain=True,25 )26 logging.info("Set mqtt toptic state to online")27 client.subscribe(f"homeassistant/switch/{CONFIG.get_device_name()}/screen/set")28def run(client: mqtt.Client):29 30 client.on_message = on_message31 client.on_connect = on_connect32 client.loop_forever()33def on_log(client, userdata, level, buf):34 #logger = logging.getLogger("mqtt")35 #logger.info(buf)36 pass37def main():38 client = mqtt.Client()39 client.enable_logger(logger=logging.getLogger("mqtt"))40 client.username_pw_set(CONFIG.get_username(), CONFIG.get_password())41 client.on_log = on_log 42 # set last will for mqtt broker43 client.will_set(44 retain=True,45 payload="offline",46 topic=f"homeassistant/switch/{CONFIG.get_device_name()}/screen/state",47 )48 client.connect(CONFIG.get_url(), CONFIG.get_port(), keepalive=10)49 run(client)50if __name__ == "__main__":...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!