예제 #1
0
def user_ready(username):
    if username.endswith(".php"):
        return False

    uh = UserHistory(username)

    # First, check to see if the file is fresh
    uh.load_if_possible()
    if uh.data_age() < settings.HISTORY_TTL:
        return uh.num_weeks()

    # Then, do a quick weeklist fetch to compare
    try:
        weeks = list(fetcher.weeks(username))
    except AssertionError:  # They probably don't exist
        return None

    present = True
    for start, end in weeks:
        if not uh.has_week(start):
            present = False
            break

    # If all weeks were present, update the timestamp
    if present:
        uh.set_timestamp()
        uh.save_default()
        return len(weeks)
    else:
        return False
예제 #2
0
파일: views.py 프로젝트: 0x414c/lastgraph
def user_ready(username):
    if username.endswith(".php"):
        return False
    
    uh = UserHistory(username)
    
    # First, check to see if the file is fresh
    uh.load_if_possible()
    if uh.data_age() < settings.HISTORY_TTL:
        return uh.num_weeks()
    
    # Then, do a quick weeklist fetch to compare
    try:
        weeks = list(fetcher.weeks(username))
    except AssertionError:  # They probably don't exist
        return None
    
    present = True
    for start, end in weeks:
        if not uh.has_week(start):
            present = False
            break
    
    # If all weeks were present, update the timestamp
    if present:
        uh.set_timestamp()
        uh.save_default()
        return len(weeks)
    else:
        return False
예제 #3
0
파일: fetch.py 프로젝트: zephg/lastgraph
def update_user(username):
    """Returns an up-to-date UserHistory for this username,
    perhaps creating it on the way or loading from disk."""

    uh = UserHistory(username)

    if uh.has_file():
        uh.load_default()

    try:
        update_user_history(uh)
        uh.set_timestamp()  # We assume we got all the data for now.
    except KeyboardInterrupt:
        pass

    uh.save_default()

    return uh
예제 #4
0
파일: fetch.py 프로젝트: 0x414c/lastgraph
def update_user(username):
    """Returns an up-to-date UserHistory for this username,
    perhaps creating it on the way or loading from disk."""
    
    uh = UserHistory(username)
    
    if uh.has_file():
        uh.load_default()
    
    try:
        update_user_history(uh)
        uh.set_timestamp() # We assume we got all the data for now.
    except KeyboardInterrupt:
        pass
    
    uh.save_default()
    
    return uh