コード例 #1
0
def main():
  global MIN_SUPPORT_VALUE
  # preprocessing
  config_data = get_config_info()
  MIN_SUPPORT_VALUE = int(config_data['min_support'])
  filename = config_data['filename']
  transactions = get_transactions(filename)
  location_time_star_items = get_location_time_star_items(transactions)
  # base itemset
  two_items_itemsets = get_two_items_itemsets(transactions)
  # running apriori on base itemset
  t1 = datetime.datetime.now()
  final_itemsets = get_final_itemsets(two_items_itemsets, transactions)
  star_itemsets = get_star_itemsets(final_itemsets, location_time_star_items)
  zero_star_itemsets = star_itemsets[0]
  one_star_itemsets = star_itemsets[1]
  two_star_itemsets = star_itemsets[2]
  t2 = datetime.datetime.now()
  total_time = t2-t1
  print(20*'*')
  print('Total time taken in (microseconds) by apriori algorithm:', total_time.microseconds)
  print('Min support value:', MIN_SUPPORT_VALUE)
  print(20*'*')
  print_table(zero_star_itemsets, 'Itemsets for CMB')
  print_table(one_star_itemsets, 'Itemsets for 1 star CMP')
  print_table(two_star_itemsets, 'Itemsets for 2 star')
コード例 #2
0
def setup_mysql57():
    """
    在宿主机安装 mysql5.7

    为什么不以docker安装database?
    测试时发现了很多问题。最终放弃了以docker方式安装 mysql5.7
    """

    config_info = get_config_info()
    root_pwd = config_info['mysql']['root_password']

    print("docker安装 mysql5.7 开始")
    cmd(("docker run --name mysql -d --net=host -e MYSQL_ROOT_PASSWORD={} "
         "-v /var/loonflow/db:/var/lib/mysql mysql:5.7.21").format(root_pwd))
    print("docker安装 mysql5.7 完成")

    print("睡眠10秒,确保mysql启动完成")
    time.sleep(10)

    db_name = 'loonflow'
    sql_file = '/opt/loonflow/docker_compose_deploy/loonflow_shutongflow/loonflow-web/loonflow_demo_init.sql'
    sql_to_docker_mysql(root_pwd, db_name, sql_file)

    print("睡眠10秒,确保sql导入完成")
    time.sleep(10)

    db_name = 'shutongflow'
    sql_file = '/opt/loonflow/docker_compose_deploy/loonflow_shutongflow/shutongflow/shutongflow_demo_init.sql'
    sql_to_docker_mysql(root_pwd, db_name, sql_file)
コード例 #3
0
def main():
    if os.geteuid() != 0:
        raise Exception("请以root权限运行")

    config_info = get_config_info()
    is_need_setup_mysql = config_info['is_need_setup_mysql']
    if is_need_setup_mysql:
        print('宿主机安装mysql5.7')
        print('这一步不是必须的,您也可使用自己已有的数据库')
        print('执行到这里说明您已将is_need_setup_mysql配置为true(默认值true)')
        try:
            setup_mysql57()
        except Exception:
            print("Warning: 在宿主机 mysql5.7 安装失败,但可能是因为你已经安装过了")

    cmd("python docker_compose_deploy/loonflow_shutongflow/setup_docker.py")
    cmd("service docker restart")
    cmd("python docker_compose_deploy/loonflow_shutongflow/setup_compose.py")
    cmd("cd docker_compose_deploy/loonflow_shutongflow && docker-compose up")
コード例 #4
0
def main():
    cfg_file = '/opt/shutongFlow/apps/apps/settings.py'
    # 修改数据库配置
    replace_in_file(cfg_file, "'USER': '******'", "'USER': '******'")
    config_info = get_config_info()
    password = config_info['mysql']['root_password']
    replace_in_file(
        cfg_file, "'PASSWORD': '******'", "'PASSWORD': '******'".format(password)
    )
    # 使前端项目在dev模式下可被外部访问
    f = '/opt/shutongFlow/fronted/config/index.js'
    replace_in_file(f, "host: 'localhost'", "host: '0.0.0.0'")

    f = '/opt/shutongFlow/fronted/src/main.js'
    ip = config_info['ip']
    replace_in_file(
        f,
        "axios.defaults.baseURL = 'http://127.0.0.1:6062/'",
        "axios.defaults.baseURL = 'http://{}:6062/'".format(ip)
    )
コード例 #5
0
def start_setup_test(yaml_file_path):
    config_info = utils.get_config_info(yaml_file_path)
    setting_dict = create_setting_dict(config_info)
    path_dict = create_path_dict(setting_dict)
    process_dict = create_process_dict(setting_dict)
    zabbix_hosts_dict = create_zabbix_hosts_dict(config_info)
    nagios_hosts_dict = create_nagios_hosts_dict(config_info)
    redmine_project_dict = create_redmine_project_dict(config_info)

    for container_name in setting_dict.keys():
        start_find_process(container_name, find_file,
                           path_dict[container_name])
        start_find_process(container_name, find_process,
                           process_dict[container_name])
    for container_name in zabbix_hosts_dict:
        start_find_process(container_name, find_zabbix_hosts,
                           zabbix_hosts_dict[container_name])
    for container_name in redmine_project_dict:
        start_find_process(container_name, find_redmine_project,
                           redmine_project_dict[container_name])
    for container_name in nagios_hosts_dict:
        start_find_process(container_name, find_nagios_hosts,
                           nagios_hosts_dict[container_name])
コード例 #6
0
def start_setup_test(yaml_file_path):
    config_info = utils.get_config_info(yaml_file_path)
    setting_dict = create_setting_dict(config_info)
    path_dict = create_path_dict(setting_dict)
    process_dict = create_process_dict(setting_dict)
    zabbix_hosts_dict = create_zabbix_hosts_dict(config_info)
    nagios_hosts_dict = create_nagios_hosts_dict(config_info)
    redmine_project_dict = create_redmine_project_dict(config_info)

    for container_name in setting_dict.keys():
        start_find_process(container_name, find_file,
                           path_dict[container_name])
        start_find_process(container_name, find_process,
                           process_dict[container_name])
    for container_name in zabbix_hosts_dict:
        start_find_process(container_name, find_zabbix_hosts,
                           zabbix_hosts_dict[container_name])
    for container_name in redmine_project_dict:
        start_find_process(container_name, find_redmine_project,
                           redmine_project_dict[container_name])
    for container_name in nagios_hosts_dict:
        start_find_process(container_name, find_nagios_hosts,
                           nagios_hosts_dict[container_name])
def main():
    config_data = get_config_info()
    MIN_SUPPORT_VALUE = int(config_data['min_support'])
    filename = config_data['filename']
    transactions = get_preprocessed_data(filename)
    location_time_star_items = get_location_time_star_items(transactions)
    t1 = datetime.datetime.now()
    final_itemsets = find_frequent_patterns_by_location_time(
        transactions, MIN_SUPPORT_VALUE)
    star_itemsets = get_star_itemsets(final_itemsets, location_time_star_items)
    zero_star_itemsets = star_itemsets[0]
    one_star_itemsets = star_itemsets[1]
    two_star_itemsets = star_itemsets[2]
    t2 = datetime.datetime.now()
    total_time = t2 - t1
    print(20 * '*')
    print('Total time taken in (microseconds) by fptree algorithm:',
          total_time.microseconds)
    print('Min support value:', MIN_SUPPORT_VALUE)
    print(20 * '*')
    print_table(zero_star_itemsets, 'Itemsets for CMB')
    print_table(one_star_itemsets, 'Itemsets for 1 star CMP')
    print_table(two_star_itemsets, 'Itemsets for 2 star')
コード例 #8
0
def setup_mysql57():
    """
    在宿主机安装 mysql5.7

    为什么不以docker安装database?
    测试时发现了很多问题。最终放弃了以docker方式安装 mysql5.7
    """

    base_dir = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, base_dir)

    print("在宿主机 mysql5.7 安装开始")
    cmd("yum install -y wget")
    cmd("wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm")
    cmd("yum -y install mysql57-community-release-el7-10.noarch.rpm")
    cmd("yum -y install mysql-community-server")
    print("在宿主机 mysql5.7 安装完成")

    cmd("systemctl start mysqld.service")
    config_info = get_config_info()
    root_password = config_info['mysql']['root_password']
    change_mysql_psw(root_password)
    print("在宿主机 mysql5.7 配置完成")

    cmd("mysqladmin -uroot -p'{}' create loonflow".format(root_password))
    init_sql = '/opt/loonflow/docker_compose_deploy/loonflow_shutongflow/loonflow-web/loonflow_demo_init.sql'
    cmd_str = "mysql -p'{}' -uroot loonflow < {}".format(
        root_password, init_sql)
    cmd(cmd_str)
    print("loonflow demo data write db ok")

    cmd("mysqladmin -uroot -p'{}' create shutongflow".format(root_password))
    init_sql = '/opt/loonflow/docker_compose_deploy/loonflow_shutongflow/shutongflow/shutongflow_demo_init.sql'
    cmd_str = "mysql -p'{}' -uroot shutongflow < {}".format(
        root_password, init_sql)
    cmd(cmd_str)
    print("shutongflow demo data write db ok")
def main():
    global MIN_SUPPORT_VALUE
    # preprocessing
    config_data = get_config_info()
    MIN_SUPPORT_VALUE = int(config_data['min_support'])
    filename = config_data['filename']
    transactions = get_transactions(filename)
    location_time_star_items = get_location_time_star_items(transactions)
    hash_ids = get_hash_ids(location_time_star_items)
    rev_hash_ids = get_rev_hash_ids(hash_ids)
    itemsets_by_hash_id = get_itemsets_by_hash_id(transactions, hash_ids)
    # base itemset
    two_items_itemsets_by_hash_id = get_two_items_itemsets_by_hash_id(
        itemsets_by_hash_id)
    # running spatio temporal apriori on base itemset
    t1 = datetime.datetime.now()
    final_itemsets_by_hash_id = get_final_itemsets_by_hash_id(
        two_items_itemsets_by_hash_id, itemsets_by_hash_id)
    star_itemsets_by_hash_id = get_star_itemsets_by_hash_id(
        final_itemsets_by_hash_id, location_time_star_items, hash_ids,
        rev_hash_ids)
    one_star_itemsets_by_hash_id = star_itemsets_by_hash_id[0]
    two_star_itemsets_by_hash_id = star_itemsets_by_hash_id[1]
    t2 = datetime.datetime.now()
    total_time = t2 - t1
    print(20 * '*')
    print(
        'Total time taken in (microseconds) by Hash Based Spatio-Temporal(HBST) algorithm:',
        total_time.microseconds)
    print('Min support value:', MIN_SUPPORT_VALUE)
    print(20 * '*')
    print_table(final_itemsets_by_hash_id, rev_hash_ids, 'Itemsets for CMB')
    print_table(one_star_itemsets_by_hash_id, rev_hash_ids,
                'Itemsets for 1 star CMP')
    print_table(two_star_itemsets_by_hash_id, rev_hash_ids,
                'Itemsets for 2 star')
コード例 #10
0
def get_container_list(yaml_path):
    container_list = utils.get_config_info(yaml_path).keys()

    return container_list