Esempio n. 1
0
def loop(client, user, max_hours, exit_if_both_not_zero):
    puts("Working in stables for {0} hours".format(max_hours))
    done_hours = 0

    while True:
        wait_time = 3610
        log_in(client, user, "Checking if we can log in")
        check_notifications(client)

        job_menu = SELECTORS.get_job_menu(client)
        if (job_menu):
            job_menu.click()

        job_do = SELECTORS.get_job_do(client)
        if (job_do):
            if (SELECTORS.get_points(client) != 0
                    or SELECTORS.get_dungeon_points(client) != 0
                    and exit_if_both_not_zero):
                puts("Exiting script because we can do fighting".format(
                    done_hours))
                return
            job_do.click()
            done_hours += 1
            puts("Starting Job")
        else:
            puts("Already was working, waiting")
            wait_time = SELECTORS.get_job_cooldown_time(client)

        delay(wait_time)

        if (done_hours == max_hours):
            puts("Exiting script after working for {0} hours".format(
                done_hours))
            return
Esempio n. 2
0
def loop(client, user, enemy_selection, max_hp, exit_on_zero_points,
         exit_on_no_food, max_events):
    done_events = 0
    log_in(client, user, "Checking if we can log in")

    puts("Entering fight event")
    while True:
        wait_time = 60
        log_in(client, user, "Checking if we can log in")
        check_notifications(client)

        # Check if we need to eat
        if check_hp(client, max_hp):

            # Go to expeditions
            expedition_bar = SELECTORS.get_expedition_bar(client)
            if (expedition_bar):
                expedition_bar.click()

            time.sleep(1)
            puts("Entering fight events")

            # Get go to location
            location = SELECTORS.get_event_fight_location(client)
            if (location):
                location.click()

            puts("Getting cooldowns")
            if SELECTORS.get_event_fight_cooldown_time(client, False):
                puts("Fight event on cooldown")
                wait_time = SELECTORS.get_event_fight_cooldown_time(
                    client, False)
            else:
                puts("Starting fight event")
                enemy = SELECTORS.get_event_fight_enemy(
                    client, enemy_selection)
                if (enemy):
                    enemy.click()
                    done_events += 1
                    wait_time = 5 * 60

        else:  # Eat food
            wait_time = 0
            if not (eat_food(client)):  # no food
                if (exit_on_no_food):
                    return
                else:
                    wait_time = 30 * 60

        if (done_events == max_events):
            puts("Exiting script after {0} events".format(max_events))
            return

        delay(wait_time)
Esempio n. 3
0
def loop(client, user, enemy_selection, max_hp, exit_on_no_food, max_arenas):
    done_arenas = 0
    log_in(client, user, "Checking if we can log in")

    # If cannot determine cooldown time, must be working or somethings wrong. Exit script
    if not (SELECTORS.get_arena_cooldown_time(client, True)):
        puts("Exiting arena provinciarum")
        return

    puts("Entering arena provinciarum")

    while True:
        wait_time = 60
        log_in(client, user, "Checking if we can log in")
        check_notifications(client)

        # Check if we need to eat
        if check_hp(client, max_hp):

            arena_bar = SELECTORS.get_arena_bar(client)
            if (arena_bar):
                arena_bar.click()

            # Get go to tab
            tab = SELECTORS.get_arena_provinciarum_tab(client)
            if (tab):
                tab.click()

            if SELECTORS.is_arena_provinciarum_on_cooldown(client):
                puts("Arena on cooldown")
                wait_time = SELECTORS.get_arena_cooldown_time(client, False)
            else:
                puts("Starting arena")
                enemy = SELECTORS.get_arena_provinciarum_enemy(
                    client, enemy_selection)
                if (enemy):
                    enemy.click()
                    done_arenas += 1
                    wait_time = 5 * 60

        else:  # Eat food
            wait_time = 0
            if not (eat_food(client)):  # no food
                if (exit_on_no_food):
                    return
                else:
                    wait_time = 30 * 60

        if (done_arenas == max_arenas):
            puts("Exiting script after {0} arenas".format(max_arenas))
            return

        delay(wait_time)
Esempio n. 4
0
def execute(command):
    words = command.split(" ")
    functions.log_in("Searching Klam Code: "+command)
    if words[0] in exec_dct:
        for key in exec_dct:
            if words[0] == key:
##                        print(words[1:])
                try:
                    a = words[1]
                except:
                    return exec_dct[key]([])
                else:
                    if a != "/?":
                        result = exec_dct[key](words[1:])
                        return result
                    else:
                        return exec_dct[key].__doc__
    else:
        functions.log_in("Command Not Found: "+command, "critical")
        raise ExecutionNotFoundError("Command:"+words[0]+" is not found.\nCheck your spelling and try it again.\n")
Esempio n. 5
0
def main():
    database = sqlite3.connect("database")
    cursor = database.cursor()
    users = []
    courses = []

    #pick a school semester to log into
    semester = ""
    while semester != "Fall 2019" and semester != "Spring 2020":
        print("Pick a Semester: Fall 2019 / Spring 2020")
        semester = input()
        if semester != "Fall 2019" and semester != "Spring 2020":
            print("This answer is invalid")

    #Start by taking the data out of the database:
    cursor.execute("Select * From Student")
    results = cursor.fetchall()
    for result in results:
        users.append(
            classes.student(result[0], result[1], result[2], result[3],
                            result[4], result[5], result[6], result[7],
                            result[8], result[9]))
    cursor.execute("Select * From Instructor")
    results = cursor.fetchall()
    for result in results:
        users.append(
            classes.instructor(result[0], result[1], result[2], result[3],
                               result[4], result[5]))
    cursor.execute("Select * From Admin")
    results = cursor.fetchall()
    for result in results:
        users.append(
            classes.admin(result[0], result[1], result[2], result[3],
                          result[4]))
    cursor.execute("Select * From Course Where semester = '" + semester + "'")
    results = cursor.fetchall()
    for result in results:
        courses.append(
            classes.course(result[0], result[1], result[2], result[3],
                           result[4], result[5], result[6], result[7]))

    response, noStudent = 1, 1  #variables: user's response to UI,
    ID, f, l, m, CRN, u, p, = "", "", "", "", "", "", ""
    ################################################################################
    while response != "0":  #main loop
        print("Welcome to CURSE \n")
        print("----------------------------------------------\n")
        userIndex = -1  #variable that determines the user's index in the list, currently not holding a value
        while userIndex == -1:  #while the user isn't determined
            functions.print_login_menu()
            response = input()
            if response == "1":
                userIndex = functions.log_in(users)  #gets user index
            elif response == "2":
                userIndex = functions.sign_up(users)
            elif response == "0":
                break
            else:
                print("invalid response")

            if userIndex != -1:  #fixes a small bug
                ################################################################################
                #STUDENT COMPONENT
                if users[userIndex].get_user_type(
                ) == "student":  #student section
                    while response != "4":
                        functions.print_student_menu(users[userIndex])
                        response = input()
                        if response == "1":  #add courses
                            users[userIndex].view_all_courses(courses)
                            CRN = input("Enter the course number\n")
                            users[userIndex].add_course(CRN, courses)
                        elif response == "2":  #drop courses
                            CRN = input("Enter the course number\n")
                            users[userIndex].remove_course(CRN, courses)
                        elif response == "3":  #print schedule
                            users[userIndex].view_schedule(courses)
################################################################################
#INSTRUCTOR COMPONENT
                elif users[userIndex].get_user_type() == "instructor":
                    while response != "3":
                        functions.print_instructor_menu(users[userIndex])
                        response = input()
                        if response == "1":  #view schedule
                            users[userIndex].view_schedule(courses)
                        elif response == "2":
                            users[userIndex].view_roster(users, courses)
################################################################################
#ADMIN COMPONENT
                elif users[userIndex].get_user_type() == "admin":
                    while response != "9":
                        functions.print_admin_menu()
                        response = input()
                        if response == "1":
                            users[userIndex].view_all_courses(courses)
                        elif response == "2":
                            users[userIndex].view_instructor_roster(
                                users, courses)
                        elif response == "3":
                            users[userIndex].add_course(users, courses)
                        elif response == "4":
                            users[userIndex].remove_course(users, courses)
                        elif response == "5":
                            users[userIndex].edit_course(users, courses)
                        elif response == "6":
                            users[userIndex].add_student(users, courses)
                        elif response == "7":
                            users[userIndex].remove_student(users, courses)
                        elif response == "8":
                            users[userIndex].view_all_students(users, courses)


################################################################################

# Commit changes to the database
    cursor.execute("Delete From Student")
    cursor.execute("Delete From Instructor")
    for user in users:
        if user.get_user_type() == "student":
            CRNtoDatabase = ""
            if not user.courseCRN:
                CRNtoDatabase = "none"
            else:
                for CRN in user.courseCRN:
                    CRNtoDatabase = CRNtoDatabase + CRN + " "
            pastCRNtoDatabase = ""
            if not user.pastCourses:
                pastCRNtoDatabase = "none"
            else:
                for CRN in user.pastCourses:
                    pastCRNtoDatabase = pastCRNtoDatabase + CRN + " "
            cursor.execute("Select * From Student Where ID = " + str(user.ID))
            result = cursor.fetchall()
            cursor.execute("Insert Into Student Values (" + str(user.ID) +
                           ", '" + user.firstName + "' ,'" + user.lastName +
                           "' ,'" + user.username + "' ,'" + user.password +
                           "' ,'" + user.major + "' ,'" + user.classLevel +
                           "' ,'" + CRNtoDatabase + "' ,'" +
                           pastCRNtoDatabase + "' ,'" + user.information +
                           "')")
            database.commit()
        elif user.get_user_type() == "instructor":
            CRNtoDatabase = ""
            if not user.courseCRN:
                CRNtoDatabase = "none"
            else:
                for CRN in user.courseCRN:
                    CRNtoDatabase = CRNtoDatabase + CRN + " "
            cursor.execute("Select * From Instructor Where ID = " +
                           str(user.ID))
            result = cursor.fetchall()
            cursor.execute("Insert Into Instructor Values (" + str(user.ID) +
                           ", '" + user.firstName + "' ,'" + user.lastName +
                           "' ,'" + user.username + "' ,'" + user.password +
                           "' ,'" + CRNtoDatabase + "')")
            database.commit()

            # admins don't change

    cursor.execute("Delete From Course Where semester = '" + semester + "'")
    for course in courses:
        scheduleToDatabase = str(course.schedule[0] + "-" +
                                 str(course.schedule[1]))
        prereqToDatabase = ""
        if not course.prerequisites:
            prereqToDatabase = "none"
        else:
            for prereq in course.prerequisites:
                prereqToDatabase = prereqToDatabase + prereq + " "
        enrolledToDatabase = ""
        if not course.studentList:
            enrolledToDatabase = "none"
        else:
            for enrolled in course.studentList:
                enrolledToDatabase = enrolledToDatabase + str(enrolled) + " "
        cursor.execute("Insert Into Course Values ('" + course.CRN + "', '" +
                       course.title + "', '" + course.department + "', '" +
                       scheduleToDatabase + "', " + str(course.instructorID) +
                       ", '" + course.semester + "', '" + prereqToDatabase +
                       "', '" + enrolledToDatabase + "')")
        database.commit()

    database.commit()
    database.close()
Esempio n. 6
0
import os
os.chdir("D:\\My AI")
import functions
# from modules import myNL

if __name__ == "__main__":
    Kristina = functions.robots.AI()
    try:
        Kristina.start()
    except Exception as e:
        functions.log_in(e,level="error")
Esempio n. 7
0
if "--help" in sys.argv:
    f.instructions()
    time.sleep(10)
else:
    pass

print(Fore.BLUE + "\n***** Welcome to Nerdy Pandy's CRM Application *****\n")
time.sleep(2)

# 1. Log in to application w/ username and password

print(
    "Please enter the correct username and password combination to access this app:\n"
)
f.log_in()

# 2. Show current time

tz_Sydney = pytz.timezone('Australia/Sydney')
datetime_Sydney = datetime.now(tz_Sydney)
print("\nYou logged in at: ", datetime_Sydney.strftime("%H:%M:%S"))

# 3. Start time to calculate total time in program
start_time = datetime.now()

# 4. Random inspirational quote:
time.sleep(2)
print("\nReady to start? Here some inspiration for you today:\n")
inspirational_quote = random.choice(q.quotes)
print(Fore.MAGENTA + inspirational_quote)
def loop(client, user, location_selection, exit_on_zero_points, max_dungeon_fights):    
  done_dungeon_fights = 0
  log_in(client, user,"Checking if we can log in")     

  # If cannot determine cooldown time, must be working or somethings wrong. Exit script
  if not (SELECTORS.get_expedition_cooldown_time(client, True)):
    puts("Exiting dungeons")
    return
  puts("Doing dungeons")
  
  while True:
    wait_time = 60
    log_in(client, user,"Checking if we can log in")
    check_notifications(client)
    
    # Check if we need to exit before delay
    if (SELECTORS.get_dungeon_points(client) == 0 and exit_on_zero_points):
      puts("Exiting dungeon script")
      return
        
    # Go to dungeons
    puts("Entering dungeons")

    dungeon_bar = SELECTORS.get_dungeon_bar(client)
    if (dungeon_bar):
      dungeon_bar.click()
      
    # Go to location
    location = SELECTORS.get_location(client, location_selection)
    if (location):
      location.click()
      
    # Go to dungeon tab
    puts("Clicking on dungeon tab")

    tab = SELECTORS.get_dungeon_tab(client)
    if (tab):
      tab.click()
      
    # Dificulty 1
    puts("Selecting first difficulty")

    dif1 = SELECTORS.get_dungeon_dif1(client)
    if(dif1):
      dif1.click()
    else:
      puts("Couldn't select first difficulty, maybe already in a dungeon?")
      
    if SELECTORS.is_dungeon_on_cooldown(client):
      puts("Dungeon on cooldown")
      wait_time = SELECTORS.get_dungeon_cooldown_time(client, False)
    else:
      # Select first found label and click attack
      puts("Fighting in dungeon")
      areas = SELECTORS.get_dungeon_areas(client)
      
      if(areas):
        areas[0].click()
        done_dungeon_fights += 1
        wait_time = 5 * 60
 
    if (done_dungeon_fights == max_dungeon_fights):
      puts("Exiting script after {0} dungeons".format(done_dungeon_fights))
      return 

    delay(wait_time)
Esempio n. 9
0
def loop(client, user, location_selection, enemy_selection, max_hp,
         exit_on_zero_points, exit_on_no_food, max_expeditions):
    done_expeditions = 0
    log_in(client, user, "Checking if we can log in")

    # If cannot determine cooldown time, must be working or somethings wrong. Exit script
    if not (SELECTORS.get_expedition_cooldown_time(client, True)):
        puts("Exiting expeditions")
        return

    puts("Entering expeditions")

    while True:
        wait_time = 60
        log_in(client, user, "Checking if we can log in")
        check_notifications(client)

        # Check if we need to exit before delay
        if (SELECTORS.get_points(client) == 0 and exit_on_zero_points):
            puts("Exiting expedition script")
            return

        # Check if we need to eat
        if check_hp(client, max_hp):

            # Go to expeditions
            expedition_bar = SELECTORS.get_expedition_bar(client)
            if (expedition_bar):
                expedition_bar.click()

            # Get go to location
            location = SELECTORS.get_location(client, location_selection)
            if (location):
                location.click()

            puts("Getting cooldowns")
            if SELECTORS.is_expedition_on_cooldown(client):
                puts("Expedition on cooldown")
                wait_time = SELECTORS.get_expedition_cooldown_time(
                    client, False)
            else:
                puts("Starting expedition")
                enemy = SELECTORS.get_enemy(client, enemy_selection)
                if (enemy):
                    enemy.click()
                    done_expeditions += 1
                    wait_time = 5 * 60

        else:  # Eat food
            wait_time = 0
            if not (eat_food(client)):  # no food
                if (exit_on_no_food):
                    return
                else:
                    wait_time = 30 * 60

        if (done_expeditions == max_expeditions):
            puts(
                "Exiting script after {0} expeditions".format(max_expeditions))
            return

        delay(wait_time)
Esempio n. 10
0
 def log(self, username, token):
     info = log_in(username, token)
     return info