returns `True` if the report should be sent.
328372
def is_valid(self):
        """"""
        if not self.total:
            return False
        if not self.contributor.freelanceprofile.is_freelance:
            return False
        return True
435773
def report(self, reason=None):
        
        url = self.reddit_session.config['report']
        data = {'id': self.fullname}
        if reason:
            data['reason'] = reason
        response = self.reddit_session.request_json(url, data=data)
        # Reported objects are automatically hidden as well
        # pylint: disable=W0212
        self.reddit_session.evict(
            [self.reddit_session.config['user'],
             urljoin(self.reddit_session.user._url, 'hidden')])
        # pylint: enable=W0212
        return response
425423
private void sendReport(@NonNull File report, boolean onlySendSilentReports) {
        if (enabled) {
            schedulerStarter.scheduleReports(report, onlySendSilentReports);
        } else {
            ACRA.log.w(LOG_TAG, "Would be sending reports, but ACRA is disabled");
        }
    }
938990
def _send(self, messages):
        """"""
        if len(messages) == 1:
            to_send = self._build_message(messages[0])
            if to_send is False:
                # The message was missing recipients.
                # Bail.
                return False
        else:
            pm_messages = list(map(self._build_message, messages))
            pm_messages = [m for m in pm_messages if m]
            if len(pm_messages) == 0:
                # If after filtering, there aren't any messages
                # to send, bail.
                return False
            to_send = PMBatchMail(messages=pm_messages)
        try:
            to_send.send(test=self.test_mode)
        except:
            if self.fail_silently:
                return False
            raise
        return True
290986
def submit_offline_reports(self):
        
        smtp_enabled = bool(self._smtp)
        hq_enabled = bool(self._hq)
        offline_reports = self.get_offline_reports()
        logging.info('Submitting %d offline crash reports' % len(offline_reports))
        offline_reports = offline_reports[:self.send_at_most]

        if smtp_enabled:
            try:
                smtp_success = self._smtp_send_offline_reports(*offline_reports)
            except Exception as e:
                logging.error(e)
                smtp_success = [False] * len(offline_reports)
        else:
            smtp_success = [True] * len(offline_reports)

        if hq_enabled:
            try:
                hq_success = self._hq_send_offline_reports(*offline_reports)
            except Exception as e:
                logging.error(e)
                hq_success = [False] * len(offline_reports)
        else:
            hq_success = [True] * len(offline_reports)

        remaining_reports = self.delete_offline_reports()
        success = [s1 and s2 for (s1, s2) in zip(smtp_success, hq_success)]
        logging.info('%d crash reports successfully submitted' % success.count(True))
        logging.info('%d crash reports remain to be submitted' % len(remaining_reports))
        return all(success)
662061
def _on_report(_loop, adapter, conn_id, report):
    """"""

    conn_string = None
    if conn_id is not None:
        conn_string = adapter._get_property(conn_id, 'connection_string')

    if isinstance(report, BroadcastReport):
        adapter.notify_event_nowait(conn_string, 'broadcast', report)
    elif conn_string is not None:
        adapter.notify_event_nowait(conn_string, 'report', report)
    else:
        adapter._logger.debug("Dropping report with unknown conn_id=%s", conn_id)
587491
def add_report(self, report, ignore_errors=False):
        """"""

        if not isinstance(report, SignedListReport):
            if ignore_errors:
                return

            raise ArgumentError("You can only add SignedListReports to a UTCAssigner", report=report)

        for reading in report.visible_readings:
            self.add_reading(reading)

        self.add_point(report.report_id, report.sent_timestamp, report.received_time)
842964
def _send(self, message):
        
        if not message.recipients():
            return False
        try:
            self.connection.sendmail(
                message.sender,
                message.recipients(),
                message.message().as_string(),
            )
        except Exception as e:
            logger.error(
                "Error sending a message to server %s:%s: %s",
                self.host,
                self.port,
                e,
            )
            if not self.fail_silently:
                raise
            return False
        return True
1282220
def publish_report(report, args, old_commit, new_commit):
    """"""
    # Print the report to stdout unless the user specified --quiet.
    output = ""

    if not args.quiet and not args.gist and not args.file:
        return report

    if args.gist:
        gist_url = post_gist(report, old_commit, new_commit)
        output += "\nReport posted to GitHub Gist: {0}".format(gist_url)

    if args.file is not None:
        with open(args.file, 'w') as f:
            f.write(report.encode('utf-8'))
        output += "\nReport written to file: {0}".format(args.file)

    return output
1286723
def send_report(self, report_parts):
        
        logger.info('Creating an email message')
        report_parts = sorted(
            filter(lambda x: x.fmt in self.formats, report_parts),
            key=lambda x: self.formats.index(x.fmt)
        )
        fmtname = '{0}-{1}.{2}' if len(report_parts) > 1 else '{0}.{2}'
        root_part = MIMEMultipart('mixed')
        root_part.preamble = 'This is a multi-part message in MIME format.'

        logger.debug('Creating the text/"text_type" parts')
        for i, text_part in enumerate(report_parts):
            attachment_name = fmtname.format(socket.gethostname(), i, text_part.ext)
            attach_part = MIMEText(text_part.text, text_part.ext, 'utf-8')
            attach_part.add_header('Content-Disposition', 'attachment', filename=attachment_name)
            root_part.attach(attach_part)

        if self.rawlogs:
            out = BytesIO()
            do_chunked_gzip(self.rawfh, out, filename=u'raw.log.gz')
            out.seek(0, os.SEEK_END)
            size = out.tell()

            if size > self.rawlogs_limit:
                logger.warning('%d is over the defined max of %r', size, self.rawlogs_limit)
                logger.warning('Not attaching the raw logs')
            else:
                logger.debug('Creating the application/x-gzip part')
                attach_part = MIMEBase('application', 'x-gzip')
                attach_part.set_payload(out.getvalue())

                from email.encoders import encode_base64

                logger.debug('Encoding the gzipped raw logs with base64')
                encode_base64(attach_part)
                attach_part.add_header('Content-Disposition', 'attachment', filename='raw.log.gz')
                root_part.attach(attach_part)

        if self.gpg_encrypt:
            import gpgme
            try:
                if self.gpg_keyringdir and os.path.exists(self.gpg_keyringdir):
                    logger.debug('Setting keyring dir to %r', self.gpg_keyringdir)
                    os.environ['GNUPGHOME'] = self.gpg_keyringdir

                cleartext = BytesIO(root_part.as_string().encode())
                ciphertext = BytesIO()

                ctx = gpgme.Context()
                ctx.armor = True

                if self.gpg_recipients:
                    recipients = [ctx.get_key(recipient) for recipient in self.gpg_recipients]
                else:
                    recipients = []
                    for key in ctx.keylist():
                        for subkey in key.subkeys:
                            if subkey.can_encrypt:
                                logger.debug('Found can_encrypt key = %d', subkey.keyid)
                                recipients.append(key)
                                break

                signers = [ctx.get_key(signer) for signer in self.gpg_signers]
                if signers:
                    logger.info('Encrypting and signing the report')
                    ctx.signers = signers
                    ctx.encrypt_sign(recipients, gpgme.ENCRYPT_ALWAYS_TRUST, cleartext, ciphertext)
                else:
                    logger.info('Encrypting the report')
                    ctx.encrypt(recipients, gpgme.ENCRYPT_ALWAYS_TRUST, cleartext, ciphertext)

                logger.debug('Creating the MIME envelope for PGP')

                gpg_envelope_part = MIMEMultipart('encrypted')
                gpg_envelope_part.set_param('protocol', 'application/pgp-encrypted', header='Content-Type')
                gpg_envelope_part.preamble = 'This is an OpenPGP/MIME encrypted message (RFC 2440 and 3156)'

                gpg_mime_version_part = MIMEBase('application', 'pgp-encrypted')
                gpg_mime_version_part.add_header('Content-Disposition', 'PGP/MIME version identification')
                gpg_mime_version_part.set_payload('Version: 1')

                gpg_payload_part = MIMEBase('application', 'octet-stream', name='encrypted.asc')
                gpg_payload_part.add_header('Content-Disposition', 'OpenPGP encrypted message')
                gpg_payload_part.add_header('Content-Disposition', 'inline', filename='encrypted.asc')
                gpg_payload_part.set_payload(ciphertext.getvalue())

                gpg_envelope_part.attach(gpg_mime_version_part)
                gpg_envelope_part.attach(gpg_payload_part)

                # envelope becomes the new root part
                root_part = gpg_envelope_part

            except ImportError:
                logger.error('Need crypto libraries for gpg_encrypt.')
                logger.error('Install pygpgme for GPG encryption support.')
                logger.error('Not mailing the report out of caution.')
                return

        # Define headers
        root_part['Date'] = formatdate()
        root_part['From'] = self.email_address
        root_part['To'] = ', '.join(self.mailto)
        root_part['Subject'] = '{0} system events: {1}'.format(
                socket.gethostname(), time.strftime('%c', time.localtime())
        )
        root_part['Message-Id'] = make_msgid()
        root_part['X-Mailer'] = u'{0}-{1}'.format(package_name, __version__)
        
        mail_message(self.smtp_server, root_part.as_string(), self.email_address, self.mailto)
        print('Mailed the report to: {0}'.format(','.join(self.mailto)))
954280
async def _report(self):
        
        while True:
            oldstatus = dict(self.status)
            stat = await self._updateq.get()
            if self._update_cb is not None and oldstatus != stat:
                # Each client gets its own copy of the dict.
                self.loop.create_task(self._update_cb(dict(stat)))
1223608
def report(self):
        
        aggregations = dict(
            (test, Counter().rollup(values))
            for test, values in self.socket_warnings.items()
        )
        total = sum(
            len(warnings)
            for warnings in self.socket_warnings.values()
        )

        def format_test_statistics(test, counter):
            return "%s:\n%s" % (
                test,
                '\n'.join(
                    '  - %s: %s' % (socket, count)
                    for socket, count in counter.items()
                )
            )

        def format_statistics(aggregations):
            return '\n'.join(
                format_test_statistics(test, counter)
                for test, counter in aggregations.items()
            )

        # Only print the report if there are actually things to report.
        if aggregations:
            print('=' * 70, file=self.stream)
            print(
                'NON-WHITELISTED SOCKETS OPENED: %s' % total,
                file=self.stream,
            )
            print('-' * 70, file=self.stream)
            print(format_statistics(aggregations), file=self.stream)
373833
def _check_send_batch(self, result=None):
        
        if (
            (self.batch_every_n and self.batch_every_n <= self._waitingMsgCount) or
            (self.batch_every_b and self.batch_every_b <= self._waitingByteCount)
        ):
            self._send_batch()
        return result
946139
def report_error(self, read_tuple_name, error_name, wrong="", message="", warning=False):
        
        if (not self.report_only_first) or (error_name not in self.reported_errors):
            print("\t".join(["error" if warning == False else "warning", read_tuple_name, error_name, wrong, message]))
        self.reported_errors.add(error_name)
        if warning:
            self.warning_has_been_reported = True
        else:
            self.error_has_been_reported = True
1204437
def posted(self):
        
        for who, record in self.logs:
            if record["field_name"] == "status" and record["added"] == "POST":
                return True
        return False
258250
public void reportSuccess() {
        connectionLock.lock();
        try {
            state = State.Success;
            condition.signalAll();
        }
        finally {
            connectionLock.unlock();
        }
    }
243866
public void report(ReportRequest req) {
    startIfStopped();
    statistics.totalReports.incrementAndGet();
    statistics.reportedOperations.addAndGet(req.getOperationsCount());
    Stopwatch w = Stopwatch.createStarted(ticker);
    boolean reported = reportAggregator.report(req);
    statistics.totalReportCacheUpdateTimeMillis.addAndGet(w.elapsed(TimeUnit.MILLISECONDS));
    if (!reported) {
      try {
        statistics.directReports.incrementAndGet();
        w.reset().start();
        transport.services().report(serviceName, req).execute();
        statistics.totalTransportedReportTimeMillis.addAndGet(w.elapsed(TimeUnit.MILLISECONDS));
      } catch (IOException e) {
        log.atSevere().withCause(e).log("direct send of a report request %s failed", req);
      }
    }

    if (isRunningSchedulerDirectly()) {
      try {
        scheduler.run(false /* don't block */);
      } catch (InterruptedException e) {
        log.atSevere().withCause(e).log("direct run of scheduler failed");
      }
    }
    logStatistics();
  }