Python config.port() Examples

The following are 8 code examples of config.port(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module config , or try the search function .
Example #1
Source File: threataggregator.py    From threataggregator with MIT License 6 votes vote down vote up
def sslblacklist(url, data):
    """ Parse SSLBlacklist CSV entries
    Format is:
    ip,port,description


    :param string url: URL for generic IP feed to include in DB entry
    :param list data: List of lines to parse
    :return:RepDB: A RepDB() instance containing threat information
    """
    repdb = RepDB()
    reader = csv.reader(data, delimiter=',')

    for line in reader:
        ipmatch = re.match(re_ipcidr, line[0])
        if ipmatch:
            ip = ipmatch.group(0)
            repdb.add(ip, url, line[2])
    return repdb 
Example #2
Source File: threataggregator.py    From threataggregator with MIT License 6 votes vote down vote up
def autoshun(url, data):
    """ Parse Autoshun CSV entries
    Format is:
    ip,port,description


    :param string url: URL for generic IP feed to include in DB entry
    :param list data: List of lines to parse
    :return: RepDB: A RepDB() instance containing threat information
    """
    repdb = RepDB()
    reader = csv.reader(data, delimiter=',')

    for line in reader:
        ipmatch = re.match(re_ipcidr, line[0])
        if ipmatch:
            ip = ipmatch.group(0)
            repdb.add(ip, url, line[2])
    return repdb 
Example #3
Source File: ip_crawl_tool.py    From SSTAP_ip_crawl_tool with GNU General Public License v3.0 5 votes vote down vote up
def update_data(self,exe_list,name_en,name_zh):
        

        host = config.server
        port = config.port# 设置端口号
        try:
            s.connect((host,port))
        #print(s.recv(1024))
        #print(self.de_msg(self.rec()))
            print('服务器连接成功')
        except:
            print('服务器连接失败')
            pass
        temp = '#{},{},0,0,1,0,1,0,By-ip_crawl_tool\n'.format(name_en,name_zh)
        while True:
            time.sleep(1)
            f = open("{}.rules".format(str(exe_list)), 'r',encoding='utf-8')
            f_temp = f.read()
            if f_temp != temp:#判断和上次传送结果是否重复,降低服务器压力
                temp = f_temp
                msg = {'rules':f_temp,'process':exe_list,'version':config.version}#加入进程名和版本号
                msg = self.en_msg(str(msg))
                s.send(msg)
                f.close()
                continue
        s.close() 
Example #4
Source File: conftest.py    From LibrERP with GNU Affero General Public License v3.0 5 votes vote down vote up
def __init__(self, config):
        # Prepare the connection to the server
        self.oerp = oerplib.OERP(config.host, protocol=config.protocol, port=config.port)

        # Login (the object returned is a browsable record)
        user = self.oerp.login(config.user, config.password, config.db_name) 
Example #5
Source File: vsphere-monitor.py    From vsphere-monitor with Apache License 2.0 5 votes vote down vote up
def hello_vcenter(vchost,username,password,port):
    try:
        si = SmartConnectNoSSL(
            host=vchost,
            user=username,
            pwd=password,
            port=port)

        atexit.register(Disconnect, si)
        return True, "ok"
    except vmodl.MethodFault as error:
        return False, error.msg
    except Exception as e:
        return False, str(e) 
Example #6
Source File: threataggregator.py    From threataggregator with MIT License 5 votes vote down vote up
def syslog(message):
    """ Send a UDP syslog packet

    :param string message: Sends a raw message to syslog
    :return:
    """
    level = LEVEL['info']
    facility = FACILITY['local0']

    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    # We have to encode as UTF8 for non-ascii characters.

    data = u'<%d>%s' % (level + facility * 8, message)
    s.sendto(data.encode('utf-8'),(config.host, config.port))
    s.close() 
Example #7
Source File: vsphere-monitor.py    From vsphere-monitor with Apache License 2.0 4 votes vote down vote up
def run(host,user,pwd,port,interval):
    try:
        si = SmartConnectNoSSL(host=host, user=user, pwd=pwd, port=port)
        atexit.register(Disconnect, si)
        content = si.RetrieveContent()
        vchtime = si.CurrentTime()

        perf_dict = {}
        perfList = content.perfManager.perfCounter
        for counter in perfList:
            counter_full = "{}.{}.{}".format(counter.groupInfo.key, counter.nameInfo.key, counter.rollupType)
            perf_dict[counter_full] = counter.key

        for datacenter in content.rootFolder.childEntity:
            datacenter_name = datacenter.name.encode("utf8")
            datastores = datacenter.datastore
            for ds in datastores:
                if (ds.name in config.datastore_names) or (len(config.datastore_names) == 0):
                    DatastoreInformation(ds,datacenter_name)

            if hasattr(datacenter.hostFolder, 'childEntity'):
                hostFolder = datacenter.hostFolder
                computeResourceList = []
                computeResourceList = getComputeResource(hostFolder,computeResourceList)
                for computeResource in computeResourceList:
                    ComputeResourceInformation(computeResource,datacenter_name,content,perf_dict,vchtime,interval)
         
        if config.vm_enable == True:
            obj = content.viewManager.CreateContainerView(content.rootFolder, [vim.VirtualMachine], True)
            for vm in obj.view:
                if (vm.name in config.vm_names) or (len(config.vm_names) == 0):
                    tags = "vm=" + vm.name
                    if vm.runtime.powerState == "poweredOn":
                        VmInfo(vm, content, vchtime, interval, perf_dict, tags)
                        add_data("vm.power",1,"GAUGE",tags)
                    else:
                        add_data("vm.power",0,"GAUGE",tags)               

    except vmodl.MethodFault as error:
        print "Caught vmodl fault : " + error.msg
        return False, error.msg
    return True, "ok" 
Example #8
Source File: threataggregator.py    From threataggregator with MIT License 4 votes vote down vote up
def process(db_add, db_del, db_equal):
    """ Processes RepDB entries in order for syslog, stdout, csv file, etc

    :param repDB db_add: RepDB entry to show added items
    :param repDB db_del: RepDB entry to show deleted items
    :param repDB db_equal: RepDB entry to show unchanged values
    """

    # fun toy for heatmaps later
    f = open('cache/coords.txt', 'w')
    count_add = 0
    count_del = 0
    count_equal = 0

    for line in db_add:

        for i in line:
            count_add += 1
            msg = buildcef('add', i)
            syslog(msg)
            if config.debug:
                printjson('add', i)
            f.write("%s %s\n" % (i['latitude'], i['longitude']))

    for line in db_del:
        for i in line:
            count_del += 1
            msg = buildcef('delete', i)
            if config.debug:
                printjson('delete', i)
            syslog(msg)

    for line in db_equal:
        for i in line:
            count_equal += 1
            msg = buildcef('update', i)
            syslog(msg)
            if config.debug:
                printjson('update', i)
            f.write("%s %s\n" % (i['latitude'], i['longitude']))

    f.close()
    print("Sent {0} New, {1} deleted, and {2} unchanged entries to {3}:{4}".format(
        count_add, count_del, count_equal, config.host, config.port))

# Only run code if invoked directly: This allows a user to import modules without having to run through everything