From 2971ffb19246aef0a1182579c60f84730920b487 Mon Sep 17 00:00:00 2001 From: yumiguan <41277086+yumiguan@users.noreply.github.com> Date: Fri, 12 Oct 2018 10:18:56 +0800 Subject: [PATCH] Modify way to get default application (#13) * Modify the way to get default application * update version name --- dev.sh | 26 +++++++++++++ .../config/comparison_table_model.json | 10 ++--- lyrebird_ios/ios_helper.py | 37 +------------------ lyrebird_ios/templates/index.html | 29 +++++---------- lyrebird_ios/ui.py | 30 +++++---------- setup.py | 2 +- 6 files changed, 52 insertions(+), 82 deletions(-) create mode 100644 dev.sh diff --git a/dev.sh b/dev.sh new file mode 100644 index 0000000..c77cf87 --- /dev/null +++ b/dev.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +echo "***************************" +echo " iOS setup start " +echo "***************************" + +# 如果已经有venv目录,删除此目录 +if [ -e "./venv/" ]; then +rm -rf ./venv/ +fi + +mkdir venv +python3 -m venv ./venv + +# 有些设备上虚拟环境中没有pip,需要通过easy_install安装 +if [ ! -e "./venv/bin/pip" ] ;then +echo "pip no exist, install pip with easy_install" +./venv/bin/easy_install pip +fi + +source ./venv/bin/activate +pip3 install -r ./requirements.txt + +echo "***************************" +echo " iOS setup finish " +echo "***************************" diff --git a/lyrebird_ios/config/comparison_table_model.json b/lyrebird_ios/config/comparison_table_model.json index 46e55b8..4f1c2bc 100644 --- a/lyrebird_ios/config/comparison_table_model.json +++ b/lyrebird_ios/config/comparison_table_model.json @@ -4,11 +4,11 @@ "iPhone3,3": "iPhone 4", "iPhone4,1": "iPhone 4S", "iPhone5,1": "iPhone 5", - "iPhone5,2": "iPhone 5 (GSM+CDMA)", - "iPhone5,3": "iPhone 5c (GSM)", - "iPhone5,4": "iPhone 5c (GSM+CDMA)", - "iPhone6,1": "iPhone 5s (GSM)", - "iPhone6,2": "iPhone 5s (GSM+CDMA)", + "iPhone5,2": "iPhone 5 GSM+CDMA", + "iPhone5,3": "iPhone 5c GSM", + "iPhone5,4": "iPhone 5c GSM+CDMA", + "iPhone6,1": "iPhone 5s GSM", + "iPhone6,2": "iPhone 5s GSM+CDMA", "iPhone7,1": "iPhone 6 Plus", "iPhone7,2": "iPhone 6", "iPhone8,1": "iPhone 6s", diff --git a/lyrebird_ios/ios_helper.py b/lyrebird_ios/ios_helper.py index 2ff2b46..d1e978c 100644 --- a/lyrebird_ios/ios_helper.py +++ b/lyrebird_ios/ios_helper.py @@ -158,7 +158,7 @@ def __init__(self, device_id): self._log_cache = [] self._log_crash_cache = [] self._log_file = None - self._screen_shot_file = os.path.abspath(os.path.join(tmp_dir, 'android_screenshot_%s.png' % self.device_id)) + self._screen_shot_file = None self._anr_file = None self._crash_file_list = [] self._device_info = None @@ -191,7 +191,6 @@ def read_line(cls, line): _device = cls(line) if len(device_info) < 2: _log.error(f'Read device info line error. {lines}') - raise libimobiledeviceError('Failed to got device info, Please make sure \'deviceinfo\' command is working on your system.') for info in device_info: info_kv = info.split(':') if info_kv[0] == 'ProductType': @@ -231,8 +230,6 @@ def log_handler(logcat_process): log_file.close() return - # self.crash_checker(line) - # self.anr_checker(line) self._log_cache.append(line.decode(encoding='UTF-8', errors='ignore')) if len(self._log_cache) >= 5000: @@ -242,24 +239,6 @@ def log_handler(logcat_process): self._log_cache = [] threading.Thread(target=log_handler, args=(p,)).start() - def crash_checker(self, line): - crash_log_path = os.path.join(crash_dir, 'android_crash_%s.log' % self.device_id) - - if str(line).find('FATAL EXCEPTION') > 0: - self.start_catch_log = True - self._log_crash_cache.append(str(line)) - lyrebird.publish('crash', 'android', path=crash_log_path, id=self.device_id) - elif str(line).find('AndroidRuntime') > 0 and self.start_catch_log: - self._log_crash_cache.append(str(line)) - else: - self.start_catch_log = False - with codecs.open(crash_log_path, 'w') as f: - f.write('\n'.join(self._log_crash_cache)) - - def anr_checker(self, line): - if str(line).find('ANR') > 0 and str(line).find('ActivityManager') > 0: - self.get_anr_log() - @property def device_info(self): if not self._device_info: @@ -309,20 +288,6 @@ def to_dict(self): prop_lines = self.device_info if not prop_lines: return device_info - - for line in prop_lines: - # 基带版本 - if 'ro.build.expect.baseband' in line: - baseband = line[line.rfind('[')+1:line.rfind(']')].strip() - device_info['baseBand'] = baseband - # 版本号 - if 'ro.build.id' in line: - build_id = line[line.rfind('[') + 1:line.rfind(']')].strip() - device_info['buildId'] = build_id - # Android 版本 - if 'ro.build.version.release' in line: - build_version = line[line.rfind('[') + 1:line.rfind(']')].strip() - device_info['releaseVersion'] = build_version return device_info diff --git a/lyrebird_ios/templates/index.html b/lyrebird_ios/templates/index.html index fb012cd..c8bcbd2 100644 --- a/lyrebird_ios/templates/index.html +++ b/lyrebird_ios/templates/index.html @@ -190,7 +190,7 @@