栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

【山大智云项目日志】Seahub+Proset分析(11)

【山大智云项目日志】Seahub+Proset分析(11)

2021SC@SDUSC

我们继续分析seafes部分的文件。

Seafes connection.py

此文件用于连接服务器。

import requests
from elasticsearch import Elasticsearch

from seafes.config import seafes_config

def es_get_conn():
    es = Elasticsearch(['{}:{}'.format(seafes_config.host, seafes_config.port)], maxsize=50, timeout=30)
    return es

def es_get_status():
    """ return True if es server work normal, otherwise return false
    """
    protocol = ['http', 'https']
    urls = []
    for p in protocol:
        urls.append(p + '://' + str(seafes_config.host) + ':' + str(seafes_config.port) + '/repofiles?pretty')
    alive = False
    try:
        for url in urls:
            if requests.get(url, timeout=10).status_code == 200:
                alive = True
    except:
        pass
    return alive

在es_get_conn()函数中服务器正常工作则返回true,否则返回false。

constants.py

该文件定义了项目中可能会出现的所有文件的后缀。

text_suffixes = [
    'txt',
    'md',
    'markdown'
]

office_suffixes = [
    'doc',
    'docx',
    'ppt',
    'pptx',
    'xls',
    'xlsx',
    'pdf',
    'odt',
    'ods',
    'odp',
]

之后我们还会继续分析其他文件。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/674217.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号