<commit_before>#!/usr/bin/env python3
# Copyright 2018 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.
"""
This is script to upload ninja_log from googler.

Server side implementation is in
https://cs.chromium.org/chromium/infra/go/src/infra/appengine/chromium_build_stats/

Uploaded ninjalog is stored in BigQuery table having following schema.
https://cs.chromium.org/chromium/infra/go/src/infra/appengine/chromium_build_stats/ninjaproto/ninjalog.proto

The log will be used to analyze user side build performance.
"""

import argparse
import gzip
import io
import json
import logging
import multiprocessing
import os
import platform
import subprocess
import sys
import time

from third_party.six.moves.urllib import request

# These build configs affect build performance.
ALLOWLISTED_CONFIGS = ('symbol_level', 'use_goma', 'is_debug',
                       'is_component_build', 'enable_nacl', 'host_os',
                       'host_cpu', 'target_os', 'target_cpu',
                       'blink_symbol_level', 'is_java_debug',
                       'treat_warnings_as_errors', 'disable_android_lint',
                       'use_errorprone_java_compiler', 'incremental_install')


def IsGoogler():
  """Check whether this user is Googler or not."""
  p = subprocess.run('goma_auth info',
                     capture_output=True,
                     text=True,
                     shell=True)
  if p.returncode != 0:
    return False
  lines = p.stdout.splitlines()
  if len(lines) == 0:
    return False
  l = lines[0]
  # |l| will be like 'Login as <user>@google.com' for googler using goma.
  return l.startswith('Login as ') and l.endswith('@google.com')


def ParseGNArgs(gn_args):<commit_msg>ninjalog_uploader: do not use capture_output and text<commit_after>#!/usr/bin/env python3
# Copyright 2018 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.
"""
This is script to upload ninja_log from googler.

Server side implementation is in
https://cs.chromium.org/chromium/infra/go/src/infra/appengine/chromium_build_stats/

Uploaded ninjalog is stored in BigQuery table having following schema.
https://cs.chromium.org/chromium/infra/go/src/infra/appengine/chromium_build_stats/ninjaproto/ninjalog.proto

The log will be used to analyze user side build performance.
"""

import argparse
import gzip
import io
import json
import logging
import multiprocessing
import os
import platform
import subprocess
import sys
import time

from third_party.six.moves.urllib import request

# These build configs affect build performance.
ALLOWLISTED_CONFIGS = ('symbol_level', 'use_goma', 'is_debug',
                       'is_component_build', 'enable_nacl', 'host_os',
                       'host_cpu', 'target_os', 'target_cpu',
                       'blink_symbol_level', 'is_java_debug',
                       'treat_warnings_as_errors', 'disable_android_lint',
                       'use_errorprone_java_compiler', 'incremental_install')


def IsGoogler():
  """Check whether this user is Googler or not."""
  p = subprocess.run('goma_auth info',
                     stdout=subprocess.PIPE,
                     universal_newlines=True,
                     shell=True)
  if p.returncode != 0:
    return False
  lines = p.stdout.splitlines()
  if len(lines) == 0:
    return False
  l = lines[0]
  # |l| will be like 'Login as <user>@google.com' for googler using goma.
  return l.startswith('Login as ') and l.endswith('@google.com')


def ParseGNArgs(gn_args):
{'fraction_non_alphanumeric': 0.09217343877829288, 'fraction_numerical': 0.00436323970548132, 'mean_word_length': 3.168181818181818, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, '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': '1960625', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1098, 'n_words': 327}