TA的每日心情 | 开心 2017-1-13 09:34 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
import xml.etree.ElementTree as ET
import os
import sys
import subprocess as sp
import time
import logging
import re
import codecs
import datetime
import ui_hooks
import socket
import threading
WINDOW_FACTOR = ['index', 'text', 'resource-id', 'class', 'package', 'visible', 'content-desc', 'checkable',
'checked', 'clickable', 'enabled', 'focusable', 'focused', 'scrollable', 'long-clickable',
'password', 'bottom', 'selected', 'bounds']
RETRY_MAX_TIME = 3
def get_data(address):
result={}
temp = ''
f1 = open(address,'r')
temp = f1.read()
result = eval(temp)
f1.close()
return result
class Operator:
def __init__(self,device_id='',log_class=None,log_path='',**kwargs):
self.device_id = device_id
self.log_class = log_class
self.log_path = log_path
self.current_path = os.path.dirname(__file__)
self.home_dir = os.path.expanduser('~')
if not os.path.isdir(self.log_path):
try:
os.makedirs(log_path)
except OSError:
pass
self.failure_pic_location = os.path.join(self.log_path,'screenshots')
if not os.path.isdir(self.failure_pic_location):
try:
os.makedirs(self.failure_pic_location)
except OSError:
pass
self.temporary = os.path.join(self.log_path,'temp')
if not os.path.isdir(self.temporary):
try:
os.makedirs(self.temporary)
except OSError:
pass
self.hooks = ui_hooks.Hooks(self.device_id)
def get_instance(self):
op = Operator(self.device_id,self.log_class,self.log_path)
return op
def decode_utf(self,var):
utype = codecs.lookup("utf-8")
return utype.decode(var)[0]
def update_dictory(self,dictory):
keys_list = dictory.keys()
values_list = dictory.values()
temp={}
for i in range(len(keys_list)):
temp[keys_list] = self.decode_utf(values_list)
return temp
def search(self,**kwargs):
|
|