提交 a56d69a955f1347a6c36dedfc54359c73b6ead25
Merge branch 'master' of http://gitlab.ctune.cn/weijunh/DMapManager
正在显示
22 个修改的文件
包含
129 行增加
和
181 行删除
| @@ -164,7 +164,7 @@ class Api(ApiTemplate): | @@ -164,7 +164,7 @@ class Api(ApiTemplate): | ||
| 164 | 164 | ||
| 165 | for i in range(feature_defn.GetFieldCount()): | 165 | for i in range(feature_defn.GetFieldCount()): |
| 166 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) | 166 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 167 | - field_name = field_defn.GetName().lower() | 167 | + field_name = field_defn.GetName() |
| 168 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( | 168 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( |
| 169 | "") else field_defn.GetAlternativeName() | 169 | "") else field_defn.GetAlternativeName() |
| 170 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, | 170 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, |
| @@ -106,6 +106,7 @@ class Api(ApiTemplate): | @@ -106,6 +106,7 @@ class Api(ApiTemplate): | ||
| 106 | if not ds: | 106 | if not ds: |
| 107 | raise Exception("打开数据失败!") | 107 | raise Exception("打开数据失败!") |
| 108 | for i in range(ds.GetLayerCount()): | 108 | for i in range(ds.GetLayerCount()): |
| 109 | + | ||
| 109 | layer: Layer = ds.GetLayer(i) | 110 | layer: Layer = ds.GetLayer(i) |
| 110 | 111 | ||
| 111 | layer_name[layer.GetName()] = layer.GetName() | 112 | layer_name[layer.GetName()] = layer.GetName() |
| @@ -358,12 +358,16 @@ class ThisTask: | @@ -358,12 +358,16 @@ class ThisTask: | ||
| 358 | feature_defn: FeatureDefn = layer.GetLayerDefn() | 358 | feature_defn: FeatureDefn = layer.GetLayerDefn() |
| 359 | 359 | ||
| 360 | for i in range(feature_defn.GetFieldCount()): | 360 | for i in range(feature_defn.GetFieldCount()): |
| 361 | + | ||
| 361 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) | 362 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 362 | field_name = field_defn.GetName() | 363 | field_name = field_defn.GetName() |
| 364 | + | ||
| 363 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( | 365 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( |
| 364 | "") else field_defn.GetAlternativeName() | 366 | "") else field_defn.GetAlternativeName() |
| 367 | + | ||
| 365 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, | 368 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, |
| 366 | name=field_name, alias=field_alias, create_time=this_time, update_time=this_time) | 369 | name=field_name, alias=field_alias, create_time=this_time, update_time=this_time) |
| 370 | + | ||
| 367 | self.sys_session.add(column) | 371 | self.sys_session.add(column) |
| 368 | return table_guid | 372 | return table_guid |
| 369 | 373 |
| @@ -250,7 +250,7 @@ class Api(ApiTemplate): | @@ -250,7 +250,7 @@ class Api(ApiTemplate): | ||
| 250 | 250 | ||
| 251 | for i in range(feature_defn.GetFieldCount()): | 251 | for i in range(feature_defn.GetFieldCount()): |
| 252 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) | 252 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 253 | - field_name = field_defn.GetName().lower() | 253 | + field_name = field_defn.GetName() |
| 254 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( | 254 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( |
| 255 | "") else field_defn.GetAlternativeName() | 255 | "") else field_defn.GetAlternativeName() |
| 256 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, | 256 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, |
| @@ -337,7 +337,7 @@ class Api(ApiTemplate): | @@ -337,7 +337,7 @@ class Api(ApiTemplate): | ||
| 337 | # 增加列 | 337 | # 增加列 |
| 338 | for i in range(feature_defn.GetFieldCount()): | 338 | for i in range(feature_defn.GetFieldCount()): |
| 339 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) | 339 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 340 | - field_name = field_defn.GetName().lower() | 340 | + field_name = field_defn.GetName() |
| 341 | db_columns_names.append(field_name) | 341 | db_columns_names.append(field_name) |
| 342 | 342 | ||
| 343 | if field_name not in columns_names: | 343 | if field_name not in columns_names: |
| @@ -484,7 +484,7 @@ def add_spatail_table(database,pg_ds,sys_session,spatial_tables_names,this_time, | @@ -484,7 +484,7 @@ def add_spatail_table(database,pg_ds,sys_session,spatial_tables_names,this_time, | ||
| 484 | 484 | ||
| 485 | for i in range(feature_defn.GetFieldCount()): | 485 | for i in range(feature_defn.GetFieldCount()): |
| 486 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) | 486 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 487 | - field_name = field_defn.GetName().lower() | 487 | + field_name = field_defn.GetName() |
| 488 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( | 488 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( |
| 489 | "") else field_defn.GetAlternativeName() | 489 | "") else field_defn.GetAlternativeName() |
| 490 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, | 490 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, |
| @@ -571,7 +571,7 @@ def edit_spatial_table(pg_ds,sys_session,spatial_tables,db_tables_names,this_tim | @@ -571,7 +571,7 @@ def edit_spatial_table(pg_ds,sys_session,spatial_tables,db_tables_names,this_tim | ||
| 571 | # 增加列 | 571 | # 增加列 |
| 572 | for i in range(feature_defn.GetFieldCount()): | 572 | for i in range(feature_defn.GetFieldCount()): |
| 573 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) | 573 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 574 | - field_name = field_defn.GetName().lower() | 574 | + field_name = field_defn.GetName() |
| 575 | db_columns_names.append(field_name) | 575 | db_columns_names.append(field_name) |
| 576 | 576 | ||
| 577 | if field_name not in columns_names: | 577 | if field_name not in columns_names: |
| @@ -12,7 +12,7 @@ import platform | @@ -12,7 +12,7 @@ import platform | ||
| 12 | import datetime | 12 | import datetime |
| 13 | import uuid | 13 | import uuid |
| 14 | from app.util.component.UserCheck import UserCheck | 14 | from app.util.component.UserCheck import UserCheck |
| 15 | - | 15 | +import requests |
| 16 | class Api(ApiTemplate): | 16 | class Api(ApiTemplate): |
| 17 | api_name = "停止任务" | 17 | api_name = "停止任务" |
| 18 | def para_check(self): | 18 | def para_check(self): |
| @@ -35,11 +35,21 @@ class Api(ApiTemplate): | @@ -35,11 +35,21 @@ class Api(ApiTemplate): | ||
| 35 | exec_result = os.popen('taskkill.exe /pid:' + str(pid)) | 35 | exec_result = os.popen('taskkill.exe /pid:' + str(pid)) |
| 36 | 36 | ||
| 37 | else: | 37 | else: |
| 38 | - #分布式下,很难吧,还需要记录机器,分布式是不可行的 | ||
| 39 | - os.kill(pid,signal.SIGILL) | 38 | + if task.task_type == 5: |
| 39 | + url = "{}/API/Image/TaskKill".format(task.parameter) | ||
| 40 | + StructurePrint().print(url) | ||
| 41 | + response: requests.Response = requests.post(url, {"pid":pid}) | ||
| 42 | + if response.status_code == 200: | ||
| 43 | + if response.json()["result"]: | ||
| 44 | + pass | ||
| 45 | + else: | ||
| 46 | + raise Exception(response.json()["msg"]) | ||
| 47 | + else: | ||
| 48 | + raise Exception("影像服务器连接失败!") | ||
| 49 | + else: | ||
| 50 | + os.kill(pid,signal.SIGILL) | ||
| 40 | except Exception as e: | 51 | except Exception as e: |
| 41 | - StructurePrint.print("Kill task 失败") | ||
| 42 | - raise e | 52 | + StructurePrint().print("Kill task 失败") |
| 43 | 53 | ||
| 44 | #处理kill任务后的事情 | 54 | #处理kill任务后的事情 |
| 45 | self.fix_task(task) | 55 | self.fix_task(task) |
| @@ -21,7 +21,9 @@ class Api(ApiTemplate): | @@ -21,7 +21,9 @@ class Api(ApiTemplate): | ||
| 21 | task_guid = self.para.get("task_guid") | 21 | task_guid = self.para.get("task_guid") |
| 22 | msg = self.para.get("msg") | 22 | msg = self.para.get("msg") |
| 23 | task:Task = Task.query.filter_by(guid=task_guid) | 23 | task:Task = Task.query.filter_by(guid=task_guid) |
| 24 | - task.update(json.loads(self.para.get("update"))) | 24 | + update = json.loads(self.para.get("update")) |
| 25 | + update["update_time"] = datetime.datetime.now() | ||
| 26 | + task.update(update) | ||
| 25 | 27 | ||
| 26 | if msg: | 28 | if msg: |
| 27 | message = "{} {}".format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), msg) | 29 | message = "{} {}".format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), msg) |
| @@ -35,6 +35,8 @@ class Api(ApiTemplate): | @@ -35,6 +35,8 @@ class Api(ApiTemplate): | ||
| 35 | #注册地址匹配引擎服务 | 35 | #注册地址匹配引擎服务 |
| 36 | if response.json().get("Type") == "AddServer": | 36 | if response.json().get("Type") == "AddServer": |
| 37 | response: requests.Response = requests.get("{}/Info".format(url),timeout=3) | 37 | response: requests.Response = requests.get("{}/Info".format(url),timeout=3) |
| 38 | + if response.status_code != 200: | ||
| 39 | + raise Exception("服务引擎连接失败!") | ||
| 38 | add_name = response.json().get("name") | 40 | add_name = response.json().get("name") |
| 39 | service = Service( | 41 | service = Service( |
| 40 | guid=engine_guid, | 42 | guid=engine_guid, |
| @@ -38,7 +38,8 @@ class Api(ApiTemplate): | @@ -38,7 +38,8 @@ class Api(ApiTemplate): | ||
| 38 | state=0, | 38 | state=0, |
| 39 | task_type=5, | 39 | task_type=5, |
| 40 | creator=self.para.get("creator"), | 40 | creator=self.para.get("creator"), |
| 41 | - process="影像创建金字塔中") | 41 | + process="影像创建金字塔中", |
| 42 | + parameter=self.para.get("url")) | ||
| 42 | 43 | ||
| 43 | db.session.add(task) | 44 | db.session.add(task) |
| 44 | db.session.commit() | 45 | db.session.commit() |
| @@ -70,11 +71,13 @@ class Api(ApiTemplate): | @@ -70,11 +71,13 @@ class Api(ApiTemplate): | ||
| 70 | self.para["task_guid"] = task_guid | 71 | self.para["task_guid"] = task_guid |
| 71 | 72 | ||
| 72 | response:requests.Response = requests.post(url,data=self.para) | 73 | 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"))) | 74 | + if response.status_code == 200: |
| 75 | + if not response.json().get("result"): | ||
| 76 | + raise Exception("由于{},提交任务失败!".format(response.json().get("msg"))) | ||
| 77 | + else: | ||
| 78 | + task_writer.update_task({"task_pid": int(response.json().get("data"))}) | ||
| 76 | else: | 79 | else: |
| 77 | - task_writer.update_task({"task_pid": int(response.json().get("data"))}) | 80 | + raise Exception("影像服务器连接失败!") |
| 78 | except Exception as e: | 81 | except Exception as e: |
| 79 | try: | 82 | try: |
| 80 | task_writer.update_task({"state": -1,"update_time":datetime.datetime.now(),"process": "创建失败"}) | 83 | task_writer.update_task({"state": -1,"update_time":datetime.datetime.now(),"process": "创建失败"}) |
| 1 | -# coding=utf-8 | ||
| 2 | -#author: 4N | ||
| 3 | -#createtime: 2021/7/19 | ||
| 4 | -#email: nheweijun@sina.com | ||
| 5 | - | ||
| 6 | -import configure | ||
| 7 | -from app.util.component.ApiTemplate import ApiTemplate | ||
| 8 | -from app.util.component.StructurePrint import StructurePrint | ||
| 9 | -from app.models import db | ||
| 10 | -from app.modules.data.models import Task | ||
| 11 | -import multiprocessing | ||
| 12 | -import uuid | ||
| 13 | -import datetime | ||
| 14 | -import requests | ||
| 15 | -from app.util.component.TaskController import TaskController | ||
| 16 | -from app.util.component.TaskWriter import TaskWriter | ||
| 17 | -class Api(ApiTemplate): | ||
| 18 | - | ||
| 19 | - api_name = "创建影像金字塔" | ||
| 20 | - | ||
| 21 | - def process(self): | ||
| 22 | - | ||
| 23 | - # 返回结果 | ||
| 24 | - res = {} | ||
| 25 | - try: | ||
| 26 | - task_guid = uuid.uuid1().__str__() | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - pyramid_process = multiprocessing.Process(target=self.task, args=(task_guid,self.para)) | ||
| 30 | - pyramid_process.start() | ||
| 31 | - | ||
| 32 | - task = Task(guid=task_guid, | ||
| 33 | - name="{}构建影像金字塔".format(self.para.get("alias")), | ||
| 34 | - create_time=datetime.datetime.now(), | ||
| 35 | - state=0, | ||
| 36 | - task_type=5, | ||
| 37 | - creator=self.para.get("creator"), | ||
| 38 | - process="影像创建金字塔中", | ||
| 39 | - task_pid=pyramid_process.pid) | ||
| 40 | - | ||
| 41 | - db.session.add(task) | ||
| 42 | - db.session.commit() | ||
| 43 | - | ||
| 44 | - res["data"] = "创建影像金字塔任务已提交!" | ||
| 45 | - res["result"] = True | ||
| 46 | - | ||
| 47 | - except Exception as e: | ||
| 48 | - raise Exception("数据库错误!") | ||
| 49 | - | ||
| 50 | - return res | ||
| 51 | - | ||
| 52 | - | ||
| 53 | - def task(self,task_guid,para): | ||
| 54 | - task_writer = None | ||
| 55 | - try: | ||
| 56 | - | ||
| 57 | - #任务控制,等待执行 | ||
| 58 | - TaskController.wait(task_guid) | ||
| 59 | - task_writer = TaskWriter(task_guid) | ||
| 60 | - | ||
| 61 | - task_writer.update_task({"state":2,"update_time":datetime.datetime.now(),"process" : "创建中"}) | ||
| 62 | - task_writer.update_process("开始创建...") | ||
| 63 | - | ||
| 64 | - url = "{}/API/Service/Image/BuildPyramid".format(para.get("url")) | ||
| 65 | - | ||
| 66 | - # s = requests.session() | ||
| 67 | - # s.keep_alive = True | ||
| 68 | - # s.post() | ||
| 69 | - | ||
| 70 | - self.para["from"] = configure.deploy_ip_host | ||
| 71 | - | ||
| 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"))) | ||
| 76 | - | ||
| 77 | - task_writer.update_task({"state":1,"update_time":datetime.datetime.now(),"process" : "创建完成"}) | ||
| 78 | - task_writer.update_process("创建完成!") | ||
| 79 | - | ||
| 80 | - except Exception as e: | ||
| 81 | - try: | ||
| 82 | - task_writer.update_task({"state": -1,"update_time":datetime.datetime.now(),"process": "创建失败"}) | ||
| 83 | - task_writer.update_process(e.__str__()) | ||
| 84 | - task_writer.update_process("任务中止!") | ||
| 85 | - except Exception as ee: | ||
| 86 | - StructurePrint().print(ee.__str__()) | ||
| 87 | - raise e | ||
| 88 | - finally: | ||
| 89 | - try: | ||
| 90 | - task_writer.close() | ||
| 91 | - except Exception as e: | ||
| 92 | - StructurePrint().print(e.__str__()) | ||
| 93 | - | ||
| 94 | - | ||
| 95 | - api_doc = { | ||
| 96 | - "tags": ["影像服务接口"], | ||
| 97 | - "parameters": [ | ||
| 98 | - {"name": "guid", | ||
| 99 | - "in": "formData", | ||
| 100 | - "type": "string", | ||
| 101 | - "description": "guid"}, | ||
| 102 | - {"name": "url", | ||
| 103 | - "in": "formData", | ||
| 104 | - "type": "string", | ||
| 105 | - "description": "url"}, | ||
| 106 | - {"name": "alias", | ||
| 107 | - "in": "formData", | ||
| 108 | - "type": "string", | ||
| 109 | - "description": "影像alias"}, | ||
| 110 | - ], | ||
| 111 | - "responses": { | ||
| 112 | - 200: { | ||
| 113 | - "schema": { | ||
| 114 | - "properties": { | ||
| 115 | - } | ||
| 116 | - } | ||
| 117 | - } | ||
| 118 | - } | ||
| 119 | - } | ||
| 120 | - |
| @@ -20,17 +20,21 @@ class Api(ApiTemplate): | @@ -20,17 +20,21 @@ class Api(ApiTemplate): | ||
| 20 | 20 | ||
| 21 | user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")), | 21 | user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")), |
| 22 | data={"guid":self.para.get("guid")}) | 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 | UserCheck.verify(user_req.json().get("data").get("service").get("creator")) | 29 | UserCheck.verify(user_req.json().get("data").get("service").get("creator")) |
| 28 | 30 | ||
| 29 | url = "{}/API/Service/Delete".format(self.para.get("url")) | 31 | url = "{}/API/Service/Delete".format(self.para.get("url")) |
| 30 | response:requests.Response = requests.post(url,data=self.para) | 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 | res["result"] = True | 38 | res["result"] = True |
| 35 | except Exception as e: | 39 | except Exception as e: |
| 36 | raise e | 40 | raise e |
| @@ -20,15 +20,21 @@ class Api(ApiTemplate): | @@ -20,15 +20,21 @@ class Api(ApiTemplate): | ||
| 20 | 20 | ||
| 21 | user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")), | 21 | user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")), |
| 22 | data={"guid":self.para.get("guid")}) | 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 | UserCheck.verify(user_req.json().get("data").get("service").get("creator")) | 29 | UserCheck.verify(user_req.json().get("data").get("service").get("creator")) |
| 27 | 30 | ||
| 28 | url = "{}/API/Service/Edit".format(self.para.get("url")) | 31 | url = "{}/API/Service/Edit".format(self.para.get("url")) |
| 29 | response:requests.Response = requests.post(url,data=self.para) | 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 | res["result"] = True | 38 | res["result"] = True |
| 33 | except Exception as e: | 39 | except Exception as e: |
| 34 | raise e | 40 | raise e |
| @@ -17,8 +17,11 @@ class Api(ApiTemplate): | @@ -17,8 +17,11 @@ class Api(ApiTemplate): | ||
| 17 | try: | 17 | try: |
| 18 | url = "{}/API/Service/Register".format(self.para.get("url")) | 18 | url = "{}/API/Service/Register".format(self.para.get("url")) |
| 19 | response:requests.Response = requests.post(url,data=self.para) | 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 | res["result"] = True | 25 | res["result"] = True |
| 23 | except Exception as e: | 26 | except Exception as e: |
| 24 | raise e | 27 | raise e |
| @@ -53,9 +53,12 @@ class Api(ApiTemplate): | @@ -53,9 +53,12 @@ class Api(ApiTemplate): | ||
| 53 | resp: requests.Response = requests.post(map_service_register_url,data=json.dumps(para), | 53 | resp: requests.Response = requests.post(map_service_register_url,data=json.dumps(para), |
| 54 | headers={'Content-Type':'application/json'},timeout=3 | 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 | raise Exception("调用矢量服务的修改服务接口失败!") | 62 | raise Exception("调用矢量服务的修改服务接口失败!") |
| 60 | 63 | ||
| 61 | service_update["overview"] = resp_json["url"] | 64 | service_update["overview"] = resp_json["url"] |
| @@ -38,11 +38,14 @@ class Api(ApiTemplate): | @@ -38,11 +38,14 @@ class Api(ApiTemplate): | ||
| 38 | resp: requests.Response = requests.post(map_service_register_url,data=json.dumps(para), | 38 | resp: requests.Response = requests.post(map_service_register_url,data=json.dumps(para), |
| 39 | headers={'Content-Type':'application/json'},timeout=3 | 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 | service = Service( | 51 | service = Service( |
| @@ -43,9 +43,13 @@ class Api(ApiTemplate): | @@ -43,9 +43,13 @@ class Api(ApiTemplate): | ||
| 43 | 43 | ||
| 44 | edit_url = "{}/API/Service/Info".format(self.para.get("url")) | 44 | edit_url = "{}/API/Service/Info".format(self.para.get("url")) |
| 45 | response:requests.Response = requests.post(edit_url,self.para) | 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 | else: | 53 | else: |
| 50 | pass | 54 | pass |
| 51 | 55 |
| @@ -61,11 +61,15 @@ class Api(ApiTemplate): | @@ -61,11 +61,15 @@ class Api(ApiTemplate): | ||
| 61 | url = "{}/API/Service/BaseMapList".format(ie.url) | 61 | url = "{}/API/Service/BaseMapList".format(ie.url) |
| 62 | response:requests.Response = requests.post(url,{"page_size":"9999","page_index":"0", | 62 | response:requests.Response = requests.post(url,{"page_size":"9999","page_index":"0", |
| 63 | "bbox":bbox,"state":state}) | 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 | else: | 71 | else: |
| 67 | - raw_json = response.json()["data"]["list"] | ||
| 68 | - fit_services_json.extend(raw_json) | 72 | + pass |
| 69 | 73 | ||
| 70 | res["data"] = {} | 74 | res["data"] = {} |
| 71 | res["data"]["count"] = len(fit_services_json) | 75 | res["data"]["count"] = len(fit_services_json) |
| @@ -34,15 +34,22 @@ class Api(ApiTemplate): | @@ -34,15 +34,22 @@ class Api(ApiTemplate): | ||
| 34 | elif s_type == ServiceType.image_service.value: | 34 | elif s_type == ServiceType.image_service.value: |
| 35 | user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")), | 35 | user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")), |
| 36 | data={"guid": self.para.get("guid")}) | 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 | UserCheck.verify(user_req.json().get("data").get("service").get("creator")) | 44 | UserCheck.verify(user_req.json().get("data").get("service").get("creator")) |
| 41 | 45 | ||
| 42 | url = "{}/API/Service/State".format(self.para.get("url")) | 46 | url = "{}/API/Service/State".format(self.para.get("url")) |
| 43 | response: requests.Response = requests.post(url, data=self.para) | 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 | res["result"] = True | 53 | res["result"] = True |
| 47 | 54 | ||
| 48 | except Exception as e: | 55 | except Exception as e: |
| @@ -63,9 +63,13 @@ class Api(ApiTemplate): | @@ -63,9 +63,13 @@ class Api(ApiTemplate): | ||
| 63 | tile_service_edit_url = "{}/dmap/api/manager/RegService".format(configure.dmap_engine) | 63 | tile_service_edit_url = "{}/dmap/api/manager/RegService".format(configure.dmap_engine) |
| 64 | 64 | ||
| 65 | resp: Response = requests.post(tile_service_edit_url,data=json.dumps(para),headers={'Content-Type':'application/json'},timeout=3) | 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 | raise Exception("调用电子地图的注册服务接口失败!") | 73 | raise Exception("调用电子地图的注册服务接口失败!") |
| 70 | 74 | ||
| 71 | service_update["overview"] = resp_json["url"] | 75 | service_update["overview"] = resp_json["url"] |
| @@ -41,13 +41,12 @@ class Api(ApiTemplate): | @@ -41,13 +41,12 @@ class Api(ApiTemplate): | ||
| 41 | resp: Response = requests.post(tile_service_register_url,data=json.dumps(para), | 41 | resp: Response = requests.post(tile_service_register_url,data=json.dumps(para), |
| 42 | headers={'Content-Type':'application/json'},timeout=3 | 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 | raise Exception("调用电子地图的注册服务接口失败!") | 50 | raise Exception("调用电子地图的注册服务接口失败!") |
| 52 | 51 | ||
| 53 | service = Service( | 52 | service = Service( |
| 1 | Listen 81 | 1 | Listen 81 |
| 2 | <VirtualHost *:81> | 2 | <VirtualHost *:81> |
| 3 | - ServerName 172.26.60.100 | 3 | + ServerName 172.26.60.101 |
| 4 | WSGIDaemonProcess yourapplication processes=4 threads=16 | 4 | WSGIDaemonProcess yourapplication processes=4 threads=16 |
| 5 | WSGIScriptAlias / /usr/src/app/run.wsgi | 5 | WSGIScriptAlias / /usr/src/app/run.wsgi |
| 6 | WSGIPassAuthorization On | 6 | WSGIPassAuthorization On |
| @@ -14,7 +14,7 @@ Listen 81 | @@ -14,7 +14,7 @@ Listen 81 | ||
| 14 | </VirtualHost> | 14 | </VirtualHost> |
| 15 | Listen 82 | 15 | Listen 82 |
| 16 | <VirtualHost *:82> | 16 | <VirtualHost *:82> |
| 17 | - ServerName 172.26.60.100 | 17 | + ServerName 172.26.60.101 |
| 18 | WSGIDaemonProcess monitormanager processes=1 threads=8 | 18 | WSGIDaemonProcess monitormanager processes=1 threads=8 |
| 19 | WSGIScriptAlias / /usr/src/app/monitor.wsgi | 19 | WSGIScriptAlias / /usr/src/app/monitor.wsgi |
| 20 | WSGIPassAuthorization On | 20 | WSGIPassAuthorization On |
| @@ -7,7 +7,7 @@ from osgeo import gdal,osr,ogr | @@ -7,7 +7,7 @@ from osgeo import gdal,osr,ogr | ||
| 7 | from osgeo.gdal import * | 7 | from osgeo.gdal import * |
| 8 | from osgeo.ogr import * | 8 | from osgeo.ogr import * |
| 9 | 9 | ||
| 10 | - | 10 | +import os |
| 11 | import json | 11 | import json |
| 12 | 12 | ||
| 13 | 13 | ||
| @@ -65,9 +65,18 @@ def getInfo( path): | @@ -65,9 +65,18 @@ def getInfo( path): | ||
| 65 | return json.dumps(info) | 65 | return json.dumps(info) |
| 66 | 66 | ||
| 67 | if __name__ == '__main__': | 67 | if __name__ == '__main__': |
| 68 | + data_path = r"E:\Data\矢量数据\广州\广州\dataset.gdb" | ||
| 69 | + | ||
| 70 | + driver: Driver = ogr.GetDriverByName("OpenFileGDB") | ||
| 71 | + ds: DataSource = driver.Open(data_path, 0) | ||
| 72 | + layer : Layer = ds.GetLayer(0) | ||
| 73 | + | ||
| 74 | + | ||
| 75 | + print(layer.GetMetadata()) | ||
| 76 | + print(layer.GetDescription()) | ||
| 77 | + print(layer.GetStyleTable()) | ||
| 68 | 78 | ||
| 69 | - path = r"E:\Data\zh.gdb" | ||
| 70 | - print(getInfo(path)) | 79 | + print(ds.GetStyleTable()) |
| 71 | 80 | ||
| 72 | 81 | ||
| 73 | 82 |
请
注册
或
登录
后发表评论