From ce5aa5ff867872a51244ed58d47b2fc1166568dc Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 10 Apr 2022 14:14:29 +0800 Subject: [PATCH] up --- plugins/gogs/class/mysqlDb.py | 2 +- plugins/gogs/index.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/gogs/class/mysqlDb.py b/plugins/gogs/class/mysqlDb.py index 30a7267ac..ee69c9dea 100755 --- a/plugins/gogs/class/mysqlDb.py +++ b/plugins/gogs/class/mysqlDb.py @@ -83,7 +83,7 @@ class mysqlDb: self.__Close() return result except Exception as ex: - return ex + return "error: " + str(ex) # 关闭连接 def __Close(self): diff --git a/plugins/gogs/index.py b/plugins/gogs/index.py index ba96cbace..fcf29bed3 100755 --- a/plugins/gogs/index.py +++ b/plugins/gogs/index.py @@ -628,19 +628,23 @@ def getRsaPublic(): def getTotalStatistics(): st = status() data = {} - if st == 'start': + if st.strip() == 'start': pm = pMysqlDb() list_count = pm.query('select count(id) as num from repository') - count = list_count[0][0] + + if list_count.find("error") > -1: + data['status'] = False + data['count'] = 0 + return mw.returnJson(False, 'fail', data) data['status'] = True data['count'] = count data['ver'] = mw.readFile(getServerDir() + '/version.pl').strip() return mw.returnJson(True, 'ok', data) - else: - data['status'] = False - data['count'] = 0 - return mw.returnJson(False, 'fail', data) + + data['status'] = False + data['count'] = 0 + return mw.returnJson(False, 'fail', data) if __name__ == "__main__":