Пример #1
0
def authorize_device(props, prop):
    global generated_auth_token
    nl = Nanoleaf(device_ip)
    if nl.generate_auth_token():
        generated_auth_key = nl.auth_token
        s = obs.obs_properties_get(props, "auth_key")
        obs.obs_property_list_add_string(s, generated_auth_key,
                                         generated_auth_key)

        return True
    print('[OBS-Nanoleaf]: Unable to acquire Authorization!')
    print(
        '[OBS-Nanoleaf]: Please make sure to Hold the on-off button down for 5-7 seconds until the LED starts flashing in a pattern'
    )
Пример #2
0
 def auth(self):
     try:
         nlip = Nanoleaf(lis[0])
         tok = nlip.generate_auth_token()
         if tok == False:
             self.label_3.setText('Token Generation Error')
         else:
             self.label_3.setText(tok)
             with open('connect.txt', 'w') as f:
                 print('### FILE CLEAR ###')
             with open('connect.txt', 'a') as f:
                 res2 = lis[0]
                 lis.clear()
                 f.write(res2 + "\n")
                 f.write(tok + "\n")
                 lis.append(res2)
                 lis.append(tok)
                 print(f'### {res2} + {tok} RESET IN FILE ###')
                 print('generated')
     except Exception as e:
         self.label_3.setText(str(e))