コード例 #1
0
def main():
    """
    Checks for a change in Banner registration data since last GET
    """

    if not app.SILENT:
        app.print_greeting(module=app_name, version=version)

    quarter, year = app.get_user_input()
    term = '_{}{}'.format(year, quarter)
    class_schedule = '{} {}'.format(quarter, year)

    try:
        cached_data = app.json.loads(app.get_cached(term)['data'])
    except:
        if not app.SILENT:
            print('First run for this quarter/year combination...')
        reg = get_schedule(quarter, year)
        cached_data = app.json.loads(app.get_cached(term)['data'])
        pass

    if app.TEST:
        body = grades_string(cached_data['data']['registrations'])
        test_msg = '***TEST***\n{}***TEST***'.format(body)
        res = notify(test_msg)
        print(res.text)
        print(test_msg)
        exit(0)

    reg = get_schedule(quarter, year)
    new_data = app.json.loads(app.get_cached(term)['data'])

    if (cached_data != new_data):
        log_entry('New changes')
        if not app.SILENT:
            print('New changes!')
        body = grades_string(new_data['data']['registrations'])
        res = notify(body)
        log_entry('Notification result: {}'.format(res.status_code))
        if res.status_code != 200:
            log_entry('Notification error: {}\n'.format(res.text))
    else:
        log_entry('')
        if not app.SILENT:
            print('Nothing new for {} {}'.format(quarter, year))
コード例 #2
0
def main():
    print_greeting('', '1.5')

    while True:
        print('Select an option:\n')
        for i, option in enumerate(options):
            print('  {}. {}'.format(i + 1, option))
        print('  ')
        try:
            sel = input()
        except KeyboardInterrupt:
            print('\nBye Felicia!')
            quit()

        if int(sel) >= 1 and int(sel) <= len(options):
            break

    if sel == '1':
        grades()
    elif sel == '2':
        gcal()
コード例 #3
0
    except:
        gpa = None
    return gpa


def main(sid):
    """
    """

    try:
        gpa = get_gpa(sid)
        print(gpa)
    # Catch a ctrl+c interrupt and print an exit message
    except KeyboardInterrupt:
        print('\nBye Felicia!')
        quit()


if __name__ == "__main__":
    sid = sid_from_cred()
    if app.args['c'] and sid is not None:
        if sid is not None:
            app.print_greeting(app_name, version)
            main(sid)
        else:
            print('Could not find SID in credentials.json')
            exit(1)
    else:
        print('Usage: {} -c /path/to/credentials.json'.format(sys.argv[0]),
              file=sys.stderr)