In the previous section on how to start the Appium service at the terminal, this section describes the important information in the command, how to value
Command appium-p 4700-bp 4701-u 611AKCPH234EC
The 4700,4701 is the start and end ports, whether the two ports have been used, and the available ports are generated.
(a) Determine if the port is available
To determine if the port is in use, use the command "Netstat-ano | findstr Port "
As shown below
Refer to the following script
defport_is_used (self,port_num):" "determine if the port is occupied: return:" "Flag=None Self.dos=doscmd () command='Netstat-ano | findstr'+Str (port_num) Reslut=self.dos.excute_cmd_result (command)ifLen (Reslut) >0:flag=TrueElse: Flag=FalsereturnFlag
View Code
(ii) generate an available port
Determine the number of devices connected, and then follow the device to add can port, give the port initial value
defcreate_port_list (self,start_port,device_list):" "Start_port 4700 generates an available port @:p arameter start_port @:p arameter device_list" "port_list= [] ifDevice_list! =None: whileLen (port_list)! =Len (device_list):ifself.port_is_used (start_port)! =True:port_list.append (start_port) Start_port= Start_port + 1returnport_listElse: Print('failed to generate an available port') returnNone
View Code
Within the range of devices, when generating an available port script, it is called to determine if a port is available, judging from the available port, starting with a value of +1 automatically after each fetch.
(iii) invoke an available port
Li = [1,2,3,4,5]print(port.create_port_list (4725,li))
Debugging prints out the available ports according to the number of devices.
Hope the little Master can help you to share.
Appium Terminal Start-up service (ii)