Beispiel #1
0
def update_args_from_server(server):
    if not hasattr(server, 'result'):
        return

    parse_args().locale = server.result['locale']
    parse_args().firefox = server.result['firefox']
    parse_args().override = server.result['override']
    parse_args().port = int(server.result['port'])
    parse_args().email = server.result['email']
    parse_args().highlight = server.result['highlight']
    parse_args().mouse = float(server.result['mouse'])
    parse_args().report = server.result['report']
    parse_args().save = server.result['save']
    Settings.move_mouse_delay = parse_args().mouse
Beispiel #2
0
    def update_run_index(self, new_data=None):
        # Prepare the current entry.
        current_run = {
            'id': IrisCore.get_run_id(),
            'version': self.version,
            'build': self.build_id,
            'channel': self.fx_channel,
            'locale': self.fx_locale
        }

        # If this run is just starting, initialize with blank values
        # to indicate incomplete run.
        if new_data is None:
            logger.debug('Updating runs.json with initial run data.')
            current_run['total'] = '*'
            current_run['failed'] = '*'
        else:
            logger.debug('Updating runs.json with completed run data.')
            current_run['total'] = new_data['total']
            current_run['failed'] = new_data['failed']

        # Temporary code to deal with legacy runs.json file.
        # It will be removed before launch.
        old_js_folder = os.path.join(parse_args().workdir, 'js')
        if os.path.exists(old_js_folder):
            shutil.rmtree(old_js_folder, ignore_errors=True)

        run_file = os.path.join(parse_args().workdir, 'data', 'all_runs.json')

        if os.path.exists(run_file):
            logger.debug('Updating run file: %s' % run_file)
            with open(run_file, 'r') as f:
                run_file_data = json.load(f)
            for run in run_file_data['runs']:
                if run['id'] == IrisCore.get_run_id():
                    run_file_data['runs'].remove(run)
            run_file_data['runs'].append(current_run)
        else:
            logger.debug('Creating run file: %s' % run_file)
            run_file_data = {'runs': []}
            run_file_data['runs'].append(current_run)

        with open(run_file, 'w') as f:
            json.dump(run_file_data, f, sort_keys=True, indent=True)
Beispiel #3
0
def control_center():
    if len(sys.argv) > 1 and not parse_args().control:
        return True, None
    else:
        dir_util.copy_tree(os.path.join(IrisCore.get_module_dir(), 'iris', 'cc_files'), parse_args().workdir)
        profile_path = os.path.join(parse_args().workdir, 'cc_profile')

        fx_path = get_local_firefox_path()
        if fx_path is None:
            logger.error('Can\'t find local Firefox installation, aborting Iris run.')
            return False, None

        fx_runner = launch_firefox(fx_path, profile=profile_path, url=IrisCore.get_base_local_web_url())
        fx_runner.start()
        server = LocalWebServer(parse_args().workdir, parse_args().port)
        quit_firefox()
        status = fx_runner.process_handler.wait(Settings.FIREFOX_TIMEOUT)
        if status is None:
            logger.debug('Firefox did not quit. Executing force quit.')
            fx_runner.stop()

        if server.result == 'cancel':
            logger.info('Canceling Iris run.')
            return False, None
        else:
            logger.debug('Received data from control center: %s' % server.result)
            update_args_from_server(server)
            tests = sorted(server.result['tests'])
            test_packages = []
            test_list = []
            if len(tests):
                for package in tests:
                    test_packages.append(package)
                    for test in server.result['tests'][package]:
                        test_list.append(test['name'])
            return True, test_list
Beispiel #4
0
 def initialize_platform(self):
     self.args = parse_args()
     self.module_dir = IrisCore.get_module_dir()
     self.platform = get_platform()
     self.os = Settings.get_os()
     self.create_working_directory()
     self.create_run_directory()
     initialize_logger(LOG_FILENAME, self.args.level)
     IrisCore.create_profile_cache()
     Iris.process_list = []
     self.local_web_root = os.path.join(self.module_dir, 'iris', 'local_web')
     self.base_local_web_url = 'http://127.0.0.1:%s' % self.args.port
     self.create_test_json()
     self.create_arg_json()
     self.test_list = []
     self.test_packages = []
Beispiel #5
0
 def __init__(self):
     self.args = parse_args()
     initialize_logger(LOG_FILENAME, self.args.level)
     self.process_list = []
     self.check_keyboard_state()
     self.init_tesseract_path()
     self.check_7zip()
     self.module_dir = get_module_dir()
     self.platform = get_platform()
     self.os = Settings.getOS()
     self.local_web_root = os.path.join(self.module_dir, 'iris', 'local_web')
     self.base_local_web_url = 'http://127.0.0.1:%s' % self.args.port
     self.start_local_web_server(self.local_web_root, self.args.port)
     self.main()
     self.create_run_directory()
     run(self)
Beispiel #6
0
def run_iris():
    """Runs Iris."""
    use_control_center, tests_list = control_center()
    if use_control_center:
        start_local_web_server(parse_args().port)
        if tests_list is not None and len(tests_list) > 0:
            tests = tests_list
        else:
            tests, packages = load_tests(master_test_list)
            if len(tests) == 0:
                logger.error('Specified tests not found, aborting run.')
                finish(1)
        try:
            browser = FirefoxApp()
            run(master_test_list, tests, browser)
        except (ValueError, KeyboardInterrupt):
            finish(1)
    else:
        IrisCore.delete_run_directory()
        finish(0)