forked from h080294/appium_python_android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.py
More file actions
38 lines (32 loc) · 1.32 KB
/
Copy pathServer.py
File metadata and controls
38 lines (32 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!usr/bin/python
# -*- coding:utf-8 -*-
from common.Log import *
import subprocess
import time
class Server:
def __init__(self, deviceobject):
self.logger = Log.logger
self._deviceobject = deviceobject
self._cmd = "appium -p %s -bp %s -U %s --session-override" % (
self._deviceobject.serverport, self._deviceobject.bootstrapport, self._deviceobject.deviceid)
def start(self):
self.kill(self._deviceobject.serverport)
time.sleep(3)
info = u"启动设备:%s 对应的Appium Server" % self._deviceobject.devicename
self.logger.info(info)
self.logger.info(self._cmd)
subprocess.call(self._cmd,shell=True)
def stop(self):
self.kill(self._deviceobject.serverport)
def kill(self, port):
cmd = "lsof -i:%s|awk 'NR==2{print $2}'" % port
self.logger.info(cmd)
pid = os.popen(cmd).read()
cmd = "kill -9 %s" % pid
os.popen(cmd).read()
def list_connect_devices(self):
info = u"已连接的设备: %s ------ %s" % (self._deviceobject.deviceid, self._deviceobject.devicename)
self.logger.info(info)
def list_disconnect_devices(self):
info = u"!!!设备丢失!!!: %s ------ %s" % (self._deviceobject.deviceid, self._deviceobject.devicename)
self.logger.info(info)