正在显示
13 个修改的文件
包含
93 行增加
和
50 行删除
... | ... | @@ -35,6 +35,8 @@ class Api(ApiTemplate): |
35 | 35 | #注册地址匹配引擎服务 |
36 | 36 | if response.json().get("Type") == "AddServer": |
37 | 37 | response: requests.Response = requests.get("{}/Info".format(url),timeout=3) |
38 | + if response.status_code != 200: | |
39 | + raise Exception("服务引擎连接失败!") | |
38 | 40 | add_name = response.json().get("name") |
39 | 41 | service = Service( |
40 | 42 | guid=engine_guid, | ... | ... |
... | ... | @@ -70,11 +70,13 @@ class Api(ApiTemplate): |
70 | 70 | self.para["task_guid"] = task_guid |
71 | 71 | |
72 | 72 | response:requests.Response = requests.post(url,data=self.para) |
73 | - | |
74 | - if not response.json().get("result"): | |
75 | - raise Exception("由于{},提交任务失败!".format(response.json().get("msg"))) | |
73 | + if response.status_code == 200: | |
74 | + if not response.json().get("result"): | |
75 | + raise Exception("由于{},提交任务失败!".format(response.json().get("msg"))) | |
76 | + else: | |
77 | + task_writer.update_task({"task_pid": int(response.json().get("data"))}) | |
76 | 78 | else: |
77 | - task_writer.update_task({"task_pid": int(response.json().get("data"))}) | |
79 | + raise Exception("影像服务器连接失败!") | |
78 | 80 | except Exception as e: |
79 | 81 | try: |
80 | 82 | task_writer.update_task({"state": -1,"update_time":datetime.datetime.now(),"process": "创建失败"}) | ... | ... |
... | ... | @@ -71,12 +71,14 @@ class Api(ApiTemplate): |
71 | 71 | |
72 | 72 | response:requests.Response = requests.post(url,data=self.para) |
73 | 73 | |
74 | - if not response.json().get("result"): | |
75 | - raise Exception("由于{},影像服务修改失败!".format(response.json().get("msg"))) | |
76 | - | |
77 | - task_writer.update_task({"state":1,"update_time":datetime.datetime.now(),"process" : "创建完成"}) | |
78 | - task_writer.update_process("创建完成!") | |
79 | - | |
74 | + if response.status_code==200: | |
75 | + if not response.json().get("result"): | |
76 | + raise Exception("由于{},影像服务修改失败!".format(response.json().get("msg"))) | |
77 | + | |
78 | + task_writer.update_task({"state":1,"update_time":datetime.datetime.now(),"process" : "创建完成"}) | |
79 | + task_writer.update_process("创建完成!") | |
80 | + else: | |
81 | + raise Exception("影像服务器连接失败!") | |
80 | 82 | except Exception as e: |
81 | 83 | try: |
82 | 84 | task_writer.update_task({"state": -1,"update_time":datetime.datetime.now(),"process": "创建失败"}) | ... | ... |
... | ... | @@ -20,17 +20,21 @@ class Api(ApiTemplate): |
20 | 20 | |
21 | 21 | user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")), |
22 | 22 | data={"guid":self.para.get("guid")}) |
23 | - | |
24 | - if not user_req.json().get("result"): | |
25 | - raise Exception("服务不存在!") | |
23 | + if user_req.status_code == 200: | |
24 | + if not user_req.json().get("result"): | |
25 | + raise Exception("服务不存在!") | |
26 | + else: | |
27 | + raise Exception("影像服务器连接失败!") | |
26 | 28 | # 验证权限 |
27 | 29 | UserCheck.verify(user_req.json().get("data").get("service").get("creator")) |
28 | 30 | |
29 | 31 | url = "{}/API/Service/Delete".format(self.para.get("url")) |
30 | 32 | response:requests.Response = requests.post(url,data=self.para) |
31 | - | |
32 | - if not response.json().get("result"): | |
33 | - raise Exception("由于{},影像地图删除失败!".format(response.json().get("msg"))) | |
33 | + if response.status_code == 200: | |
34 | + if not response.json().get("result"): | |
35 | + raise Exception("由于{},影像地图删除失败!".format(response.json().get("msg"))) | |
36 | + else: | |
37 | + raise Exception("影像服务器连接失败!") | |
34 | 38 | res["result"] = True |
35 | 39 | except Exception as e: |
36 | 40 | raise e | ... | ... |
... | ... | @@ -20,15 +20,21 @@ class Api(ApiTemplate): |
20 | 20 | |
21 | 21 | user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")), |
22 | 22 | data={"guid":self.para.get("guid")}) |
23 | - if not user_req.json().get("result"): | |
24 | - raise Exception("服务不存在!") | |
23 | + if user_req.status_code == 200: | |
24 | + if not user_req.json().get("result"): | |
25 | + raise Exception("服务不存在!") | |
26 | + else: | |
27 | + raise Exception("影像服务器连接失败!") | |
25 | 28 | # 验证权限 |
26 | 29 | UserCheck.verify(user_req.json().get("data").get("service").get("creator")) |
27 | 30 | |
28 | 31 | url = "{}/API/Service/Edit".format(self.para.get("url")) |
29 | 32 | response:requests.Response = requests.post(url,data=self.para) |
30 | - if not response.json().get("result"): | |
31 | - raise Exception("由于{},影像地图修改失败!".format(response.json().get("msg"))) | |
33 | + if response.status_code == 200: | |
34 | + if not response.json().get("result"): | |
35 | + raise Exception("由于{},影像地图修改失败!".format(response.json().get("msg"))) | |
36 | + else: | |
37 | + raise Exception("影像服务器连接失败!") | |
32 | 38 | res["result"] = True |
33 | 39 | except Exception as e: |
34 | 40 | raise e | ... | ... |
... | ... | @@ -17,8 +17,11 @@ class Api(ApiTemplate): |
17 | 17 | try: |
18 | 18 | url = "{}/API/Service/Register".format(self.para.get("url")) |
19 | 19 | response:requests.Response = requests.post(url,data=self.para) |
20 | - if not response.json().get("result"): | |
21 | - raise Exception("由于{}影像地图注册失败!".format(response.json().get("msg"))) | |
20 | + if response.status_code == 200: | |
21 | + if not response.json().get("result"): | |
22 | + raise Exception("由于{}影像地图注册失败!".format(response.json().get("msg"))) | |
23 | + else: | |
24 | + raise Exception("影像服务器连接失败!") | |
22 | 25 | res["result"] = True |
23 | 26 | except Exception as e: |
24 | 27 | raise e | ... | ... |
... | ... | @@ -53,9 +53,12 @@ class Api(ApiTemplate): |
53 | 53 | resp: requests.Response = requests.post(map_service_register_url,data=json.dumps(para), |
54 | 54 | headers={'Content-Type':'application/json'},timeout=3 |
55 | 55 | ) |
56 | - resp.encoding="utf-8" | |
57 | - resp_json = resp.json() | |
58 | - if not resp_json["status"]=="1": | |
56 | + if resp.status_code == 200: | |
57 | + resp.encoding="utf-8" | |
58 | + resp_json = resp.json() | |
59 | + if not resp_json["status"]=="1": | |
60 | + raise Exception("调用矢量服务的修改服务接口失败!") | |
61 | + else: | |
59 | 62 | raise Exception("调用矢量服务的修改服务接口失败!") |
60 | 63 | |
61 | 64 | service_update["overview"] = resp_json["url"] | ... | ... |
... | ... | @@ -38,11 +38,14 @@ class Api(ApiTemplate): |
38 | 38 | resp: requests.Response = requests.post(map_service_register_url,data=json.dumps(para), |
39 | 39 | headers={'Content-Type':'application/json'},timeout=3 |
40 | 40 | ) |
41 | - resp.encoding="utf-8" | |
42 | - resp_json = resp.json() | |
43 | - if not resp_json["status"]=="1": | |
44 | - raise Exception("调用矢量服务的注册服务接口失败!") | |
45 | 41 | |
42 | + if resp.status_code == 200: | |
43 | + resp.encoding="utf-8" | |
44 | + resp_json = resp.json() | |
45 | + if not resp_json["status"]=="1": | |
46 | + raise Exception("调用矢量服务的注册服务接口失败!") | |
47 | + else: | |
48 | + raise Exception("调用矢量服务的注册服务接口失败!") | |
46 | 49 | # 并获得服务缩略图 |
47 | 50 | |
48 | 51 | service = Service( | ... | ... |
... | ... | @@ -43,9 +43,13 @@ class Api(ApiTemplate): |
43 | 43 | |
44 | 44 | edit_url = "{}/API/Service/Info".format(self.para.get("url")) |
45 | 45 | response:requests.Response = requests.post(edit_url,self.para) |
46 | - if not response.json().get("result"): | |
47 | - raise Exception("查询影像地图失败!") | |
48 | - res = response.json() | |
46 | + | |
47 | + if response.status_code == 200: | |
48 | + if not response.json().get("result"): | |
49 | + raise Exception("查询影像地图失败!") | |
50 | + res = response.json() | |
51 | + else: | |
52 | + raise Exception("影像服务器连接失败!") | |
49 | 53 | else: |
50 | 54 | pass |
51 | 55 | ... | ... |
... | ... | @@ -61,11 +61,15 @@ class Api(ApiTemplate): |
61 | 61 | url = "{}/API/Service/BaseMapList".format(ie.url) |
62 | 62 | response:requests.Response = requests.post(url,{"page_size":"9999","page_index":"0", |
63 | 63 | "bbox":bbox,"state":state}) |
64 | - if not response.json().get("result"): | |
65 | - raise Exception("获取影像地图失败!") | |
64 | + | |
65 | + if response.status_code == 200: | |
66 | + if not response.json().get("result"): | |
67 | + raise Exception("获取影像地图失败!") | |
68 | + else: | |
69 | + raw_json = response.json()["data"]["list"] | |
70 | + fit_services_json.extend(raw_json) | |
66 | 71 | else: |
67 | - raw_json = response.json()["data"]["list"] | |
68 | - fit_services_json.extend(raw_json) | |
72 | + pass | |
69 | 73 | |
70 | 74 | res["data"] = {} |
71 | 75 | res["data"]["count"] = len(fit_services_json) | ... | ... |
... | ... | @@ -34,15 +34,22 @@ class Api(ApiTemplate): |
34 | 34 | elif s_type == ServiceType.image_service.value: |
35 | 35 | user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")), |
36 | 36 | data={"guid": self.para.get("guid")}) |
37 | - if not user_req.json().get("result"): | |
38 | - raise Exception("服务不存在!") | |
37 | + | |
38 | + if user_req.status_code == 200: | |
39 | + if not user_req.json().get("result"): | |
40 | + raise Exception("服务不存在!") | |
41 | + else: | |
42 | + raise Exception("影像服务器连接失败!") | |
39 | 43 | # 验证权限 |
40 | 44 | UserCheck.verify(user_req.json().get("data").get("service").get("creator")) |
41 | 45 | |
42 | 46 | url = "{}/API/Service/State".format(self.para.get("url")) |
43 | 47 | response: requests.Response = requests.post(url, data=self.para) |
44 | - if not response.json().get("result"): | |
45 | - raise Exception("由于{},影像地图修改失败!".format(response.json().get("msg"))) | |
48 | + if response.status_code == 200: | |
49 | + if not response.json().get("result"): | |
50 | + raise Exception("由于{},影像地图修改失败!".format(response.json().get("msg"))) | |
51 | + else: | |
52 | + raise Exception("影像服务器连接失败!") | |
46 | 53 | res["result"] = True |
47 | 54 | |
48 | 55 | except Exception as e: | ... | ... |
... | ... | @@ -63,9 +63,13 @@ class Api(ApiTemplate): |
63 | 63 | tile_service_edit_url = "{}/dmap/api/manager/RegService".format(configure.dmap_engine) |
64 | 64 | |
65 | 65 | resp: Response = requests.post(tile_service_edit_url,data=json.dumps(para),headers={'Content-Type':'application/json'},timeout=3) |
66 | - resp.encoding="utf-8" | |
67 | - resp_json = resp.json() | |
68 | - if not resp_json["status"].__eq__("1"): | |
66 | + | |
67 | + if resp.status_code==200: | |
68 | + resp.encoding="utf-8" | |
69 | + resp_json = resp.json() | |
70 | + if not resp_json["status"].__eq__("1"): | |
71 | + raise Exception("调用电子地图的注册服务接口失败!") | |
72 | + else: | |
69 | 73 | raise Exception("调用电子地图的注册服务接口失败!") |
70 | 74 | |
71 | 75 | service_update["overview"] = resp_json["url"] | ... | ... |
... | ... | @@ -41,13 +41,12 @@ class Api(ApiTemplate): |
41 | 41 | resp: Response = requests.post(tile_service_register_url,data=json.dumps(para), |
42 | 42 | headers={'Content-Type':'application/json'},timeout=3 |
43 | 43 | ) |
44 | - | |
45 | - resp.encoding="utf-8" | |
46 | - resp_json = resp.json() | |
47 | - StructurePrint().print(para) | |
48 | - StructurePrint().print(resp_json) | |
49 | - | |
50 | - if not resp_json["status"]=="1": | |
44 | + if resp.status_code == 200: | |
45 | + resp.encoding="utf-8" | |
46 | + resp_json = resp.json() | |
47 | + if not resp_json["status"]=="1": | |
48 | + raise Exception("调用电子地图的注册服务接口失败!") | |
49 | + else: | |
51 | 50 | raise Exception("调用电子地图的注册服务接口失败!") |
52 | 51 | |
53 | 52 | service = Service( | ... | ... |
请
注册
或
登录
后发表评论