def get_prop():
    from adb_utils.adb_helper import ch_2_abd_dir
    ch_2_abd_dir()
    dev_props = os.popen('adb shell getprop')
    with open('dev_prop.prop.txt', 'w') as prop_file:
        error_cnt = 0
        line_index = 0
        while True:
            line_index += 1
            try:
                prop = dev_props.readline()
            except:
                error_cnt += 1
                print(
                    'Warning: ====================Error {error_num}-{index}====================='
                    .format(error_num=error_cnt, index=line_index))
                with open('dev_prop.prop.error.txt', 'a') as error_file:
                    import time
                    error_file.writelines(
                        'Error {error_num} at line {line_idx} : Unicode cannot decode at {local_time}\n'
                        .format(line_idx=line_index,
                                error_num=error_cnt,
                                local_time=time.strftime(
                                    "%Y-%m-%d %H:%M:%S", time.localtime())))
                continue
            print(prop)
            if prop == '':
                break
            prop_file.write(prop)
def open_accordant_config():
    """
    调用配置文件
    """
    from adb_utils.adb_helper import ch_2_abd_dir
    ch_2_abd_dir()
    screen_size = _get_screen_size()
    config_file = "{path}/config/{screen_size}/config.json".format(
        path=sys.path[0], screen_size=screen_size)
    if os.path.exists(config_file):
        with open(config_file, 'r') as f:
            print("Load config file from {}".format(config_file))
            return json.load(f)
    else:
        with open('{}/config/default.json'.format(sys.path[0]), 'r') as f:
            print("Load default config")
            return json.load(f)
Exemple #3
0
def check_screenshot():
    """
    检查获取截图的方式
    """
    global SCREENSHOT_WAY
    from adb_utils.adb_helper import ch_2_abd_dir
    ch_2_abd_dir()
    if os.path.isfile(SCREENSHOT_NAME):
        try:
            os.remove(SCREENSHOT_NAME)
        except Exception:
            pass
    if SCREENSHOT_WAY < 0:
        print('暂不支持当前设备')
        sys.exit()
    pull_screenshot()
    try:
        Image.open('./%s' % SCREENSHOT_NAME).load()
        # print('采用方式 {} 获取截图'.format(SCREENSHOT_WAY))
    except Exception:
        SCREENSHOT_WAY -= 1
        check_screenshot()
from time import sleep

from adb_utils.adb_helper import ch_2_abd_dir
from adb_utils.adb_inputter import input_text
from greeting_procer.procer import load_greetings
from img_procer.checker import check_title_bar_green_line
from img_procer.screenshot import check_screenshot
from operations.oper import *

print('初始化')
ch_2_abd_dir()
check_screenshot()
sleep(0.1)

print('============================================')
print('                 问候')

start_config = input(
    '请确认在微信的主界面并且输入法已调至ADB IME/ADB Keyboard\n确认开始? (输入y) \n 否则输入任意其他字符\n')
if start_config != 'y':
    print('再见')
    exit(-1)
print('============================================')

click_wechat_nav_home()

sleep(0.5)

click_wechat_title_bar_search()

contacts = load_greetings(