正在显示
5 个修改的文件
包含
27 行增加
和
39 行删除
| ... | ... | @@ -6,7 +6,6 @@ |
| 6 | 6 | |
| 7 | 7 | from app.util.component.ApiTemplate import ApiTemplate |
| 8 | 8 | |
| 9 | -from threading import Thread | |
| 10 | 9 | from .util.ImageWMSServer import ImageWMSServer |
| 11 | 10 | |
| 12 | 11 | class Api(ApiTemplate): |
| ... | ... | @@ -62,18 +61,6 @@ class Api(ApiTemplate): |
| 62 | 61 | } |
| 63 | 62 | } |
| 64 | 63 | |
| 65 | -class MyThread(Thread): | |
| 66 | - def __init__(self,func,args=()): | |
| 67 | - super(MyThread,self).__init__() | |
| 68 | - self.func = func | |
| 69 | - self.args = args | |
| 70 | - def run(self): | |
| 71 | - self.result = self.func(*self.args) | |
| 72 | - def get_result(self): | |
| 73 | - try: | |
| 74 | - return self.result | |
| 75 | - except Exception: | |
| 76 | - return None | |
| 77 | 64 | |
| 78 | 65 | |
| 79 | 66 | ... | ... |
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | #email: nheweijun@sina.com |
| 5 | 5 | |
| 6 | 6 | from app.util.component.ApiTemplate import ApiTemplate |
| 7 | -from threading import Thread | |
| 7 | + | |
| 8 | 8 | |
| 9 | 9 | from .util.ImageWMSServer import ImageWMSServer |
| 10 | 10 | class Api(ApiTemplate): |
| ... | ... | @@ -57,18 +57,6 @@ class Api(ApiTemplate): |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | -class MyThread(Thread): | |
| 61 | - def __init__(self,func,args=()): | |
| 62 | - super(MyThread,self).__init__() | |
| 63 | - self.func = func | |
| 64 | - self.args = args | |
| 65 | - def run(self): | |
| 66 | - self.result = self.func(*self.args) | |
| 67 | - def get_result(self): | |
| 68 | - try: | |
| 69 | - return self.result | |
| 70 | - except Exception: | |
| 71 | - return None | |
| 72 | 60 | |
| 73 | 61 | |
| 74 | 62 | ... | ... |
| ... | ... | @@ -27,10 +27,10 @@ class Api(ApiTemplate): |
| 27 | 27 | res["data"]["speci_service"]["images"] = sorted(res["data"]["speci_service"]["images"], key=lambda x: x["name"]) |
| 28 | 28 | |
| 29 | 29 | elif service.type.__eq__("切片服务"): |
| 30 | - speci_service = service.relate_map_service.one_or_none() | |
| 30 | + speci_service = service.relate_tile_service.one_or_none() | |
| 31 | 31 | res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service) |
| 32 | 32 | elif service.type.__eq__("地图服务"): |
| 33 | - speci_service = service.relate_tile_service.one_or_none() | |
| 33 | + speci_service = service.relate_map_service.one_or_none() | |
| 34 | 34 | res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service) |
| 35 | 35 | else: |
| 36 | 36 | res["data"] = {} | ... | ... |
| ... | ... | @@ -60,21 +60,35 @@ class ModelVisitor: |
| 60 | 60 | info = {} |
| 61 | 61 | info["catalog_name"] = task.relate_catalog.name if task.relate_catalog else None |
| 62 | 62 | info["database_alias"] = task.relate_database.alias if task.relate_database else None |
| 63 | - info["consume_time"]=None | |
| 64 | 63 | if task.update_time: |
| 65 | - | |
| 66 | - consume_time = int(task.update_time.timestamp()-task.create_time.timestamp()) | |
| 67 | - minute = int(consume_time/60) | |
| 68 | - sec = 1 if (int(consume_time%60)==0 and minute==0) else int(consume_time%60) | |
| 69 | - if minute>0: | |
| 70 | - info["consume_time"] = "{}分{}秒".format(minute,sec) | |
| 71 | - else: | |
| 72 | - info["consume_time"] = "{}秒".format(sec) | |
| 64 | + dd: datetime.timedelta = task.update_time - task.create_time | |
| 65 | + info["spend"] = float("{}.{}".format(dd.seconds, str(dd.microseconds)[:3])) | |
| 73 | 66 | if object: |
| 74 | 67 | info.update(cls.formatter(task.__dict__)) |
| 75 | - del info["parameter"] | |
| 68 | + | |
| 69 | + | |
| 76 | 70 | return info |
| 77 | 71 | |
| 72 | + # @classmethod | |
| 73 | + # def task_to_json(cls, task): | |
| 74 | + # info = {} | |
| 75 | + # info["catalog_name"] = task.relate_catalog.name if task.relate_catalog else None | |
| 76 | + # info["database_alias"] = task.relate_database.alias if task.relate_database else None | |
| 77 | + # info["consume_time"] = None | |
| 78 | + # if task.update_time: | |
| 79 | + # | |
| 80 | + # consume_time = int(task.update_time.timestamp() - task.create_time.timestamp()) | |
| 81 | + # minute = int(consume_time / 60) | |
| 82 | + # sec = 1 if (int(consume_time % 60) == 0 and minute == 0) else int(consume_time % 60) | |
| 83 | + # if minute > 0: | |
| 84 | + # info["consume_time"] = "{}分{}秒".format(minute, sec) | |
| 85 | + # else: | |
| 86 | + # info["consume_time"] = "{}秒".format(sec) | |
| 87 | + # if object: | |
| 88 | + # info.update(cls.formatter(task.__dict__)) | |
| 89 | + # | |
| 90 | + # return info | |
| 91 | + | |
| 78 | 92 | @classmethod |
| 79 | 93 | def database_to_json(cls,database): |
| 80 | 94 | info = {} | ... | ... |
请
注册
或
登录
后发表评论