def __init__(self, enabled, jar, html_dir, check_css, show_warnings, java_binary, java_stack): self.enabled = enabled self.jar = jar self.html_dir = html_dir self.java = java_binary self.db_conn = None self.queue_current_size = 0 self.queue_max_size = 40 self.vnu_version = "" if not self.enabled: return self.vnu_version = self._check_vnu() stack_size = "-Xss%sk" % java_stack command_parts = [self.java, stack_size, "-jar", self.jar, "--format", "json", "--exit-zero-always"] if check_css: command_parts.append("--also-check-css") if not show_warnings: command_parts.append("--errors-only") command_parts.append(self.html_dir) self.vnu_command_parts = command_parts filesystem_utils.clean_directory(self.html_dir)
def __init__(self): subdir = "port_%s" % config.chrome_debugging_port self.html_dir = path.join(config.validator_html_dir, subdir) self.db_conn = None self.queue_current_size = 0 self.queue_max_size = 40 self.vnu_version = "" if not config.validator_enabled: return self.vnu_version = self._check_vnu() stack_size = "-Xss%sk" % config.java_stack_size command_parts = [ config.java_binary, stack_size, "-jar", config.validator_vnu_jar, "--format", "json", "--exit-zero-always" ] if config.validator_check_css: command_parts.append("--also-check-css") if not config.validator_show_warnings: command_parts.append("--errors-only") command_parts.append(self.html_dir) self.vnu_command_parts = command_parts filesystem_utils.clean_directory(self.html_dir)
def _execute_vnu(self): if self.queue_current_size == 0: return [] print("[INFO] Running HTML validator on %s files" % self.queue_current_size) parsed = json.loads(self._get_vnu_json_result()) logs = [] for msg in parsed["messages"]: logs.append(self._parse_output_message(msg)) filesystem_utils.clean_directory(self.html_dir) self.queue_current_size = 0 return logs
def start_session(self): self.debugger_socket.close_existing_session() filesystem_utils.clean_directory(self.profile_dir) chrome_log = open(self.log_file, "w") try: Popen(self.command_parts, stdout=chrome_log, stderr=chrome_log) except OSError: message = "Chrome not found at location: %s" % self.chrome message += "\nFind location of Chrome/Chromium in your system and configure it in:" message += "\n* config/default.ini file (option: chrome_binary)" message += "\n* or command line parameter --chrome-binary" error_utils.exit_with_message(message) self._print_start_message() self.debugger_socket.connect_to_remote_debugger() self._enable_features()
def _start_browser(self): self._check_chrome_binary_set() filesystem_utils.clean_directory(self._profile_dir) self._exec_command()
def create(self): if not self.keep_previous: filesystem_utils.clean_directory(self.output_data) filesystem_utils.try_make_dir(self.current)
def create(self): if not config.keep_previous_data: filesystem_utils.clean_directory(config.output_data) filesystem_utils.try_make_dir(self.current) config.current_data_dir = self.current config.current_data_subdir = self.current_subdir