def main():
  optparser = optparse.OptionParser()
  optparser.add_option(
      '-r', '--reason', dest='reason', default='Unknown',
      help='Reason for brokenness.')
  optparser.add_option(
      '-d', '--detail-file', dest='detail_file',
      help='File with error details.')
  options, _ = optparser.parse_args()

  detail_parts = []

  if options.detail_file:
    try:
      detail_parts.append(
          'Failure detail:\n%s' % open(options.detail_file, 'r').read())
    except IOError as e:
      detail_parts.append(
          'Could not read detail file %r:\n%s' % (options.detail_file, e))


  return_code, stdout, stderr = flight_common.Exec(
      ['facter', '-p'], timeout=60, waitfor=0.5)
  facter_parts = [
      'Facter Return Code: %s' % return_code,
      stdout % 'Facter StdOut:\n%s',
  ]
  if stderr:
    facter_parts.append('Facter StdErr:\n%s' % stderr)
  detail_parts.append('\n\n'.join(facter_parts))

  details = ('\n\n' + ('*' * 60) + '\n\n').join(
      [part.strip() for part in detail_parts])
  params = {'details': details, 'reason': options.reason}

  url = flight_common.GetServerURL()
  c = client.SimianAuthClient(hostname=url)
  c.GetAuthToken()
  c.PostReport('broken_client', params)
  print 'Reported broken client to server.'
dataset/ETHPy150Open google/simian/src/simian/mac/client/report_broken_client.py/main/swapped operands of `%`