Exemplo n.º 1
0
 def setup(self):
     print('test start')
     uid = device_info_util.get_serial_numbers_android()
     config_path = os.path.join(os.path.dirname(__file__), 'testdata',
                                'config', 'NBA_Android_config.yml')
     config = Config(config_path, uid[0])
     screenshot = os.path.join(os.path.dirname(__file__),
                               'testdata\\screenshot')
     if not os.path.exists(screenshot):
         os.mkdir(screenshot)
     self.driver = Appium(config.appium_desired_caps())
Exemplo n.º 2
0
 def test_serial_numbers_android(self):
     res = get_serial_numbers_android()
     print(res)
     assert isinstance(res, Sequence)
     assert len(res) >= 0
Exemplo n.º 3
0
 def setup(self):
     print('Test start.')
     # config_path = '/Users/jameszhang/python/project/appCrawler/test/testdata/config/NBA_Android_config.yml'
     config_path = os.path.join(os.path.dirname(__file__), 'testdata/config', 'NBA_Android_config.yml')
     uid = device_info_util.get_serial_numbers_android()
     self.config = Config(config_path, uid[0])
Exemplo n.º 4
0
def main():
    print_spider()
    try:
        params_dict = cmd_parse()
    except FilePathInvalid as msg:
        log.error(msg)
    else:
        config_path = params_dict.get('config')
        # default 2 minutes.
        timer = int(params_dict.get('timer', 2))
        # default 5 threads.
        max_workers = int(params_dict.get('max_workers', 5))
        # default dfs
        travel_mode = params_dict.get('travel_mode', 'mixture')
        support_mode = {'mixture', 'dfs', 'bfs'}

        if travel_mode not in support_mode:
            _origin_mode = travel_mode
            travel_mode = support_mode.pop()
            log.warning(
                f"{_origin_mode} travel mode is not support, set travel mode to {travel_mode}"
            )
        Crawler.travel_mode = travel_mode

        futures_map = dict()
        config = Config(config_path=config_path)
        devices_list = list()
        platform = config.platformName
        if platform == 'Android':
            devices_list = get_serial_numbers_android()
        elif platform == 'iOS':
            devices_list = get_serial_numbers_ios()
        else:
            log.error("Not support {} platform".format(platform))

        if not devices_list:
            log.warning("Not find any device.")
        else:
            with futures.ThreadPoolExecutor(max_workers) as executor:
                futures_list = []
                for serial in devices_list:
                    future = executor.submit(performer, config_path, serial,
                                             timer)
                    futures_map[future] = serial
                    futures_list.append(future)

                for future in futures.as_completed(futures_list):
                    print(futures_map.get(future))
                    report_dir, record = future.result()
                    json_gene = GenerateJson(report_dir, record)
                    json_gene.insert_crash_log()
                    json_gene.generate_json()

                    # generate report
                    report = Report(report_dir=report_dir)
                    try:
                        report.clear_expired_report(expired_day=3)
                    except Exception as exc:
                        log.error(exc)
                    finally:
                        report.generate_report()

            kill_adb_server()
            log.warning("All test end.")
 def setup(self):
     print('test start!')
     udid = get_serial_numbers_android()[0]
     self.log = LogAndroid(udid)
     self.log.clear_log()