def handle(self, *args, **options): github = github_login(settings.GITHUB_USERNAME, settings.GITHUB_PASSWORD) for index, package in enumerate(Package.objects.iterator()): # Simple attempt to deal with Github rate limiting while True: if github.ratelimit_remaining() < 50: sleep(120) break try: try: package.fetch_metadata(fetch_metadata=False) package.fetch_commits() except Exception as e: raise PackageUpdaterException(e, package.title) except PackageUpdaterException: pass # We've already caught the error so let's move on now sleep(5) message = "TODO - load logfile here" # TODO send_mail( subject="Package Updating complete", message=message, from_email=settings.DEFAULT_FROM_EMAIL, recipient_list=[x[1] for x in settings.ADMINS] )
def login(): # Do we have the credentials stored? c = ConfigParser() c.read(CONFIG_FILE) if c.has_section('credentials'): # Get the token from the config file token = c.get('credentials', 'token').strip() else: # Ask for credentials print("Please insert your GitHub credentials below:") user = input("Username: ").strip() password = getpass() auth = authorize(user, password, SCOPES, DESCRIPTION) token = auth.token # Save credentials to the config file c.add_section('credentials') c.set('credentials', 'token', str(token)) c.set('credentials', 'id', str(auth.id)) with open(CONFIG_FILE, 'w') as f: c.write(f) return github_login(token=token)
def handle(self, *args, **options): github = github_login(token=settings.GITHUB_TOKEN) for index, package in enumerate(Package.objects.iterator()): # Simple attempt to deal with Github rate limiting while True: if github.ratelimit_remaining < 50: sleep(120) break try: try: package.fetch_metadata(fetch_pypi=False) package.fetch_commits() except Exception as e: raise PackageUpdaterException(e, package.title) except PackageUpdaterException: pass # We've already caught the error so let's move on now sleep(5) message = "TODO - load logfile here" # TODO send_mail(subject="Package Updating complete", message=message, from_email=settings.DEFAULT_FROM_EMAIL, recipient_list=[x[1] for x in settings.ADMINS])
def handle(self, *args, **options): github = github_login(token=settings.GITHUB_TOKEN) for index, package in enumerate( tqdm(Package.objects.iterator(), total=Package.objects.all().count())): # Simple attempt to deal with Github rate limiting while True: if github.ratelimit_remaining < 50: sleep(120) break try: try: package.fetch_metadata(fetch_pypi=False) package.fetch_commits() except Exception as e: raise PackageUpdaterException(e, package.title) except PackageUpdaterException: logger.error(f"Unable to update {package.title}", exc_info=True) sleep(5) healthcheck(settings.PACKAGE_HEALTHCHECK_URL)
def handle(self, *args, **options): github = github_login(token=settings.GITHUB_TOKEN) projects_count = Project.objects.count() for index, package in enumerate(Project.objects.iterator()): Job.update_progress(total_parts=projects_count, total_parts_complete=index) logging.info("{} ...".format(package.name)) print("{} ...".format(package.name)) # Simple attempt to deal with Github rate limiting while True: if github.ratelimit_remaining < 50: sleep(120) break try: try: package.fetch_metadata(fetch_pypi=False) package.fetch_commits() except Exception as e: raise PackageUpdaterException(e, package.name) except PackageUpdaterException: pass # We've already caught the error so let's move on now sleep(5)
def handle(self, *args, **options): github = github_login(token=settings.GITHUB_TOKEN) for index, package in enumerate(Package.objects.iterator()): # Simple attempt to deal with Github rate limiting while True: if github.ratelimit_remaining < 50: sleep(120) break try: package.fetch_metadata(fetch_repo=False) package.fetch_commits() except Exception as e: raise e sleep(5)
def handle(self, *args, **options): github = github_login(token=settings.GITHUB_TOKEN) for index, package in enumerate(Package.objects.iterator()): # Simple attempt to deal with Github rate limiting while True: if github.ratelimit_remaining < 50: sleep(120) break try: try: package.fetch_metadata(fetch_pypi=False) package.fetch_commits() except Exception as e: raise PackageUpdaterException(e, package.title) except PackageUpdaterException: logger.error(f"Unable to update {package.title}", exc_info=True) sleep(5) healthcheck(settings.PACKAGE_HEALTHCHECK_URL)
def __init__(self): self.github = github_login(settings.GITHUB_USERNAME, settings.GITHUB_PASSWORD)