Exemplo n.º 1
0
def get_code(pwd, git_obj, code_dir):
    """
    拉取graph组件的源码:如果本路径有代码库则更新即可;没有代码库则拉取最新代码
    :param pwd: 路径
    :param git_obj: git 配置
    :param code_dir:
    """
    if not is_match_re(pwd, code_dir):
        branch = git_obj['branch']
        url = git_obj['url']
        print('cd %s && git clone -b %s %s' % (pwd, branch, url))
        os.system('cd %s && git clone -b %s %s' % (pwd, branch, url))
    else:
        os.system('cd %s/%s && git pull' % (pwd, code_dir))
Exemplo n.º 2
0
    def server(self):
        """
        :return:
        """
        code_dir = 'hugegraph'
        code_dir_path = self.code_path + '/' + code_dir
        re_dir = '^%s-(\d).(\d{1,2}).(\d)$' % code_dir

        is_exists_path(self.code_path)
        get_code(self.code_path, self.server_git, code_dir)
        compile_package(self.mvn_path, code_dir_path)
        #  start graph_server
        package_dir_name = is_match_re(code_dir_path, re_dir)
        package_dir_path = code_dir_path + '/' + package_dir_name
        set_server_properties(package_dir_path, self.graph_host, self.server_port, self.gremlin_port)
        start_graph(package_dir_path, 'server')
Exemplo n.º 3
0
 def hubble(self):
     """
     :return:
     """
     code_dir = 'hugegraph-hubble'
     code_dir_path = self.code_path + '/' + code_dir
     re_dir = '^%s-(\d).(\d{1,2}).(\d)$' % code_dir
     #         # get code && compile
     #         is_exists_path(self.code_path)
     #         get_code(self.code_path, self.hubble_git, code_dir)
     #         compile_package(self.mvn_path, code_dir_path)
     # wget tar
     is_exists_path(code_dir_path)
     os.system(
         'cd %s && '
         'wget https://github.com/hugegraph/hugegraph-hubble/releases/download/v1.5.0/hugegraph-hubble-1.5.0.tar.gz '
         '&& tar xzvf hugegraph-hubble-1.5.0.tar.gz' % code_dir_path)
     # set properties && start hubble
     package_dir_name = is_match_re(code_dir_path, re_dir)
     package_dir_path = code_dir_path + '/' + package_dir_name
     set_hubble_properties(package_dir_path, self.graph_host,
                           self.hubble_port)
     start_graph(package_dir_path, 'hubble')
Exemplo n.º 4
0
author     : lxb
note       : 给初始化的空图添加数据
create_time:  2020/10/27 20:20 下午
"""
import os
import sys
import subprocess

root_path = os.path.dirname(os.path.realpath(__file__)) + '/../../'
sys.path.append(root_path)

from src.common.server_api import Gremlin
from src.common.file_basic import is_match_re
from src.config import basic_config as _cfg

loader_name = is_match_re(_cfg.code_path + '/hugegraph-loader',
                          "^hugegraph-loader-(\d).(\d{1,2}).(\d)$")
loader_path = _cfg.code_path + '/hugegraph-loader' + '/' + loader_name
dataset_path = root_path + 'src/config/dataset/'


def gremlin_create_graph(file_name, auth=None):
    """
    读取文件 & 请求gremlin接口创建图
    """
    gremlin_str = ''
    n = 0
    with open(file_name, 'r') as f:
        for line in f:
            each_line = line.strip('\n')
            if line.startswith('graph'):
                Gremlin().gremlin_post(each_line, auth=auth)
Exemplo n.º 5
0
"""
author     : lxb
note       : tools工具类
create_time:  
"""
import os
import sys
import subprocess

current_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(current_path + '/../../../')
from src.config import basic_config as _cfg
from src.common.file_basic import is_match_re
from src.common.server_api import Gremlin

tools_name = is_match_re(_cfg.code_path + '/hugegraph-tools',
                         "^hugegraph-tools-(\d).(\d{1,2}).(\d)$")
tools_path = _cfg.code_path + '/hugegraph-tools' + '/' + tools_name


def run_shell(cmd, graph_name=None, graph_host=None, graph_port=None):
    """
    执行脚本
    :return:
    """
    if graph_name is None:
        graph_name = _cfg.graph_name

    if graph_port is None:
        graph_port = _cfg.server_port

    if graph_host is None: