def network_check(target_server_ip):
    # 准备ip和端口
    address = (target_server_ip, 9526)
    # 创建socket对象
    client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    # 连接
    client_socket.connect(address)
    print('连接服务端成功')
    # 获取主板id
    board_id = Base.get_board_id()
    # 获取基本信息
    data = Base.get_network_info()
    # data的双引号转换为单引号
    data = data.replace('"', "'")
    # 组装发送的类型
    send_data = '{"typeCode":%d,"boardId":"%s","data":"%s"}' % (
        Type.NETWORK_INFO, board_id, data)
    # print(send_data)
    # 发送
    client_socket.send(send_data.encode('utf-8'))
    print('发送成功')

    # 关闭
    client_socket.close()
Exemple #2
0
        data = Base.get_register_info(board_id)
        typeCode = Type.REGISTER

    #基本信息
    elif ins == '2':
        data = Base.get_base_info()
        typeCode = Type.BASE_INFO

    #安装的软件
    elif ins == '3':
        data = Base.get_install_soft()
        typeCode = Type.INSTALLED_SOFT

    #网络信息
    elif ins == '4':
        data = Base.get_network_info()
        typeCode = Type.NETWORK_INFO

    #进程信息
    elif ins == '5':
        data = Base.get_process_info()
        typeCode = Type.PROCESS_INFO

    #服务信息
    elif ins == '6':
        data = Base.get_service_info()
        typeCode = Type.SERVICE_INFO

    #主机信息
    elif ins == '7':
        data = Base.get_host_info()