def leaveGroup(self, email): db = Database() flag = self.showMyGroups(email) if (flag == False): return print("|---------------------------------|") print(" Leaving group ") print("|---------------------------------|") group = input("\n Enter the name of the group you want to leave : ") if group in db.my_groups(email): db.leave_group(group, email) clear() print("|---------------------------------|") print(" You have left the group ") print("|---------------------------------|") else: print("|---------------------------------|") print(" Not a valid group name ") print("|---------------------------------|")
def page_pets_available(shelter): """Page to display all available(Not Adopted and not On-Hold) pets in the Shelter's Pet Directory """ helper.clear() shelter.print_Pets_Available() print( '\nWhat would you like to do? \n[1]Schedule a Visit \n[2]Adopt a Pet \n[3]Sort Available Pets \n[4]Home' ) limit = 4 action = helper.get_next_page(limit) if action == 1: page_pets_visit(shelter) elif action == 2: page_pets_adopt(shelter) elif action == 3: page_pets_sorted(shelter) elif action == 4: page_home(shelter)
def showFriendsPost(self, email, friend_name): db = Database() myFriends = db.my_friends(email) if friend_name in myFriends: posts = db.get_friends_post_from_person_node_details(friend_name) friend_Posts = posts.split("\n") clear() print("|--------------------------------------------|") print("|---------", friend_name, "\'s" " Posts---------|") print("|--------------------------------------------|") if (len(friend_Posts) != 0): for post in friend_Posts: print(" ", post) else: print(" NO POSTS YET ") print("|--------------------------------------------|") else: clear() print("|--------------------------------------------|") print(" ", friend_name, "is not your friend") print("|--------------------------------------------|")
def page_admin_home(shelter, admin): """The admin homepage where the user selects what operation they wish to perform """ helper.clear() print( '[Admin] What would you like to do? \n[1]View All Pets \n[2]View Drop-Off Requests \n[3]Add Pet \n[4]Edit Pet \n[5]Home' ) limit = 5 action = helper.get_next_page(limit) if action == 1: page_admin_all_pets(shelter, admin) elif action == 2: page_admin_dropoffs(shelter, admin) elif action == 3: page_admin_add_pet(shelter, admin) elif action == 4: pass elif action == 5: page_home(shelter)
def get_date(): date = None flag = False while True: clear() print("Step 2: Choose a date") print( "Date -- The latest date to be plotted (in dd-mm-yyyy format)") print( "Please note that there are delays between the real-time report" ) print("and this compiled report. If there is no report available") print("for today, please switch to the previous date.") if flag: print("\nDate is invalid! Try again.\n") date = input("Enter date > ") if is_valid_date(date): break else: flag = True return date
def starting_up(self, own, opponent): """Initialize own board.""" helper.clear() ship_list = [("Destroyer", 2), ("Submarine", 3), ("Cruiser", 3), ('Battleship', 4), ('Carrier', 5)] input(own.name + ", press Enter if you're ready. ") for ship in reversed(ship_list): succesful = False while not succesful: helper.clear() own.draw_boards(own, opponent) position = insert_position(own, ship, starting=True) direction = insert_direction() if check_if_possible(own, position, direction, ship): succesful = True own.draw_ship(position, direction, ship) else: print( "\nIt's not possible to place a ship here. Please chose an other location.\n" ) time.sleep(2) helper.clear() own.draw_boards(own, opponent) time.sleep(1)
def my_friends(current_user): db = Database() user = Facebook() subchoice = input( '\n 1. Add friends \n 2. Display friends \n 3. Display friend\'s posts \n 0. Back \n \n Enter your choice: ' ) clear() if subchoice == '1': user.showUsers() friend_name = input( "\n Enter the first name of the user you want to add as a friend from the users list: " ) user.addFriend(current_user, friend_name) input(" Press Enter to go back ") clear() my_friends(current_user) elif subchoice == '2': user.showFriends(current_user) input(" Press Enter to go back ") clear() my_friends(current_user) elif subchoice == '3': user.showFriends(current_user) friend_name = input( "\n Enter the first name of your friend, to view their posts: ") user.showFriendsPost(current_user, friend_name) input(" Press Enter to go back ") clear() my_friends(current_user) elif subchoice == '0': user_dashboard(current_user) else: clear() print("|-------------------------------------|") print(" Invalid Choice! ") print("|-------------------------------------|") my_friends(current_user)
def login(): db = Database() if (db.count_user() != 0): print("|--------------------------------------------------|") print("|----------------------LOGIN-----------------------|") print("|--------------------------------------------------|") email = input('\n Enter Your Email: ') password = input('\n Enter Your Password: '******' Welcome! to command line facebook ') print("|-----------------------------------------|") return email else: clear() print("|----------------------|") print(' Wrong Credentials! ') print("|----------------------|") home_screen() else: clear() print("|----------------------|") print(" No user found ") print("|----------------------|") home_screen()
def get_ct(): countries = [] flag = False while True: clear() print("Step 1: Choose the countries you want to plot\n") print("Country -- The country to be plotted") print( "Now supported multiple countries! You can put any countries in a list" ) print("and it will be drawn.\n") print("For the full list of available countries, please go to:") print("https://github.com/MunchDev/EpidemicSimulator\n") print("Leave empty to proceed to Step 2.\n") if flag: print("Country name is invalid! Try again.\n") ct = input("Enter country name > ") flag = False if ct == "": if len(countries) == 0: clear() print( "You did not enter any valid country! Please enter at least one." ) input("Press Enter to go back and try again") else: break elif ct not in countries: flag = True else: countries.append(ct) clear() return countries
def addFriend(self, email, friend_name): db = Database() if db.get_name(email) == friend_name: clear() print( "|----------------------------------------------------------------|" ) print(" You cannot add yourself to your friends list") print( "|----------------------------------------------------------------|" ) return for name in db.my_friends(email): if name == friend_name: clear() print("|--------------------------------------------|") print(" User is already your friend ") print("|--------------------------------------------|") return db.add_friend_to_person_node(email, friend_name) clear() print( "|----------------------------------------------------------------|" ) print(" ", friend_name, " successfully added to your friend list ") print( "|----------------------------------------------------------------|" ) return
def joinGroup(self, email): db = Database() flag = self.showGroups() if (flag == False): print("|---------------------------------|") print(" create a group to join ") print("|---------------------------------|") return print("|---------------------------------|") print(" Joining group ") print("|---------------------------------|") groupName = input("\n Enter the name of the group you wish to join : ") if groupName in db.my_groups(email): clear() print("|---------------------------------|") print(" Already a group member ") print("|---------------------------------|") return db.join_group_node(groupName, email) print("|------------------------------------------------------------|") print(" You are successfully added to ", groupName, " group ") print("|------------------------------------------------------------|")
def home_screen(): print("|-------------------------------------|") print('| COMMAND LINE FACEBOOK |') print("|-------------------------------------|") choice = input( '\n 1. Login \n 2. Register \n 3. Exit \n \n Enter your choice: ') clear() if (choice == '1'): current_user = login() user_dashboard(current_user) home_screen() elif (choice == '2'): register() home_screen() elif (choice == '3'): exit() else: print("|-------------------------------------|") print(" Invalid Choice! ") print("|-------------------------------------|") home_screen()
def make_move(self, own, opponent): succesful = False while not succesful: helper.clear() #Best to comment this line for testing own.draw_boards(own, opponent) position = insert_position(own, ship=None, starting=False) coordinate = convert_position(position) if check_if_first_time(coordinate, opponent): succesful = True else: print('Please enter a non-chosen position.') time.sleep(1) helper.clear() #Best to comment this line for testing if opponent.check_if_hit(coordinate): print('Hit!') else: print('Miss!') ships_name = opponent.check_if_sunk() if ships_name: print(ships_name + ' sunked!') time.sleep(1) own.draw_boards(own, opponent) time.sleep(1)
def my_timeline(current_user): user = Facebook() subchoice = input( '\n 1. Display my posts \n 2. Create text post \n 0. Back \n \n Enter your choice: ' ) clear() if subchoice == '1': user.display_user_posts(current_user) input(" Press Enter to go back ") clear() my_timeline(current_user) elif subchoice == '2': user.create_post(current_user) input(" Press Enter to go back ") clear() my_timeline(current_user) elif subchoice == '0': user_dashboard(current_user) else: clear() print("|-------------------------------------|") print(" Invalid Choice! ") print("|-------------------------------------|") my_timeline(current_user)
def get_pltype(): pltype = [] flag = False while True: clear() print("Step 5: Choose the plot type(s) you will be using") print( "Plot type -- Show plot of confirmed cases (c), deaths (d), recovered cases (r)," ) print("active cases (a) or any combination of these.") print( "Support multiple countries. If only one string of plot type is provided, it" ) print( "will used across all plots. If the number of plot type is smaller than" ) print( 'the number of countries, the rest will be taken as default of "cdra".\n' ) print("Leave empty to proceed to finish.\n") if flag: print("Plot type is invalid! Try again.\n") p = input("Enter plot type > ") flag = False if p == "": if len(pltype) == 0: clear() print( "You did not enter any valid plot type! Please enter at least one." ) input("Press Enter to go back and try again") if len(pltype) == 1: pltype = pltype[0] break else: break elif ("c" not in p) and ("d" not in p) and ("r" not in p) and ( "a" not in p): flag = True else: pltype.append(p) clear() return pltype
def get_scale(): scale = [] flag = False while True: clear() print("Step 4: Choose the scale you will be using") print( "Scale -- Set to 'linear' for linear scale or 'log' for logarithmic scale" ) print( "Support multiple countries. If only one string of scale is provided, it" ) print( "will used across all plots. If the number of scale is smaller than the" ) print( 'number of countries, the rest will be taken as default of "log".\n' ) print("Leave empty to proceed to Step 5.\n") if flag: print("Scale is invalid! Try again.\n") s = input("Enter scale name ('log' or 'linear') > ") flag = False if s == "": if len(scale) == 0: clear() print( "You did not enter any valid scale! Please enter at least one." ) input("Press Enter to go back and try again") elif len(scale) == 1: scale = scale[0] break else: break elif s != "log" and s != "linear": flag = True else: scale.append(s) clear() return scale
def check_one(): clear() #print ("in check 1") print_title() strx = input( Fore.GREEN + "Enter the password you want to check: " + Fore.RED + "\n(It is CASE SENSITIVE and SPACES will also be counted)\n\n" + Fore.WHITE + "#" + Fore.BLUE + "") i = 0 (Found, File) = (False, None) clear() print_title() print(Fore.GREEN + "\nSearching for " + Fore.RED + strx + Fore.GREEN + " in Password Database.\n") print(Fore.WHITE + "It may take Several Minutes. To interrupt, Press CTRL+C.\n\n") hide_cursor() try: total_pass = 0 for x in files: total_pass = total_pass + file_len(data_path + '/' + x) for x in files: if Found: break file = open(data_path + '/' + x, 'r', encoding='latin1') (c, r) = get_terminal_size() print(Back.CYAN + (c - 1) * ' ', end='\r') for line in file: line = line.strip() #(c, r) = get_terminal_size() #print (Back.BLUE + (c-1)*' ', end = '\r') i = i + 1 zx = Back.CYAN + Fore.BLACK + "Checking " + Fore.MAGENTA + "{:>13}".format( line[:13] ) + Fore.BLACK + " in file " + Fore.MAGENTA + "{:>25} ".format( x[:25]) + Fore.RED + str((i * 100) // total_pass) + "%" print(zx, end='\r') if (line == strx): (Found, File) = (True, x) file.close() break file.close() (c, r) = get_terminal_size() print(Back.BLACK + (c - 1) * ' ', end='\r') if Found: print( Fore.RED + "Your password was available in the password database in file " + Fore.BLUE + File + Fore.RED + ". You should immediately change this password if u have used it somewhere." ) else: print( Fore.GREEN + "Great! Your password is not available in any of the Password Database, and it should be secure enough." ) print(Fore.GREEN + "\n\n[+]" + Fore.WHITE + " Script Succeded. Result was " + Fore.BLUE + ("Unsecure Password" if Found else "Secure Password") + Fore.WHITE) except KeyboardInterrupt: (c, r) = get_terminal_size() print(Back.BLACK + (c - 1) * ' ', end='\r') print(Fore.GREEN + "\n[+]" + Fore.WHITE + " Script Succeded. Result was " + Fore.BLUE + "Interrupted by User" + Fore.WHITE) show_cursor() exit(0)
def group_activities(current_user): user = Facebook() subchoice = input( '\n 1. Create new group \n 2. Show groups \n 3. Join group \n 4. Leave group \n 5. My groups \n 6. Post in a group \n 7. Display group posts \n 8. Chat room \n 0. Back \n \n Enter your choice: ' ) clear() if subchoice == '1': user.createGroup(current_user) input(" Press Enter to go back ") clear() group_activities(current_user) elif subchoice == '2': user.showGroups() input(" Press Enter to go back ") clear() group_activities(current_user) elif subchoice == '3': user.joinGroup(current_user) input(" Press Enter to go back ") clear() group_activities(current_user) elif subchoice == '4': user.leaveGroup(current_user) input(" Press Enter to go back ") clear() group_activities(current_user) elif subchoice == '5': user.showMyGroups(current_user) input(" Press Enter to go back ") clear() group_activities(current_user) elif subchoice == '6': user.post_in_group(current_user) input(" Press Enter to go back ") clear() group_activities(current_user) elif subchoice == '7': user.showGroupPosts(current_user) input(" Press Enter to go back ") clear() group_activities(current_user) elif subchoice == '8': user.chatRoom(current_user) input(" Press Enter to go back ") clear() group_activities(current_user) elif subchoice == '0': user_dashboard(current_user) else: clear() print("|-------------------------------------|") print(" Invalid Choice! ") print("|-------------------------------------|") group_activities(current_user)
def check_file(): clear() print_title() print("This thing is under Development.")
def check_substr(): clear() print_title() strx = input( Fore.GREEN + "Enter the sub-string you want to search in Password Database: " + Fore.RED + "\n(It is CASE SENSITIVE and SPACES will also be counted)\n\n" + Fore.WHITE + "#" + Fore.BLUE + "") i = 0 #(Found, File) = (False, None) clear() print_title() print(Fore.GREEN + "\nSearching for " + Fore.RED + strx + Fore.GREEN + " and its Sub-Strings in Password Database.\n") print(Fore.WHITE + "It may take Several Minutes. To interrupt, Press CTRL+C.\n\n") hide_cursor() num = 0 try: total_pass = 0 for x in files: total_pass = total_pass + file_len(data_path + '/' + x) for x in files: file = open(data_path + '/' + x, 'r', encoding='latin1') (c, r) = get_terminal_size() print(Back.CYAN + (c - 1) * ' ', end='\r') for line in file: line = line.strip() #(c, r) = get_terminal_size() #print (Back.BLUE + (c-1)*' ', end = '\r') i = i + 1 zx = Back.CYAN + Fore.BLACK + "Checking " + Fore.MAGENTA + "{:>13}".format( line[:13] ) + Fore.BLACK + " in file " + Fore.MAGENTA + "{:>25} ".format( x[:25]) + Fore.RED + str((i * 100) // total_pass) + "%" print(zx, end='\r') l = line.find(strx) if (l is not -1): num = num + 1 #l = line.find (strx) lenx = len(strx) linex = Fore.BLUE + line[:l] + Fore.MAGENTA + line[ l:l + lenx] + Fore.BLUE + line[lenx:] (c, r) = get_terminal_size() print(Back.BLACK + (c - 1) * ' ', end='\r') print(Fore.WHITE + "{:>6}: ".format(num) + " " + linex + " " + Style.DIM + Fore.WHITE + " in " + Fore.BLUE + x + Style.RESET_ALL) (c, r) = get_terminal_size() print(Back.CYAN + (c - 1) * ' ', end='\r') file.close() (c, r) = get_terminal_size() print(Back.BLACK + (c - 1) * ' ', end='\r') print(Fore.GREEN + "\n\n[+]" + Fore.WHITE + " Script Succeded. Result was " + Fore.BLUE + "{} result(s)".format(num) + Fore.WHITE) except KeyboardInterrupt: (c, r) = get_terminal_size() print(Back.BLACK + (c - 1) * ' ', end='\r') print(Fore.GREEN + "\n[+]" + Fore.WHITE + " Script Succeded. Result was " + Fore.BLUE + "Interrupted by User, {} results found.".format(num) + Fore.WHITE) show_cursor() exit(0)
hangedgrad = hanged[::-1] word = (RandomWords().get_random_word()).lower() tempGuess = list("_" * len(word)) while ('-' in word) or (' ' in word): word = (RandomWords().get_random_word()).lower() def status(x): print('{} characters left to guess and you got {} shots'.format( tempGuess.count('_'), wrongs)) helper.newLine() print("Your guess: " + (" ".join(tempGuess))) helper.newLine(x) helper.clear() status(2) while (wrongs > 0): helper.newLine(2) char = input("Guess a charachter: ") if char in choosed: helper.clear() status(1) print("You had this char before") for item in hangedPortion: if (len(item) > 0): print(item) else: choosed.append(char) if (char in word): indexList = helper.find(word, char)