Appium Terminal Start-up service (ii)

Source: Internet
Author: User
Tags appium

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.