<commit_before># Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import logging
import re

from telemetry import decorators
from telemetry.timeline import trace_data as trace_data_module
from telemetry.core.backends.chrome_inspector import devtools_http
from telemetry.core.backends.chrome_inspector import inspector_backend
from telemetry.core.backends.chrome_inspector import tracing_backend
from telemetry.core.platform.tracing_agent import chrome_tracing_agent


def IsDevToolsAgentAvailable(port):
  """Returns True if a DevTools agent is available on the given port."""
  return _IsDevToolsAgentAvailable(devtools_http.DevToolsHttp(port))


def _IsDevToolsAgentAvailable(devtools_http_instance):
  try:
    devtools_http_instance.Request('', timeout=.1)
  except devtools_http.DevToolsClientConnectionError:
    return False
  else:
    return True


class DevToolsClientBackend(object):
  def __init__(self, devtools_port, remote_devtools_port, app_backend):
    """Creates a new DevToolsClientBackend.<commit_msg>[Telemetry] Increase the timeout amount for devtool alive check from 0.1s to 30s<commit_after># Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import logging
import re

from telemetry import decorators
from telemetry.timeline import trace_data as trace_data_module
from telemetry.core.backends.chrome_inspector import devtools_http
from telemetry.core.backends.chrome_inspector import inspector_backend
from telemetry.core.backends.chrome_inspector import tracing_backend
from telemetry.core.platform.tracing_agent import chrome_tracing_agent


def IsDevToolsAgentAvailable(port):
  """Returns True if a DevTools agent is available on the given port."""
  return _IsDevToolsAgentAvailable(devtools_http.DevToolsHttp(port))


# TODO(nednguyen): Find a more reliable way to check whether the devtool agent
# is still alive.
def _IsDevToolsAgentAvailable(devtools_http_instance):
  try:
    devtools_http_instance.Request('')
  except devtools_http.DevToolsClientConnectionError:
    return False
  else:
    return True


class DevToolsClientBackend(object):
  def __init__(self, devtools_port, remote_devtools_port, app_backend):
    """Creates a new DevToolsClientBackend.
{'fraction_non_alphanumeric': 0.05702479338842975, 'fraction_numerical': 0.005371900826446281, 'mean_word_length': 6.037790697674419, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6820132', 'n_tokens_mistral': 696, 'n_tokens_neox': 666, 'n_words': 219}