本文整理汇总了Python中config.port方法的典型用法代码示例。如果您正苦于以下问题:Python config.port方法的具体用法?Python config.port怎么用?Python config.port使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config
的用法示例。
在下文中一共展示了config.port方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sslblacklist
# 需要导入模块: import config [as 别名]
# 或者: from config import port [as 别名]
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
示例2: autoshun
# 需要导入模块: import config [as 别名]
# 或者: from config import port [as 别名]
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
示例3: update_data
# 需要导入模块: import config [as 别名]
# 或者: from config import port [as 别名]
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()
示例4: __init__
# 需要导入模块: import config [as 别名]
# 或者: from config import port [as 别名]
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)
示例5: hello_vcenter
# 需要导入模块: import config [as 别名]
# 或者: from config import port [as 别名]
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)
示例6: syslog
# 需要导入模块: import config [as 别名]
# 或者: from config import port [as 别名]
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()
示例7: run
# 需要导入模块: import config [as 别名]
# 或者: from config import port [as 别名]
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"
示例8: process
# 需要导入模块: import config [as 别名]
# 或者: from config import port [as 别名]
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