summaryrefslogtreecommitdiff
path: root/customlib/common/util.py
diff options
context:
space:
mode:
author董晓燕 <[email protected]>2021-06-03 09:55:45 +0000
committer董晓燕 <[email protected]>2021-06-03 09:55:45 +0000
commitac68e65f508799a0e555a240ae374d313a0a8d75 (patch)
tree2a339bbd8acd65e2fb235159cc9c5303ae5725b7 /customlib/common/util.py
parent2f39b56d617e5fba2b8d73d81cd5e6d894f85352 (diff)
parent4667c668725ff7cb673c637a297c67283876d4d4 (diff)
Merge branch 'develop' into 'master'HEADmaster
Develop See merge request dongxiaoyan/gap_tsg_api!4
Diffstat (limited to 'customlib/common/util.py')
-rw-r--r--customlib/common/util.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/customlib/common/util.py b/customlib/common/util.py
new file mode 100644
index 0000000..98befec
--- /dev/null
+++ b/customlib/common/util.py
@@ -0,0 +1,17 @@
+import socket
+import fcntl
+import struct
+import string
+
+def get_ip_address(ifname):
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ return socket.inet_ntoa(fcntl.ioctl(
+ s.fileno(),
+ 0x8915, # SIOCGIFADDR
+ struct.pack('256s', ifname[:15])
+ )[20:24])
+
+#get_ip_address('eth0') # '192.168.0.110'
+
+def source_str_is_cotain_destion_str(sourcestr,destionstr):
+ return string.find(sourcestr,destionstr)!=-1 \ No newline at end of file