def get_pid(self, package_name):
"""
????pid
args:
- packageName -: ????
usage: getPid("com.android.settings")
"""
if system is "Windows":
pidinfo = self.shell(
"ps | findstr %s$" %
package_name).stdout.read()
else:
pidinfo = self.shell(
"ps | %s -w %s" %
(find_util, package_name)).stdout.read()
if pidinfo == '':
return "the process doesn't exist."
pattern = re.compile(r"\d+")
result = pidinfo.split(" ")
result.remove(result[0])
return pattern.findall(" ".join(result))[0]
评论列表
文章目录