Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1 - add --rate-limit command #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions bin/pullpo
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# Santiago Dueñas <[email protected]>
#

import datetime

from argparse import ArgumentParser

from pullpo.backends import BackendError
Expand Down Expand Up @@ -52,6 +54,16 @@ def main():
backend = GitHubBackend(args.gh_user, args.gh_password,
args.gh_token, session,
enterprise_url=args.gh_url)
if args.rate_limit:
print('Remaining rate limit requests: ' + str(backend.gh.rate_limit()['rate']['remaining']))
print('Rate limit requests reset at: ' + str(datetime.datetime.fromtimestamp(backend.gh.rate_limit()['rate']['reset'])))
sys.exit(0)


if args.rate_limit:
print('Remaining rate limit requests: ' + str(backend.gh.rate_limit()['rate']['remaining']))
print('Rate limit requests reset at: ' + str(datetime.datetime.fromtimestamp(backend.gh.rate_limit()['rate']['reset']+3600)))
sys.exit(0)

for repo in backend.fetch(args.owner, args.repository, since, newest):
store(db, session, repo)
Expand Down Expand Up @@ -109,6 +121,10 @@ def parse_args():
action='store_true',
help='Retrieve newest issues first',
default=False)
group.add_argument('--rate-limit', dest='rate_limit',
action='store_true',
help='Display rate limit info for the GitHub login',
default=False)

# Positional arguments
parser.add_argument('owner', help='Owner of the repository on GitHub')
Expand Down