Handles the cron request to github to check for new pull requests. If
    any are found, they are run *sequentially* until they are all completed.

def _do_cron():
    """Handles the cron request to github to check for new pull requests. If
    any are found, they are run *sequentially* until they are all completed.
    """
    if not args["cron"]:
        return
    
    if ("enabled" in db and not db["enabled"]) or "enabled" not in db:
        warn("The CI server is disabled. Exiting.")
        exit(0)
    #Our basic idea with the cron is as follows:
    # - the cron runs every minute of the day.
    # - each installed XML file has the last time it ran saved in the script's
    #   database. If the specified check frequency has elapsed since it last
    #   ran, then we run the repository server checks.
    # - NB: before running the time-intensive checks against remote servers
    #   or running the unit tests, first update the running status of the repo
    #   so that another call with -cron doesn't duplicate the work!

    #By having the cron run every minute, we maximize the probability that
    #repo checks with time intensive unit tests may run in parallel. Since
    #servers usually have many cores, this shouldn't impact the run times too
    #severely unless the tests are disk intensive.

    #We use the repo full names as keys in the db's status dictionary.
    from pyci.server import Server
    from datetime import datetime
    attempted = []
    server = Server(testmode=args["nolive"])
    nextrepo = _find_next(server)
    dbs = db["status"]
    
    while nextrepo is not None:
        vms("Working on '{}' in cron.".format(nextrepo))
        if nextrepo in attempted:
            #This makes sure we don't end up in an infinite loop.
            vms("'{}' has already been handled! Exiting infinite loop.".format(nextrepo))
            break
        
        if nextrepo not in dbs:
            vms("Created blank status dictionary for '{}' in db.".format(nextrepo))
            dbs[nextrepo] = {"start": None, "end": None}
        dbs[nextrepo]["start"] = datetime.now()
        _save_db()

        #Now that we have saved our intent to run these repo-checks, let's
        #actually run them.
        attempted.append(nextrepo)
        server.runnable = [nextrepo]
        if not args["nolive"]:
            vms("Starting pull request processing for '{}'.".format(nextrepo))
            server.process_pulls()
    
        dbs[nextrepo]["end"] = datetime.now()
        _save_db()
        nextrepo = _find_next(server)