def lock_add_instance_common(self): payload = dmpv.lock_add_instance(u"普通") req_url = pu.devices_instance_urls()["add_dev_url"] r = requests.post(req_url, data=payload, cookies=self.ck) operate_time = time.strftime("%Y-%m-%d %H:%M:%S") self.result_check(r, operate_time, payload, "get_device_properties_by_name", payload["name"], self.lock_name, self.lock_model, self.lock_net_type, self.lock_id)
def add_home_provider(self): payload = hmpv.add_house_provider() CustomerManage.home_provider_name = payload["providerName"] req_url = pu.house_manage_urls()["add_home_source_provider_url"] aa = self.ck r = requests.post(req_url, json=payload, cookies=self.ck) operate_time = datetime.datetime.now().strftime("%H:%M:%S.%f") # 检查provider name self.result_check(r, operate_time, payload, payload["providerName"], query_type="get_home_provider_info")
def update_space(self): payload = hmpv.update_space() payload["homeSourceId"] = CustomerManage.home_source_id payload["id"] = db.house_source_sql("get_space_id", CustomerManage.home_no) req_url = pu.house_manage_urls()["update_space_url"] r = requests.post(req_url, json=payload, cookies=self.ck) CustomerManage.home_source_id = payload["homeSourceId"] operate_time = datetime.datetime.now().strftime("%H:%M:%S.%f") self.result_check(r, operate_time, payload, CustomerManage.space_id, query_type="get_space_info")
def upload_image(img_path): upload_url = pu.device_urls()["upload_image_url"] with open(img_path, "rb") as image_file: encoded_img = base64.b64encode(image_file.read()) r = requests.post(upload_url, data={ "base64": "data:image/png;base64," + encoded_img.decode("utf-8") }, cookies=DeviceManageParamsValue.ck) rsp = json.loads(r.text) img = rsp['image'] return img
def update_house_source(self): payload = hmpv.update_house_source() payload["id"] = db.house_source_sql("get_home_source_id", CustomerManage.home_source_name) payload["providerId"] = str(CustomerManage.provider_id) req_url = pu.house_manage_urls()["update_home_source_url"] r = requests.post(req_url, json=payload, cookies=self.ck) # 检查 homeSourceName, providerId,id,types,删除状态 operate_time = datetime.datetime.now().strftime("%H:%M:%S.%f") CustomerManage.home_source_name = payload["homeSourceName"] self.result_check(r, operate_time, payload, payload["homeSourceName"], query_type="get_home_source_info")
def add_house_source(self): payload = hmpv.add_house_source() payload["providerId"] = db.house_source_sql( "get_provider_name_and_id", CustomerManage.home_provider_name) req_url = pu.house_manage_urls()["add_home_source_url"] r = requests.post(req_url, json=payload, cookies=self.ck) CustomerManage.home_source_name = payload["homeSourceName"] CustomerManage.addrCode = payload["addrCode"] CustomerManage.provider_id = payload["providerId"] operate_time = datetime.datetime.now().strftime("%H:%M:%S.%f") self.result_check(r, operate_time, payload, payload["homeSourceName"], query_type="get_home_source_info")
def add_space(self): payload = hmpv.add_space() payload["homeSourceId"] = db.house_source_sql( "get_home_source_id", CustomerManage.home_source_name) req_url = pu.house_manage_urls()["add_space_url"] r = requests.post(req_url, json=payload, cookies=self.ck) CustomerManage.home_source_id = payload["homeSourceId"] CustomerManage.home_no = payload["homeNo"] # homelist 检查id,homeSourceId,homeNo,floorNum,del # 通过homeSourceId,homeNo确定space 的id CustomerManage.space_id = db_wc.house_manage_web_check( "get_space_id", payload["homeSourceId"], payload["homeNo"]) operate_time = datetime.datetime.now().strftime("%H:%M:%S.%f") self.result_check(r, operate_time, payload, CustomerManage.space_id, query_type="get_space_info")
def delete_home_provider(self): home_provide_id = hmpv.delete_house_provider() req_url = pu.house_manage_urls()["delete_home_source_provider"] + str( home_provide_id) + "/deleteRecordById" r = requests.get(req_url, cookies=self.ck) operate_time = datetime.datetime.now().strftime("%H:%M:%S.%f") query_result = db_wc.house_manage_web_check( "get_home_provider_info", CustomerManage.home_provider_name) # id,providerName,del,enterpriseAccountId payload = dict() payload["del_status"] = query_result[2] payload["id"] = query_result[0] self.result_check(r, operate_time, payload, CustomerManage.home_source_name, query_type="get_home_provider_info", del_home_source=True)
def delete_house_source(self): house_source_id = hmpv.delete_house_source() req_url = pu.house_manage_urls()["delete_home_source_url"] + str( house_source_id) + "/deleteRecordById" r = requests.get(req_url, cookies=self.ck) operate_time = datetime.datetime.now().strftime("%H:%M:%S.%f") # id,types,providerId,homeSourceName,del query_result = db_wc.house_manage_web_check( "get_home_source_info", CustomerManage.home_source_name) payload = dict() payload["homeSourceName"] = query_result[3] payload["providerId"] = query_result[2] payload["types"] = query_result[1] payload["del"] = query_result[4] self.result_check(r, operate_time, payload, CustomerManage.home_source_name, query_type="get_home_source_info", del_home_source=True)
def delete_space(self): space_id = hmpv.delete_space() req_url = pu.house_manage_urls()["delete_space_url"] + str( space_id) + "/deleteRecordById" r = requests.get(req_url, cookies=self.ck) operate_time = datetime.datetime.now().strftime("%H:%M:%S.%f") # 获取删除后的信息 payload = dict() query_result = db_wc.house_manage_web_check("get_space_info", space_id) # id,homeSourceId,homeNo,isPublic,floorNum,homeType,del payload["floorNum"] = query_result[4] payload["homeNo"] = query_result[2] payload["homeSourceId"] = query_result[1] payload["del_status"] = query_result[6] self.result_check(r, operate_time, payload, CustomerManage.space_id, query_type="get_space_info", del_space=True)
def get_cookies(): # 该方法中,如果从parameter_value 中引用payload,会产生环形引用错误,因此在这里写payload login_url = pu.login_url() payload = {"userName": Util.username, "password": Util.password} r = requests.post(login_url, json=payload) return r.cookies
def delete_user_group(self): payload = smpv.delete_user_group() req_url = pu.system_manage_urls()["delete_user_group_url"] r = requests.post(req_url, data=payload, cookies=self.ck) operate_time = datetime.datetime.now().strftime("%H:%M:%S.%f") self.result_check(r, operate_time, payload, ("id", payload["groupId"]), query_type="get_user_group")