From 96875052cd683a55a4760993bc97bc4d7f531fd0 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 25 Feb 2023 08:25:05 +0800 Subject: [PATCH] Update index.py --- plugins/webssh/index.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/plugins/webssh/index.py b/plugins/webssh/index.py index 6731dac86..678f4cc85 100755 --- a/plugins/webssh/index.py +++ b/plugins/webssh/index.py @@ -145,24 +145,25 @@ class App(): def get_server_list(self): host_list = [] - for name in os.listdir(self.__host_dir): - info_file = self.__host_dir + '/' + name + '/info.json' - if not os.path.exists(info_file): - continue - try: - info_tmp = self.getSshInfo(info_file) - host_info = {} - host_info['host'] = name - host_info['port'] = info_tmp['port'] - host_info['ps'] = info_tmp['ps'] - # host_info['sort'] = int(info_tmp['sort']) - except Exception as e: - print(e) - # if os.path.exists(info_file): - # os.remove(info_file) - # continue - - host_list.append(host_info) + if os.path.exists(self.__host_dir): + for name in os.listdir(self.__host_dir): + info_file = self.__host_dir + '/' + name + '/info.json' + if not os.path.exists(info_file): + continue + try: + info_tmp = self.getSshInfo(info_file) + host_info = {} + host_info['host'] = name + host_info['port'] = info_tmp['port'] + host_info['ps'] = info_tmp['ps'] + # host_info['sort'] = int(info_tmp['sort']) + except Exception as e: + print(e) + # if os.path.exists(info_file): + # os.remove(info_file) + # continue + + host_list.append(host_info) host_list = sorted(host_list, key=lambda x: x['host'], reverse=False) return mw.returnJson(True, 'ok!', host_list)