示例#1
0
def main():
    clearConsole()

    nav = Navigator()
    courses = []

    major, minor, micro = sys.version_info[:3]
    message = checkVersion(major, minor, micro)

    if message != "":
        print message

    if "Error" in message:
        sys.exit(1)

    username = getpass('PID: ')
    password = getpass()

    print "Logging In.. "
    sys.stdout.flush()

    while (nav.login(username, password) is False):
        print "Please Try Again"

        username = raw_input('PID: ')
        password = getpass()

    clearConsole()

    automate = raw_input("Automate?: ")

    if automate:
        errors = ""
        CRN = "92074"
        TERM = "09"
        YEAR = "2013"
        SUBJ = "CS"
        CRSE = "2114"
    else:
        errors = 1

    print "Logged In"

    print "Please Enter The Following Information:"

    error_checker = ErrorCheck()

    while (errors):

        CRN = raw_input('CRN: ') or ""  # or "92083"
        TERM = raw_input('TERM (F, S, S1, or S2) (F - Default): '
                         ) or "09"  # Default TERM if nothing is given
        YEAR = raw_input('YEAR (2013 - Default): '
                         ) or "2013"  # Default YEAR if nothing is given
        SUBJ = raw_input('SUBJ: ') or ""
        CRSE = raw_input('CRSE: ') or ""

        print "\nChecking for Errors in Course Information..\n"

        errors = error_checker.obviousChecks(crn=CRN, subj=SUBJ, crse=CRSE)

        if (errors):
            print "Sorry, There Were Some Errors: \n"
            print "Error(s): "
            for error in errors:
                print error
            print "Please Try Again"

    clearConsole()
    print "Everything Looks Good.."
    print "Searching for Class Information.."

    if ((SUBJ and CRSE) or CRN):
        course_info = nav.find(subj=SUBJ,
                               crse=CRSE,
                               term=TERM,
                               year=YEAR,
                               crn=CRN)
    else:
        print "Sorry.. You Didn't Enter Enough Information"
        sys.exit(0)

    if course_info is None:
        print "Sorry.. No Sections were Found"
        answer = raw_input("Try Again..? ")
        sys.exit(0)
    else:
        course_info = Cleaner(course_info)

    print "Here's What I Found.."

    print course_info

    answer = YesNo(
        raw_input("Do You Wish to Add a Course? Enter (y)es or (n)o: "))

    if answer == "Yes":
        CRN = raw_input("Please Enter the CRN: ")
        courses.append(CRN)
    else:
        sys.exit(0)