From 99b9a27e95dd88e0cebd98ac7f2aa63b62eb2486 Mon Sep 17 00:00:00 2001 From: zhangwenqing Date: Thu, 2 Apr 2020 15:46:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(Common)=EF=BC=9A"testClentIP"=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E5=8A=A8=E6=80=81=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tsg_common/LoginAndLogoutTypeSwitch.robot | 5 +++++ .../ExtensionLibrary/__init__.py | 7 +++++++ .../ExtensionPackages/ExtensionLibrary/mytool.py | 16 ++++++++++++++++ .../FileLibrary/__init__.py | 0 .../FileLibrary/filetool.py | 4 ---- .../ExtensionPackages/extensionLibrary.pth | 2 ++ 6 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 04-CustomLibrary/ExtensionPackages/ExtensionLibrary/__init__.py create mode 100644 04-CustomLibrary/ExtensionPackages/ExtensionLibrary/mytool.py rename 04-CustomLibrary/{ => ExtensionPackages}/FileLibrary/__init__.py (100%) rename 04-CustomLibrary/{ => ExtensionPackages}/FileLibrary/filetool.py (89%) create mode 100644 04-CustomLibrary/ExtensionPackages/extensionLibrary.pth 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