正在显示
5 个修改的文件
包含
22 行增加
和
14 行删除
@@ -28,10 +28,11 @@ from app.util.component.StructuredPrint import StructurePrint | @@ -28,10 +28,11 @@ from app.util.component.StructuredPrint import StructurePrint | ||
28 | from app.util.component.PGUtil import PGUtil | 28 | from app.util.component.PGUtil import PGUtil |
29 | import os | 29 | import os |
30 | 30 | ||
31 | -""" | ||
32 | -因为decimal不能序列化,增加Flask对decimal类的解析 | ||
33 | -""" | 31 | + |
34 | class JSONEncoder(_JSONEncoder): | 32 | class JSONEncoder(_JSONEncoder): |
33 | + """ | ||
34 | + 因为decimal不能序列化,增加Flask对decimal类的解析 | ||
35 | + """ | ||
35 | def default(self, o): | 36 | def default(self, o): |
36 | if isinstance(o, decimal.Decimal): | 37 | if isinstance(o, decimal.Decimal): |
37 | return float(o) | 38 | return float(o) |
@@ -45,6 +46,10 @@ class Flask(_Flask): | @@ -45,6 +46,10 @@ class Flask(_Flask): | ||
45 | # url_json_list=None | 46 | # url_json_list=None |
46 | # sqlite3_connect= None | 47 | # sqlite3_connect= None |
47 | def create_app(): | 48 | def create_app(): |
49 | + """ | ||
50 | + flask应用创建函数 | ||
51 | + :return:app,flask实例 | ||
52 | + """ | ||
48 | 53 | ||
49 | # app基本设置 | 54 | # app基本设置 |
50 | app = Flask(__name__) | 55 | app = Flask(__name__) |
@@ -33,7 +33,9 @@ class Api(ApiTemplate): | @@ -33,7 +33,9 @@ class Api(ApiTemplate): | ||
33 | # if Table.query.filter_by(catalog_guid=self.para.get("pguid")).all(): | 33 | # if Table.query.filter_by(catalog_guid=self.para.get("pguid")).all(): |
34 | # raise Exception("父目录挂载了数据,不能创建子目录") | 34 | # raise Exception("父目录挂载了数据,不能创建子目录") |
35 | 35 | ||
36 | - if Catalog.query.filter_by(name=self.para.get("name"),pguid=self.para.get("pguid"),database_guid=self.para.get("database_guid")).one_or_none(): | 36 | + if Catalog.query.filter_by(name=self.para.get("name"), |
37 | + pguid=self.para.get("pguid"), | ||
38 | + database_guid=self.para.get("database_guid")).one_or_none(): | ||
37 | res["msg"]="目录已经存在!" | 39 | res["msg"]="目录已经存在!" |
38 | return res | 40 | return res |
39 | 41 | ||
@@ -58,9 +60,12 @@ class Api(ApiTemplate): | @@ -58,9 +60,12 @@ class Api(ApiTemplate): | ||
58 | 60 | ||
59 | sort = Catalog.query.filter_by(pguid=self.para.get("pguid")).count() | 61 | sort = Catalog.query.filter_by(pguid=self.para.get("pguid")).count() |
60 | 62 | ||
61 | - catalog = Catalog(guid=guid,pguid=self.para.get("pguid"),name=self.para.get("name"), | ||
62 | - sort=sort,description=self.para.get("description"), | ||
63 | - database_guid=self.para.get("database_guid"),path=path) | 63 | + catalog = Catalog(guid=guid, |
64 | + pguid=self.para.get("pguid"),name=self.para.get("name"), | ||
65 | + sort=sort, | ||
66 | + description=self.para.get("description"), | ||
67 | + database_guid=self.para.get("database_guid"), | ||
68 | + path=path) | ||
64 | db.session.add(catalog) | 69 | db.session.add(catalog) |
65 | db.session.commit() | 70 | db.session.commit() |
66 | 71 |
@@ -120,6 +120,8 @@ class Api(ApiTemplate): | @@ -120,6 +120,8 @@ class Api(ApiTemplate): | ||
120 | except Exception as e: | 120 | except Exception as e: |
121 | try: | 121 | try: |
122 | sys_session.query(Task).filter_by(guid=task_guid).update({"state": -1,"update_time":datetime.datetime.now()}) | 122 | sys_session.query(Task).filter_by(guid=task_guid).update({"state": -1,"update_time":datetime.datetime.now()}) |
123 | + sys_session.query(Table).filter_by(guid=table.guid).update( | ||
124 | + {"is_vacuate": 0, "update_time": datetime.datetime.now()}) | ||
123 | 125 | ||
124 | message = "{} {}".format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), e.__str__()) | 126 | message = "{} {}".format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), e.__str__()) |
125 | task_process_guid = uuid.uuid1().__str__() | 127 | task_process_guid = uuid.uuid1().__str__() |
@@ -133,7 +135,8 @@ class Api(ApiTemplate): | @@ -133,7 +135,8 @@ class Api(ApiTemplate): | ||
133 | except Exception as ee: | 135 | except Exception as ee: |
134 | print(traceback.format_exc()) | 136 | print(traceback.format_exc()) |
135 | finally: | 137 | finally: |
136 | - vacuate_process.end() | 138 | + if vacuate_process: |
139 | + vacuate_process.end() | ||
137 | if sys_session: | 140 | if sys_session: |
138 | sys_session.close() | 141 | sys_session.close() |
139 | if pg_session: | 142 | if pg_session: |
请
注册
或
登录
后发表评论