1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 15:53:28 +00:00

improve seafevents related code

This commit is contained in:
lins05
2013-11-09 16:58:57 +08:00
parent 47cf0c6de7
commit 908b600b87
2 changed files with 39 additions and 14 deletions

View File

@@ -356,6 +356,25 @@ LOGIN_ATTEMPT_TIMEOUT = 15 * 60 # in seconds (default: 15 minutes)
SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True # Whether to send email when a system staff adding new member. SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = True # Whether to send email when a system staff adding new member.
SEND_EMAIL_ON_RESETTING_USER_PASSWD = True # Whether to send email when a system staff resetting user's password. SEND_EMAIL_ON_RESETTING_USER_PASSWD = True # Whether to send email when a system staff resetting user's password.
##########################
# Settings for seafevents #
##########################
def get_events_conf_file():
if not 'CCNET_CONF_DIR' in os.environ:
return
ccnet_dir = os.environ['CCNET_CONF_DIR']
seafile_ini = os.path.join(ccnet_dir, 'seafile.ini')
if not os.path.exists(seafile_ini):
return
with open(seafile_ini, 'r') as fp:
seafile_data_dir = fp.read().strip()
globals()['EVENTS_CONFIG_FILE'] = os.path.join(seafile_data_dir, 'seafevents.conf')
get_events_conf_file()
########################## ##########################
# Settings for Extra App # # Settings for Extra App #
########################## ##########################

View File

@@ -991,13 +991,16 @@ def more_files_in_commit(commit):
HAS_OFFICE_CONVERTER = False HAS_OFFICE_CONVERTER = False
if EVENTS_CONFIG_FILE: if EVENTS_CONFIG_FILE:
def check_office_converter_enabled(): def check_office_converter_enabled():
config = ConfigParser.ConfigParser() enabled = False
config.read(EVENTS_CONFIG_FILE) if hasattr(seafevents, 'is_office_converter_enabled'):
enabled = seafevents.is_office_converter_enabled(config) config = ConfigParser.ConfigParser()
if enabled: config.read(EVENTS_CONFIG_FILE)
logging.debug('office converter: enabled') enabled = seafevents.is_office_converter_enabled(config)
else:
logging.debug('office converter: not enabled') if enabled:
logging.debug('office converter: enabled')
else:
logging.debug('office converter: not enabled')
return enabled return enabled
def get_office_converter_html_dir(): def get_office_converter_html_dir():
@@ -1072,13 +1075,16 @@ if HAS_OFFICE_CONVERTER:
HAS_FILE_SEARCH = False HAS_FILE_SEARCH = False
if EVENTS_CONFIG_FILE: if EVENTS_CONFIG_FILE:
def check_search_enabled(): def check_search_enabled():
config = ConfigParser.ConfigParser() enabled = False
config.read(EVENTS_CONFIG_FILE) if hasattr(seafevents, 'is_office_converter_enabled'):
enabled = seafevents.is_search_enabled(config) config = ConfigParser.ConfigParser()
if enabled: config.read(EVENTS_CONFIG_FILE)
logging.debug('search: enabled') enabled = seafevents.is_search_enabled(config)
else:
logging.debug('search: not enabled') if enabled:
logging.debug('search: enabled')
else:
logging.debug('search: not enabled')
return enabled return enabled
HAS_FILE_SEARCH = check_search_enabled() HAS_FILE_SEARCH = check_search_enabled()