diff --git a/02-Keyword/tsg_common/LoginAndLogoutTypeSwitch.robot b/02-Keyword/tsg_common/LoginAndLogoutTypeSwitch.robot index 84617aa..ef387a4 100644 --- a/02-Keyword/tsg_common/LoginAndLogoutTypeSwitch.robot +++ b/02-Keyword/tsg_common/LoginAndLogoutTypeSwitch.robot @@ -2,12 +2,17 @@ Resource ../../03-Variable/BifangApiVariable.txt Library REST http://${host}:${port} Library Collections +Library ExtensionLibrary Resource ../tsg_bfapi/LoginLogout.robot Resource ../tsg_ui/Logout/Logout.robot Resource ../tsg_ui/Login/Login.robot *** Keywords *** LoginAndAddLocalIP + # 获取主机IP + ${ip} Get Host IP + Set Global Variable ${testClentIP} ${ip} + Run Keyword If '${loginType}' == 'api' ApiLoginAndAddLocalIP aa ... ELSE IF '${loginType}' == 'cli' CliLogin ... ELSE UiLoginAndAaddLocalIP bb diff --git a/04-CustomLibrary/ExtensionPackages/ExtensionLibrary/__init__.py b/04-CustomLibrary/ExtensionPackages/ExtensionLibrary/__init__.py new file mode 100644 index 0000000..b7bba48 --- /dev/null +++ b/04-CustomLibrary/ExtensionPackages/ExtensionLibrary/__init__.py @@ -0,0 +1,7 @@ +#coding=utf-8 +from mytool import mytool + +version = '1.0' + +class ExtensionLibrary(mytool): + ROBOT_LIBRARY_SCOPE = 'GLOBAL' \ No newline at end of file diff --git a/04-CustomLibrary/ExtensionPackages/ExtensionLibrary/mytool.py b/04-CustomLibrary/ExtensionPackages/ExtensionLibrary/mytool.py new file mode 100644 index 0000000..c399544 --- /dev/null +++ b/04-CustomLibrary/ExtensionPackages/ExtensionLibrary/mytool.py @@ -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 \ No newline at end of file diff --git a/04-CustomLibrary/FileLibrary/__init__.py b/04-CustomLibrary/ExtensionPackages/FileLibrary/__init__.py similarity index 100% rename from 04-CustomLibrary/FileLibrary/__init__.py rename to 04-CustomLibrary/ExtensionPackages/FileLibrary/__init__.py diff --git a/04-CustomLibrary/FileLibrary/filetool.py b/04-CustomLibrary/ExtensionPackages/FileLibrary/filetool.py similarity index 89% rename from 04-CustomLibrary/FileLibrary/filetool.py rename to 04-CustomLibrary/ExtensionPackages/FileLibrary/filetool.py index 56eadcf..de2e89b 100644 --- a/04-CustomLibrary/FileLibrary/filetool.py +++ b/04-CustomLibrary/ExtensionPackages/FileLibrary/filetool.py @@ -1,10 +1,6 @@ #coding=utf-8 -import sys -reload(sys) -sys.setdefaultencoding("utf-8") """ 变量文件操作 """ - class filetool(): def __init__(self): pass diff --git a/04-CustomLibrary/ExtensionPackages/extensionLibrary.pth b/04-CustomLibrary/ExtensionPackages/extensionLibrary.pth new file mode 100644 index 0000000..4569177 --- /dev/null +++ b/04-CustomLibrary/ExtensionPackages/extensionLibrary.pth @@ -0,0 +1,2 @@ +ExtensionLibrary +FileLibrary \ No newline at end of file