Пример #1
0
def send_email_by_sendgrid():
    """
    Send email via SendGrid
    """
    sendgrid_cli_args = SendGridCliArgs()

    github_email_template = get_email_template(sendgrid_cli_args.template_path)
    metadata = github_email_template.metadata
    # List first
    if metadata['user']:
        print "Send email by list..."
        ges = parse_into_github_user_emails(metadata['user'])
        print 'Total email addresses from list: {}'.format(len(ges))
        send_sendgrid_by_ges(github_user_emails=ges,
                             sendgrid_api_key=sendgrid_cli_args.api_key,
                             github_email_template=github_email_template)

    else:
        print "Send email by exploring..."
        # explore users email by action types
        github_api_auth = (sendgrid_cli_args.client_id,
                           sendgrid_cli_args.client_secret)
        ges = github_email.collect_email_info(metadata['repository_owner'],
                                              metadata['repository_name'],
                                              sendgrid_cli_args.action_type,
                                              github_api_auth)
        print 'Total: {}/{}'.format(len([ge for ge in ges if ge.email]),
                                    len(ges))

        # send email by py-sendgrid
        send_sendgrid_by_ges(github_user_emails=ges,
                             sendgrid_api_key=sendgrid_cli_args.api_key,
                             github_email_template=github_email_template)
Пример #2
0
def send_email_by_sendgrid():
    """
    Send email via SendGrid
    """
    sendgrid_cli_args = SendGridCliArgs()

    github_email_template = get_email_template(sendgrid_cli_args.template_path)
    metadata = github_email_template.metadata
    # List first
    if metadata['user']:
        print "Send email by list..."
        ges = parse_into_github_user_emails(metadata['user'])
        print 'Total email addresses from list: {}'.format(len(ges))
        send_sendgrid_by_ges(github_user_emails=ges,
                             sendgrid_api_key=sendgrid_cli_args.api_key,
                             github_email_template=github_email_template)

    else:
        print "Send email by exploring..."
        # explore users email by action types
        github_api_auth = (sendgrid_cli_args.client_id, sendgrid_cli_args.client_secret)
        ges = github_email.collect_email_info(metadata['repository_owner'], metadata['repository_name'], sendgrid_cli_args.action_type, github_api_auth)
        print 'Total: {}/{}'.format(len([ge for ge in ges if ge.email]), len(ges))

        # send email by py-sendgrid
        send_sendgrid_by_ges(github_user_emails=ges,
                             sendgrid_api_key=sendgrid_cli_args.api_key,
                             github_email_template=github_email_template)
Пример #3
0
def get_github_email_by_repo():
    """ Get user email by repos
    """
    explore_cli_args = ExploreCliArgs()

    github_api_auth = (explore_cli_args.client_id, explore_cli_args.client_secret)

    if explore_cli_args.status:
        # call api status
        status = github_email.api_status(github_api_auth)
        table = [["Core", status.core_limit, status.core_remaining, datetime.utcfromtimestamp(status.core_reset_time).strftime('%Y-%m-%dT%H:%M:%SZ')],
                 ["Search", status.search_limit, status.search_remaining, datetime.utcfromtimestamp(status.search_reset_time).strftime('%Y-%m-%dT%H:%M:%SZ')]]
        print "== GitHub API Status =="
        print tabulate(table, headers=['Resource Type', 'Limit', 'Remaining', 'Reset Time'])
        return

    # handle action_type
    ges = github_email.collect_email_info(explore_cli_args.repo.owner, explore_cli_args.repo.name, explore_cli_args.action_type, github_api_auth)
    print 'Total: {}/{}'.format(len([ge for ge in ges if ge.email]), len(ges))
    print github_email.format_email(ges)
def get_github_email_by_repo():
    """ Get user email by repos
    """
    explore_cli_args = ExploreCliArgs()

    github_api_auth = {
        'access_token': explore_cli_args.access_token
    }

    if explore_cli_args.status:
        # call api status
        status = github_email.api_status(github_api_auth)
        table = [["Core", status.core_limit, status.core_remaining, datetime.utcfromtimestamp(status.core_reset_time).strftime('%Y-%m-%dT%H:%M:%SZ')],
                 ["Search", status.search_limit, status.search_remaining, datetime.utcfromtimestamp(status.search_reset_time).strftime('%Y-%m-%dT%H:%M:%SZ')]]
        print "== GitHub API Status =="
        print tabulate(table, headers=['Resource Type', 'Limit', 'Remaining', 'Reset Time'])
        return

    # handle action_type
    ges = github_email.collect_email_info(explore_cli_args.repo.owner, explore_cli_args.repo.name, explore_cli_args.action_type, github_api_auth)
    print 'Total: {}/{}'.format(len([ge for ge in ges if ge.email]), len(ges))
    print github_email.format_email(ges, explore_cli_args.output_format)