def setUp(self): self.original_environ = os.environ.copy() os.environ['DISABLE_CLOUD_STORAGE_IO'] = '' self.setUpPyfakefs() self.fs.CreateFile( os.path.join(py_utils.GetCatapultDir(), 'third_party', 'gsutil', 'gsutil'))
def InitNode(self): if self.node_initialized: return # So we only init once per run self.node_initialized = True old_dir = os.path.abspath(os.curdir) os.chdir(os.path.join(os.path.abspath( py_utils.GetCatapultDir()), 'common', 'node_runner', 'node_runner')) subprocess.call([self.node_path, self.npm_path, 'install']) os.chdir(old_dir)
PARTNER_BUCKET = 'chrome-partner-telemetry' INTERNAL_BUCKET = 'chrome-telemetry' TELEMETRY_OUTPUT = 'chrome-telemetry-output' # Uses ordered dict to make sure that bucket's key-value items are ordered from # the most open to the most restrictive. BUCKET_ALIASES = collections.OrderedDict(( ('public', PUBLIC_BUCKET), ('partner', PARTNER_BUCKET), ('internal', INTERNAL_BUCKET), ('output', TELEMETRY_OUTPUT), )) BUCKET_ALIAS_NAMES = BUCKET_ALIASES.keys() _GSUTIL_PATH = os.path.join(py_utils.GetCatapultDir(), 'third_party', 'gsutil', 'gsutil') # TODO(tbarzic): A workaround for http://crbug.com/386416 and # http://crbug.com/359293. See |_RunCommand|. _CROS_GSUTIL_HOME_WAR = '/home/chromeos-test/' # If Environment variables has DISABLE_CLOUD_STORAGE_IO set to '1', any method # calls that invoke cloud storage network io will throw exceptions. DISABLE_CLOUD_STORAGE_IO = 'DISABLE_CLOUD_STORAGE_IO' # The maximum number of seconds to wait to acquire the pseudo lock for a cloud # storage file before raising an exception. LOCK_ACQUISITION_TIMEOUT = 10
import logging import os import re import signal import subprocess import sys import tempfile import urllib import py_utils from py_utils import atexit_with_log from py_utils import binary_manager _WPR_DIR = os.path.abspath( os.path.join(py_utils.GetCatapultDir(), 'web_page_replay_go')) TELEMETRY_PROJECT_CONFIG = os.path.join(py_utils.GetCatapultDir(), 'telemetry', 'telemetry', 'binary_dependencies.json') CHROME_BINARY_CONFIG = os.path.join(py_utils.GetCatapultDir(), 'common', 'py_utils', 'py_utils', 'chrome_binaries.json') RECORD = '--record' INJECT_SCRIPTS = '--inject_scripts=' class ReplayError(Exception): """Catch-all exception for the module."""
import logging import os import re import signal import subprocess import sys import tempfile import urllib import py_utils from py_utils import atexit_with_log from py_utils import binary_manager _WPR_DIR = os.path.abspath(os.path.join( py_utils.GetCatapultDir(), 'web_page_replay_go')) TELEMETRY_PROJECT_CONFIG = os.path.join( py_utils.GetCatapultDir(), 'telemetry', 'telemetry', 'binary_dependencies.json') CHROME_BINARY_CONFIG = os.path.join( py_utils.GetCatapultDir(), 'common', 'py_utils', 'py_utils', 'chrome_binaries.json') RECORD = '--record' INJECT_SCRIPTS = '--inject_scripts=' class ReplayError(Exception): """Catch-all exception for the module.""" pass
_UpdateSysPathIfNeeded() import py_utils from node_runner import node_util BASE_ESLINT_CMD = [ node_util.GetNodePath(), os.path.join(node_util.GetNodeModulesPath(), 'eslint', 'bin', 'eslint.js'), '--color' ] DEFAULT_ESLINT_CONFIG = os.path.join( py_utils.GetCatapultDir(), 'common', 'eslint', '.eslintrc') DEFAULT_ESLINT_RULES_DIR = os.path.join( py_utils.GetCatapultDir(), 'common', 'eslint', 'rules') def _CreateEslintCommand(config, rulesdir): return BASE_ESLINT_CMD + [ '--config', config, '--rulesdir', rulesdir ] def RunEslintOnDirs(dirs, config=DEFAULT_ESLINT_CONFIG,
import re import signal import subprocess import sys import time try: import fcntl except ImportError: fcntl = None import py_utils from py_utils import retry_util from py_utils import atexit_with_log _TSPROXY_PATH = os.path.join(py_utils.GetCatapultDir(), 'third_party', 'tsproxy', 'tsproxy.py') class TsProxyServerError(Exception): """Catch-all exception for tsProxy Server.""" pass def ParseTsProxyPortFromOutput(output_line): port_re = re.compile(r'Started Socks5 proxy server on ' r'(?P<host>[^:]*):' r'(?P<port>\d+)') m = port_re.match(output_line) if m: return int(m.group('port'))
_AddToPathIfNeeded(os.path.join(_CATAPULT_PATH, 'common', 'node_runner')) _AddToPathIfNeeded(os.path.join(_CATAPULT_PATH, 'common', 'py_utils')) _UpdateSysPathIfNeeded() import py_utils from node_runner import node_util BASE_ESLINT_CMD = [ node_util.GetNodePath(), os.path.join(node_util.GetNodeModulesPath(), 'eslint', 'bin', 'eslint.js'), '--color' ] DEFAULT_ESLINT_RULES_DIR = os.path.join(py_utils.GetCatapultDir(), 'common', 'eslint', 'rules') def _CreateEslintCommand(rulesdir, extra_args): eslint_cmd = BASE_ESLINT_CMD + [ '--rulesdir', rulesdir, '--ext', '.js,.html' ] if extra_args: eslint_cmd += [extra_args] return eslint_cmd def RunEslint(paths, rules_dir=DEFAULT_ESLINT_RULES_DIR, extra_args=None): if type(paths) is not list or len(paths) == 0: raise ValueError('Must specify a non-empty list of paths to lint.')
import signal import subprocess import sys import time try: import fcntl except ImportError: fcntl = None import py_utils from py_utils import retry_util from py_utils import atexit_with_log _TSPROXY_PATH = os.path.join( py_utils.GetCatapultDir(), 'third_party', 'tsproxy', 'tsproxy.py') class TsProxyServerError(Exception): """Catch-all exception for tsProxy Server.""" pass def ParseTsProxyPortFromOutput(output_line): port_re = re.compile( r'Started Socks5 proxy server on ' r'(?P<host>[^:]*):' r'(?P<port>\d+)') m = port_re.match(output_line) if m: return int(m.group('port'))