def post(self): try: zwave.update_options(opt_parse.parse_args(strict=True)) except ZWaveException as e: return Ajax(msg="ZWaveException thrown: {}".format(str(e))) \ .set_state("options", OptionState.failed).render() p = zwave.raw_opts.device try: msg = "Could not open zwave serial device: {} [permissions?]".format( p) if p is None or not os.path.exists(p) or \ (not open(p, "rb").readable()) or \ (not open(p, "wb").writable()): print("bad device path: {}".format(p)) return ret_err(404, msg) except PermissionError as e: return ret_err(404, msg + " Exception: " + str(e)) try: zwave.set_options() except ZWaveException as e: return Ajax(msg="ZWaveException thrown: {}".format(str(e))) \ .set_state("options", OptionState.failed).render() return Ajax(data=dict(zwave.raw_opts.items())) \ .set_state("options", OptionState.locked).render()
def patch(self): msg = None try: zwave.update_options(opt_parse.parse_args(strict=True)) except ZWaveException as e: return Ajax(msg="ZWaveException thrown: {}".format(str(e))) \ .set_state("options", OptionState.failed).render() return Ajax(data=dict(zwave.raw_opts.items())) \ .set_state("options", OptionState.editable).render()