コード例 #1
0
ファイル: email.py プロジェクト: tquentin/dnstwister
def main():
    """Main code for worker."""
    while True:

        start = time.time()

        subs_iter = repository.isubscriptions()

        while True:

            try:
                sub = subs_iter.next()
            except StopIteration:
                print 'All subs processed in {} seconds'.format(
                    round(time.time() - start, 2))
                break

            if sub is None:
                break

            sub_id, sub_detail = sub

            try:
                process_sub(sub_id, sub_detail)
            except:
                print u'Skipping {}, exception:\n {}'.format(
                    sub_id, traceback.format_exc())

            time.sleep(1)

        time.sleep(datetime.timedelta(minutes=15).total_seconds())
コード例 #2
0
ファイル: email.py プロジェクト: thisismyrobot/dnstwister
def main():
    """Main code for worker."""
    while True:

        subs_iter = repository.isubscriptions()

        while True:

            try:
                sub = subs_iter.next()
            except StopIteration:
                print 'All subs processed'
                break

            if sub is None:
                break

            sub_id, sub_detail = sub

            try:
                process_sub(sub_id, sub_detail)
            except:
                print 'Skipping {}, exception:\n {}'.format(
                    sub_id, traceback.format_exc()
                )

            time.sleep(1)

        time.sleep(60)
コード例 #3
0
def increment_email_sub_deltas():
    """Add/increment domains found in delta reports for email subs.

    Return count of updated domains.
    """
    updated_domains = set()
    subs_iter = repository.isubscriptions()

    while True:
        try:
            sub = subs_iter.next()
        except StopIteration:
            break

        sub_detail = sub[1]
        domain = sub_detail['domain']

        updated_domains = process_domain(domain, updated_domains)

    return updated_domains
コード例 #4
0
    )

    # Mark as emailed to ensure we don't flood if there's an error after the
    # actual email has been sent.
    repository.update_last_email_sub_sent_date(sub_id)

    emailer.send(
        email_address, 'dnstwister report for {}'.format(domain), body
    )
    print 'Emailed delta for {} to {}'.format(domain, email_address)


if __name__ == '__main__':
    while True:

        subs_iter = repository.isubscriptions()

        while True:

            try:
                sub = subs_iter.next()
            except StopIteration:
                print 'All subs processed'
                break

            if sub is None:
                break

            sub_id, sub_detail = sub

            try: