File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: Unlicense OR CC0-1.0
33# !/usr/bin/env python3
44# this file defines some functions for testing cli and br under pytest framework
5-
65import re
76import socket
87import struct
@@ -411,12 +410,15 @@ def host_publish_service() -> None:
411410
412411
413412def host_close_service () -> None :
414- command = " ps | grep avahi-publish-s | awk '{print $1}'"
413+ command = ' ps aux | grep avahi-publish-s'
415414 out_bytes = subprocess .check_output (command , shell = True , timeout = 5 )
416415 out_str = out_bytes .decode ('utf-8' )
417- the_pid = re .findall (r'(\d+)\n' , str (out_str ))
418- for pid in the_pid :
416+ service_info = [line for line in out_str .splitlines () if 'testxxx _testxxx._udp' in line ]
417+ for line in service_info :
418+ print ('Process:' , line )
419+ pid = line .split ()[1 ]
419420 command = 'kill -9 ' + pid
421+ print ('kill ' , pid )
420422 subprocess .call (command , shell = True , timeout = 5 )
421423 time .sleep (1 )
422424
You can’t perform that action at this time.
0 commit comments