feat(Common):"testClentIP"变量动态获取
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
#coding=utf-8
|
||||
from mytool import mytool
|
||||
|
||||
version = '1.0'
|
||||
|
||||
class ExtensionLibrary(mytool):
|
||||
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
|
||||
@@ -0,0 +1,16 @@
|
||||
#coding=utf-8
|
||||
import socket
|
||||
|
||||
""" 获取主机信息 """
|
||||
class mytool():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def get_host_IP(self):
|
||||
try:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
s.connect(('8.8.8.8', 80))
|
||||
ip = s.getsockname()[0]
|
||||
finally:
|
||||
s.close()
|
||||
return ip
|
||||
@@ -0,0 +1,7 @@
|
||||
#coding=utf-8
|
||||
from filetool import filetool
|
||||
|
||||
version = '1.0'
|
||||
|
||||
class FileLibrary(filetool):
|
||||
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
|
||||
23
04-CustomLibrary/ExtensionPackages/FileLibrary/filetool.py
Normal file
23
04-CustomLibrary/ExtensionPackages/FileLibrary/filetool.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#coding=utf-8
|
||||
|
||||
""" 变量文件操作 """
|
||||
class filetool():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def alter_dict(self, path, k, v):
|
||||
data = ''
|
||||
flag = True
|
||||
key = '${%s}' % (k)
|
||||
add = key + '\t%s' % (v) + '\n'
|
||||
with open(path, 'r+') as f:
|
||||
for line in f.readlines():
|
||||
if(line.find(key + '\t') == 0):
|
||||
line = add
|
||||
flag = False
|
||||
data += line
|
||||
if(flag):
|
||||
data += add
|
||||
print data
|
||||
with open(path, 'w+') as f:
|
||||
f.writelines(data)
|
||||
2
04-CustomLibrary/ExtensionPackages/extensionLibrary.pth
Normal file
2
04-CustomLibrary/ExtensionPackages/extensionLibrary.pth
Normal file
@@ -0,0 +1,2 @@
|
||||
ExtensionLibrary
|
||||
FileLibrary
|
||||
Reference in New Issue
Block a user