From 6a26dd47f6ec925bff1a63a3238ef732230768f8 Mon Sep 17 00:00:00 2001 From: lzjohnny Date: Sun, 13 Jan 2019 02:48:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A7=A3=E5=86=B3Windows=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E4=B8=8Bzk=E8=B7=AF=E5=BE=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/config/znode.py | 3 ++- service/snapshot.py | 2 +- service/znode.py | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/handler/config/znode.py b/handler/config/znode.py index 9a89cc5..e2a56e5 100644 --- a/handler/config/znode.py +++ b/handler/config/znode.py @@ -307,7 +307,8 @@ def response(self): zk_path = "" if not self.path: # 新增节点需要进行存在检验 - zk_path = os.path.join(self.parent_path, self.node_name) + zk_path = "/{0}".format(self.node_name) if self.parent_path == "/" else "{0}/{1}".format(self.parent_path, + self.node_name) if ZookeeperService.exists(self.cluster_name, zk_path): return self.ajax_popup(code=300, msg="节点已经存在!") else: diff --git a/service/snapshot.py b/service/snapshot.py index 615257a..3499555 100644 --- a/service/snapshot.py +++ b/service/snapshot.py @@ -171,7 +171,7 @@ def _get_recursively(zoo_client, path, nodes): else: nodes.append({"path": path, "data": data}) for child in zoo_client.get_children(path): - child_path = os.path.join(path, child) + child_path = "/{0}".format(child) if path == "/" else "{0}/{1}".format(path, child) _get_recursively(zoo_client, child_path, nodes) diff --git a/service/znode.py b/service/znode.py index 7a8a933..13bed28 100644 --- a/service/znode.py +++ b/service/znode.py @@ -38,7 +38,7 @@ def get_child_znodes(cluster_name, path): children = zoo_client.get_children(path) # iter child nodes and convert to dict with extra info for child in children: - child_path = os.path.join(path, child) + child_path = "/{0}".format(child) if path == "/" else "{0}/{1}".format(path, child) data, _ = zoo_client.get(child_path) # node node = {"path": child_path, "value": data} @@ -74,7 +74,7 @@ def set_batch_znodes(cluster_name, parent_path, batch_data, business=''): """set batch znodes from python data """ for key, data in batch_data: - path = os.path.join(parent_path, key) + path = "/{0}".format(key) if parent_path == "/" else "{0}/{1}".format(parent_path, key) set_znode(cluster_name, path, data, business=business) @@ -115,7 +115,7 @@ def delete_znodes_diff_with_keys(cluster_name, parent_path, keys): children = zoo_client.get_children(parent_path) diff_znodes = [child for child in children if child not in keys] for znode in diff_znodes: - path = os.path.join(parent_path, znode) + path = "/{0}".format(znode) if parent_path == "/" else "{0}/{1}".format(parent_path, znode) zoo_client.delete(path, version=-1, recursive=False) delete_znodes(cluster_name, path, recursive=False, del_snapshots=True) @@ -142,7 +142,7 @@ def get_znode_tree(zoo_client, path, nodes, current_id='1', parent_id='0'): idx = '{0:02d}'.format(idx) # parent_id as 1, then child_id should be 10, 11, 12... child_id = "{0}{1}".format(current_id, idx) - child_path = os.path.join(path, child) + child_path = "/{0}".format(child) if path == "/" else "{0}/{1}".format(path, child) get_znode_tree(zoo_client, child_path, nodes, child_id, current_id) From c37ea8dff3894550a37d3c18a648e51ab0257c3d Mon Sep 17 00:00:00 2001 From: lzjohnny Date: Sun, 13 Jan 2019 18:52:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=94=AE=E5=80=BC?= =?UTF-8?q?=E4=B8=BAJson=E6=97=B6=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/BJUI/js/bjui-tabledit.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/static/BJUI/js/bjui-tabledit.js b/static/BJUI/js/bjui-tabledit.js index a3251bc..e13c086 100644 --- a/static/BJUI/js/bjui-tabledit.js +++ b/static/BJUI/js/bjui-tabledit.js @@ -127,6 +127,8 @@ $th = $(this), $child = $th.children(), $pic = $th.find('.pic-box') if (typeof val == 'undefined') val = $td.html() + if (typeof val == 'object') val = JSON.stringify(val) + if (!$td.data('noedit')) { if ($child.length) { if ($child.is('input:checkbox') || $child.is('input:radio')) {