From b7d3c20a347440b86a245d6e5c0b69ed212905ab Mon Sep 17 00:00:00 2001 From: zhengxie Date: Sat, 9 May 2015 13:24:08 +0800 Subject: [PATCH] Handle rpc errors and use new rpc to get repos count --- seahub/views/sysadmin.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/seahub/views/sysadmin.py b/seahub/views/sysadmin.py index c25bc18e35..bffd39d0d0 100644 --- a/seahub/views/sysadmin.py +++ b/seahub/views/sysadmin.py @@ -40,6 +40,7 @@ from seahub.settings import INIT_PASSWD, SITE_NAME, \ ENABLE_GUEST from seahub.utils import send_html_email, get_user_traffic_list, \ get_server_id, clear_token +from seahub.utils.rpc import mute_seafile_api from seahub.utils.sysinfo import get_platform_name try: from seahub.settings import ENABLE_TRIAL_ACCOUNT @@ -63,11 +64,26 @@ def sys_info(request): Arguments: - `request`: """ - users_count = ccnet_threaded_rpc.count_emailusers('DB') - repos_count = len(seafile_api.get_repo_list(-1, -1)) - groups_count = len(ccnet_threaded_rpc.get_all_groups(-1, -1)) + try: + users_count = ccnet_threaded_rpc.count_emailusers('DB') + except Exception as e: + logger.error(e) + users_count = 0 + + repos_count = mute_seafile_api.count_repos() + + try: + groups_count = len(ccnet_threaded_rpc.get_all_groups(-1, -1)) + except Exception as e: + logger.error(e) + groups_count = 0 + if MULTI_TENANCY: - org_count = ccnet_threaded_rpc.count_orgs() + try: + org_count = ccnet_threaded_rpc.count_orgs() + except Exception as e: + logger.error(e) + org_count = 0 else: org_count = -1