From 49f57041cc9202ebfcc6b41a258642ca6dbd816b Mon Sep 17 00:00:00 2001 From: Roger James Date: Tue, 4 Feb 2020 12:39:52 +0000 Subject: [PATCH] Fixed inconsustent use of tabs --- code/lan_ewlink_api.py | 74 +++++++++++++++++++++--------------------- code/tool_01DIY85.py | 4 +-- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/code/lan_ewlink_api.py b/code/lan_ewlink_api.py index ff0dd18..801cc20 100644 --- a/code/lan_ewlink_api.py +++ b/code/lan_ewlink_api.py @@ -183,32 +183,32 @@ def performer_func(self, sub_id): elif self. command_num == 7: # 7 command("ROOT") ret=self.get_signal_intensity(ip=ip,port=port,sub_id=sub_id) - elif self. command_num==8: - #8命令(获取设备状态信息) - ret=self.get_dev_info_api(ip=ip,port=port,sub_id=sub_id) - elif self. command_num==9: - #9命令(解锁ota) - print("self.command_vrg==",self.command_vrg) - ret=self.set_unlock(ip=ip,port=port,sub_id=sub_id) - print("ret",ret) - if ret['error'] == 0: - #10命令(发送升级信息) - ret=self.set_ota_flash(sha256sum= self.command_vrg["sha256sum"], sever_ip= self.command_vrg["sever_ip"], sever_port=self. command_vrg["sever_port"], ip=ip, port=port, sub_id=sub_id) + elif self. command_num==8: + #8命令(获取设备状态信息) + ret=self.get_dev_info_api(ip=ip,port=port,sub_id=sub_id) + elif self. command_num==9: + #9命令(解锁ota) + print("self.command_vrg==",self.command_vrg) + ret=self.set_unlock(ip=ip,port=port,sub_id=sub_id) + print("ret",ret) + if ret['error'] == 0: + #10命令(发送升级信息) + ret=self.set_ota_flash(sha256sum= self.command_vrg["sha256sum"], sever_ip= self.command_vrg["sever_ip"], sever_port=self. command_vrg["sever_port"], ip=ip, port=port, sub_id=sub_id) return ret - + def send_data(self, send_url, send_data): - """ - send data to device by HTTP PORT - """ - #try: - print("send:",send_url,str(send_data)) - response =self.ht.postRequest(send_url,send_data) - print("response:",str(response)) - if response["result"]: - return json.loads(response["text"]) - else: - return 1 - + """ + send data to device by HTTP PORT + """ + #try: + print("send:",send_url,str(send_data)) + response =self.ht.postRequest(send_url,send_data) + print("response:",str(response)) + if response["result"]: + return json.loads(response["text"]) + else: + return 1 + def set_OUT(self, **info): """ Set the lights on and off @@ -232,10 +232,10 @@ def set_OUT(self, **info): data["sequence"] = str(int(time.time())) sub_id = info["sub_id"] data["deviceid"] = sub_id - if out_sta: - data["data"]= {"switch": "on"} - else: - data["data"]= {"switch": "off"} + if out_sta: + data["data"]= {"switch": "on"} + else: + data["data"]= {"switch": "off"} # 3. Call Http_API(postRequest) to send. return self.send_data(send_url=url, send_data=data) @@ -262,12 +262,12 @@ def set_power_up_state(self, **info): data["sequence"] = str(int(time.time())) sub_id = info["sub_id"] data["deviceid"] = sub_id - if(state== 0): - data["data"]= {"startup": "off"} - elif (state== 1): - data["data"]= {"startup": "on"} - elif (state== 2): - data["data"]= {"startup": "stay"} + if(state== 0): + data["data"]= {"startup": "off"} + elif (state== 1): + data["data"]= {"startup": "on"} + elif (state== 2): + data["data"]= {"startup": "stay"} # 3. Call Http_API(postRequest) to send. return self.send_data(send_url=url, send_data=data) @@ -376,7 +376,7 @@ def set_unlock(self, **info): data["sequence"] = str(int(time.time())) sub_id = info["sub_id"] data["deviceid"] = sub_id - data["data"]= { } + data["data"]= { } # 3. Call Http_API(postRequest) to send. return self.send_data(send_url=url, send_data=data) @@ -405,7 +405,7 @@ def set_ota_flash(self, **info): data["sequence"] = str(int(time.time())) sub_id = info["sub_id"] data["deviceid"] = sub_id - data["data"]= { } + data["data"]= { } # 3. Call Http_API(postRequest) to send. return self.send_data(send_url=url, send_data=data) @@ -422,4 +422,4 @@ def get_dev_info_api(self,**info): sub_id=info["sub_id"] data["deviceid"]=sub_id data["data"]= { } - return self.send_data(send_url=url, send_data=data) \ No newline at end of file + return self.send_data(send_url=url, send_data=data) diff --git a/code/tool_01DIY85.py b/code/tool_01DIY85.py index 308cd5e..6a81e23 100644 --- a/code/tool_01DIY85.py +++ b/code/tool_01DIY85.py @@ -6,7 +6,7 @@ Parses the user's input(lan_ewlink_api and Dialog_text). """ - +import os import sys import time from PySide2.QtGui import * @@ -430,7 +430,7 @@ def result_to_ui(self, result_str): return result_list = result_str.split("\n") print("The return value is received:", result_list) - self.send_result[result_list[0]]=eval(result_list[1]) + self.send_result[result_list[0]]=eval(result_list[1]) def run_detection(self, command_num, **comand_vrg):