tools/check_git_config.py
def upload_report(
    conf, report_url, verbose, push_works, push_log, push_duration_ms):
  """Posts report to the server, returns True if server accepted it.

  Uploads the report only if script is running in Google corp network. Otherwise
  just prints the report.
  """
  report = conf.copy()
  report.update(
      push_works=push_works,
      push_log=push_log,
      push_duration_ms=push_duration_ms)

  as_bytes = json.dumps({'access_check': report}, indent=2, sort_keys=True)
  if verbose:
    print('Status of git push attempt:')
    print(as_bytes)

  # Do not upload it outside of corp or if server side is already disabled.
  if not is_in_google_corp() or datetime.datetime.now() > UPLOAD_DISABLE_TS:
    if verbose:
      print (
          'You can send the above report to chrome-git-migration@google.com '
          'if you need help to set up you committer git account.')
    return True

  req = urllib2.Request(
      url=report_url,
      data=as_bytes,
      headers={'Content-Type': 'application/json; charset=utf-8'})

  attempt = 0
  success = False
  while not success and attempt < 10:
    attempt += 1
    try:
      logging.warning(
          'Attempting to upload the report to %s...',
          urlparse.urlparse(report_url).netloc)
      resp = urllib2.urlopen(req, timeout=5)
      report_id = None
      try:
        report_id = json.load(resp)['report_id']
      except (ValueError, TypeError, KeyError):
        pass
      logging.warning('Report uploaded: %s', report_id)
      success = True
    except (urllib2.URLError, socket.error, ssl.SSLError) as exc:
      logging.warning('Failed to upload the report: %s', exc)
  return success
Posts report to the server, returns True if server accepted it.

  Uploads the report only if script is running in Google corp network. Otherwise
  just prints the report.
  
Posts report to the server, returns True if server accepted it.
Uploads the report only if script is running in Google corp network. Otherwise
just prints the report.
Posts report to the server returns True if server accepted it . Uploads the report only if script is running in Google corp network . Otherwise just prints the report .
def upload_report(
    conf, report_url, verbose, push_works, push_log, push_duration_ms):
  report = conf.copy()
  report.update(
      push_works=push_works,
      push_log=push_log,
      push_duration_ms=push_duration_ms)
  as_bytes = json.dumps({'access_check': report}, indent=2, sort_keys=True)
  if verbose:
    print('Status of git push attempt:')
    print(as_bytes)
  if not is_in_google_corp() or datetime.datetime.now() > UPLOAD_DISABLE_TS:
    if verbose:
      print (
          'You can send the above report to chrome-git-migration@google.com '
          'if you need help to set up you committer git account.')
    return True
  req = urllib2.Request(
      url=report_url,
      data=as_bytes,
      headers={'Content-Type': 'application/json; charset=utf-8'})
  attempt = 0
  success = False
  while not success and attempt < 10:
    attempt += 1
    try:
      logging.warning(
          'Attempting to upload the report to %s...',
          urlparse.urlparse(report_url).netloc)
      resp = urllib2.urlopen(req, timeout=5)
      report_id = None
      try:
        report_id = json.load(resp)['report_id']
      except (ValueError, TypeError, KeyError):
        pass
      logging.warning('Report uploaded: %s', report_id)
      success = True
    except (urllib2.URLError, socket.error, ssl.SSLError) as exc:
      logging.warning('Failed to upload the report: %s', exc)
  return success
def upload_report ( conf , report_url , verbose , push_works , push_log , push_duration_ms ) : report = conf . copy ( ) report . update ( push_works = push_works , push_log = push_log , push_duration_ms = push_duration_ms ) as_bytes = json . dumps ( { 'access_check' : report } , indent = 2 , sort_keys = True ) if verbose : print ( 'Status of git push attempt:' ) print ( as_bytes ) if not is_in_google_corp ( ) or datetime . datetime . now ( ) > UPLOAD_DISABLE_TS : if verbose : print ( 'You can send the above report to chrome-git-migration@google.com ' 'if you need help to set up you committer git account.' ) return True req = urllib2 . Request ( url = report_url , data = as_bytes , headers = { 'Content-Type' : 'application/json; charset=utf-8' } ) attempt = 0 success = False while not success and attempt < 10 : attempt += 1 try : logging . warning ( 'Attempting to upload the report to %s...' , urlparse . urlparse ( report_url ) . netloc ) resp = urllib2 . urlopen ( req , timeout = 5 ) report_id = None try : report_id = json . load ( resp ) [ 'report_id' ] except ( ValueError , TypeError , KeyError ) : pass logging . warning ( 'Report uploaded: %s' , report_id ) success = True except ( urllib2 . URLError , socket . error , ssl . SSLError ) as exc : logging . warning ( 'Failed to upload the report: %s' , exc ) return success
Posts report to the server, returns True if server accepted it.
Posts report to the server returns True if server accepted it .
"""Posts report to the server, returns True if server accepted it.

  Uploads the report only if script is running in Google corp network. Otherwise
  just prints the report.
  """ # Do not upload it outside of corp or if server side is already disabled.
conf
report_url
verbose
push_works
push_log
push_duration_ms