Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37283120 authored by Chih-hung Hsieh's avatar Chih-hung Hsieh Committed by Gerrit Code Review
Browse files

Merge "Use same warn_common.py and warn.py for Android and Chrome"

parents 71b4252b 5ae55196
Loading
Loading
Loading
Loading
+686 −0

File added.

Preview size limit exceeded, changes collapsed.

+12 −10
Original line number Diff line number Diff line
@@ -20,9 +20,6 @@ This file stores definition for class Severity that is used in warn_patterns.


# pylint:disable=old-style-class
class Severity:
  """Class of Severity levels where each level is a SeverityInfo."""

class SeverityInfo:

  def __init__(self, value, color, column_header, header):
@@ -31,13 +28,18 @@ class Severity:
    self.column_header = column_header
    self.header = header


# pylint:disable=old-style-class
class Severity:
  """Class of Severity levels where each level is a SeverityInfo."""

  # SEVERITY_UNKNOWN should never occur since every warn_pattern listed has
  # a specified severity. It exists for protobuf, the other values must
  # map to non-zero values (since 0 is reserved for a default UNKNOWN), but
  # logic in clang_tidy_warn.py assumes severity level values are consecutive
  # ints starting with 0.
  SEVERITY_UNKNOWN = SeverityInfo(0, 'blueviolet', 'Errors of unknown severity',
                                  'Unknown severity (should not occur)')
  SEVERITY_UNKNOWN = SeverityInfo(0, 'blueviolet', 'Unknown',
                                  'Unknown-severity warnings)')
  FIXMENOW = SeverityInfo(1, 'fuschia', 'FixNow',
                          'Critical warnings, fix me now')
  HIGH = SeverityInfo(2, 'red', 'High', 'High severity warnings')
+37 −7
Original line number Diff line number Diff line
@@ -17,21 +17,51 @@
"""Simple wrapper to run warn_common with Python standard Pool."""

import multiprocessing
import signal
import sys

# pylint:disable=relative-beyond-top-level
# pylint:disable=g-importing-member
from .warn_common import common_main
from . import warn_common as common


# This parallel_process could be changed depending on platform
# and availability of multi-process library functions.
def parallel_process(num_cpu, classify_warnings, groups):
def classify_warnings(args):
  """Classify a list of warning lines.

  Args:
    args: dictionary {
        'group': list of (warning, link),
        'project_patterns': re.compile(project_list[p][1]),
        'warn_patterns': list of warn_pattern,
        'num_processes': number of processes being used for multiprocessing }
  Returns:
    results: a list of the classified warnings.
  """
  results = []
  for line, link in args['group']:
    common.classify_one_warning(line, link, results, args['project_patterns'],
                                args['warn_patterns'])

  # After the main work, ignore all other signals to a child process,
  # to avoid bad warning/error messages from the exit clean-up process.
  if args['num_processes'] > 1:
    signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
  return results


def create_and_launch_subprocesses(num_cpu, classify_warnings_fn, arg_groups,
                                   group_results):
  pool = multiprocessing.Pool(num_cpu)
  return pool.map(classify_warnings, groups)
  for cpu in range(num_cpu):
    proc_result = pool.map(classify_warnings_fn, arg_groups[cpu])
    if proc_result is not None:
      group_results.append(proc_result)
  return group_results


def main():
  common_main(parallel_process)
  use_google3 = False
  common.common_main(use_google3, create_and_launch_subprocesses,
                     classify_warnings)


if __name__ == '__main__':
+593 −263

File changed.

Preview size limit exceeded, changes collapsed.