Exemplo n.º 1
0
    def __init__(self,server_address,server_port,server_database,server_user,server_password):
        self.server_address=server_address
        self.server_port = server_port
        self.server_database = server_database
        self.server_user = server_user
        self.server_password = server_password
        self.local_address=getlocaladdress()

        engine = create_engine('mssql+pymssql://'+str(self.server_user)+':'+str(self.server_password)+'@'+str(self.server_address)+':'+str(self.server_port)+'/'+str(self.server_database)+'?charset=utf8')
        # 创建DBSession类型:
        DBSession = sessionmaker(bind=engine)
        # 创建Session:
        self.session = DBSession()
Exemplo n.º 2
0
import os
import sys
import time
import traceback

import requests

from internetProgramming.FileDownClass import FileDownClass
from util.getlocalhostAddress import getlocaladdress

# 获得本机ip
local_address = getlocaladdress()

# 初始化控件放在服务器的地址
target_agent_address = "C:/TheoTestShell"

# 循环检测以及重连的间隔时间
time_load=5

while True:
    try:
        # 第一次连接,检查一下是否需要增加此agent节点的控件情况列表
        # 捏造参数,为了让服务器知道访问的IP是多少
        param_init={'agent_address':str(local_address)}
        # 制定的wepapi地址
        url_init = 'http://192.168.11.162:5001/initAgentPluginsSituation'
        # 携带参数调用api
        result_init = requests.post(url_init,data=param_init)

        while True:
Exemplo n.º 3
0
# 导入 socket、sys 模块
import socket
import sys

# 创建 socket 对象
from util.getlocalhostAddress import getlocaladdress

serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 绑定端口号
port = 5001
serversocket.bind((getlocaladdress(), port))

# 设置最大连接数,超过后排队
serversocket.listen(20)

while True:
    # 建立客户端连接
    clientsocket, addr = serversocket.accept()

    print("连接地址: %s" % str(addr))

    msg = '欢迎访问菜鸟教程!' + "\r\n"
    clientsocket.send(msg.encode('utf-8'))
    clientsocket.close()
    def initServer(self, maxNum):
        # 绑定端口号
        self.serversocket.bind((getlocaladdress(), self.port))

        # 设置最大连接数,超过后排队
        self.serversocket.listen(maxNum)