def start_choice():
  '''
  asks player if they want to play and gives character select

  uses cutie module to have user select input, both for wanting to play and what character they play as

  Parameter:
  ----------
  User input : str

  Returns:
  --------
  The stats of the hero choosen

  '''
  game_choice = ['Yes','No']
  print ('Would you like to play a game?')
  game_cho = game_choice[cutie.select(game_choice)]
  if game_cho == 'Yes':
    print ('Choose your character')
    names = ['Warrior', 'Assasin']
    if names[
        cutie.select(names)] == "Warrior":
          hero.warrior_select('Warrior', 100, 40)
    else:
      hero.warrior_select('Assassin', 75, 60)
    print ("You've made your choice, \nyour character is: \n" + hero.char_info())
  else:
    sys.exit('Thanks for playing')
Example #2
0
def manage(servers_config, config_file):
    server_continue = False
    for _ in count():
        if not server_continue:
            print(f"Maximum snapshots: {servers_config.snapshot_max}")
            print("\nWhich server do you want to manage?")
            opts = list(servers_config.servers) + ["Exit"]
            selection = cutie.select(options=opts)
            if selection == len(opts) - 1:
                break
            server_selection = list(servers_config.servers)[selection]
            stats(server_selection, servers_config, details=False)
        else:
            server_selection = server_continue
        server_continue = False

        dogs = DOGS(server_selection, config_file)
        if dogs.droplet:
            print(f"Running: {dogs.droplet.ip_address}")
        else:
            print("Currently not running")

        actions = [
            "Turn On",
            "Shutdown",
            "View Server Info",
            "View Snapshots",
            "Cleanup Old Snapshots",
            "Cancel",
        ]
        print("\nManage:")
        action = actions[cutie.select(actions,
                                      selected_index=1 if dogs.droplet else 0)]

        if action == "Turn On":
            print("\nTurning droplet on\n")
            dogs.create()
        elif action == "Shutdown":
            print("\nShutting down droplet\n")
            dogs.destroy()
        elif action == "View Snapshots":
            print("\nFinding snapshots\n")
            dogs.show_snapshots()
        elif action == "Cleanup Old Snapshots":
            print("\nRemoving old snapshots\n")
            dogs.cleanup()
        elif action == "View Server Info":
            stats(server_selection, servers_config, details=True)
            server_continue = server_selection
            continue

        print("\nWould you like to:")
        selection = cutie.select(["Manage more", "Exit"], selected_index=1)
        if selection == 0:
            continue
        else:
            break
def askUserForPositionInfo():
    '''
    Purpose: On the command line, ask the user to input which position they 
        would like to scrape statistical data for.  If the user does not want 
        to scrape data for all positions, they will be asked what posiiton they 
        are specifically interested in.
        
    Inputs
    ------
        NONE
        
    Outputs
    -------
        scrape_position : string
            Position that the user requests data for 
            (allowed values are 'NONE', 'QB', 'RB', 'FB', 'WR', 'TE', 
                  'CB', 'DB', 'DE', 'DT', 'DL', 'LB', 'NT', 'S' or 'all') 
             ** NOTE: WR includes TE **
            [default = 'all']
    '''
    # Set the default for scraping to all positions
    scrape_position = 'all'

    # Prompt the user to select the years they would like to scrape data for
    list_all = [
        'Would you like to scrape player info for all positions?', 'No', 'Yes'
    ]
    all_positions = list_all[cutie.select(list_all,
                                          caption_indices=[0],
                                          selected_index=1)]

    # Scrape player-specific data for all positions
    if all_positions == 'Yes':
        print('Proceeding to scrape player info for all available posiitons.')
        scrape_position = [
            'NONE', 'QB', 'RB', 'FB', 'WR', 'TE', 'CB', 'DB', 'DE', 'DT', 'DL',
            'LB', 'NT', 'S'
        ]
    # Scrape player-specific data for one position
    else:
        years = [
            'Select the position for which you would like to scrape player info:',
            'NONE', 'QB', 'RB', 'FB', 'WR', 'TE', 'CB', 'DB', 'DE', 'DT', 'DL',
            'LB', 'NT', 'S'
        ]
        scrape_position = [
            years[cutie.select(years, caption_indices=[0], selected_index=1)]
        ]
        print(f'Proceeding to scrape player info for {scrape_position}')

    return scrape_position
def granny_house():
  '''
  sidetrack where player finds a nice old lady who helps them with chicken soup

  asks player if they want the powerup, and they appends the player's health value

  Parameters:
  -----------
  player input : str

  Returns:
  --------
  either pass or updated self.health value

  '''
  print ('As you approach the red brick house, you notice\nit has a beautiful rose garden in the front yard.')
  time.sleep(1)
  print ('Once you arrive at the gate of the front yard you notice\na small old woman watering the garden.')
  time.sleep(2)
  print ('Grandma: hellllooooo? Is someone there?')
  time.sleep(2)
  print ('Grandma: Oh hello youngster!')
  time.sleep(2)
  print ('Grandma: You are the first human I have seen in ages!\nIt is usually just monters in these parts!')
  print ('Grandma: Would you like to step inside and have some\nnice homemade dragon and mushroom soup?')
  choices = ['Yes','No']
  play_cho = choices[cutie.select(choices)]
  if play_cho == 'Yes':
    print ('The soup was delicious and nourishing! You gain 80 HP.\nYou thank Grandma for the soup and head on')
    hero.increase_health(80)
    print("Your health is now at: " + str(hero.show_health()) + " HP.")
  else:
    print ('You decline a bowl of grandma\'s soup and head on.')
def fifth_choice():
  '''
  once again asks the player whether or not they want to continue

  Parameters:
  -----------
  Player input : str

  Returns:
  --------
  either pass to next function or sys.exit

  '''
  time.sleep(1)
  print ('As you continue on your journey you come across\na dark and sinister looking cave.')
  time.sleep(1)
  print ('You sense an overwhelming source of evil\nemanating from the cave.')
  time.sleep(1)
  print ('Do you dare to continue? Or will you run home?')
  choices = ['Dare to continue', 'Run home']
  play_cho = choices[cutie.select(choices)]
  if play_cho == 'Dare to continue':
    pass
  else:
    print ('Good choice, your mom made you cookies.')
    sys.exit('Thanks for playing!')
 def mainloop(self):
     while True:
         try:
             clear_screen()
             self.show_info()
             print("\nSelect One:")
             action = MENU_OPTIONS[cutie.select(MENU_OPTIONS)]
             if action == "Connect":
                 self.connect()
             elif action == "Unit Configuration":
                 self.configure()
             elif action == "Vehicle Configuration":
                 self.vehicle_configure()
             elif action == "Log":
                 self.log()
             elif action == "Monitor":
                 self.monitor()
             elif action == "NTRIP":
                 self.ntrip_menu()
             elif action == "Upgrade":
                 self.upgrade()
             elif action == "Plot":
                 self.plot()
             elif action == "Refresh":
                 self.refresh()
             elif action == "Exit":
                 self.exit()
             elif action == "Restart Unit":
                 self.reset()
             else:
                 raise Exception("invalid action: " + str(action))
         except (socket.error, socket.herror, socket.gaierror, socket.timeout, serial.SerialException, serial.SerialTimeoutException) as e:
             print(e)
             self.release()
             show_and_pause("connection error. check cable and reconnect")
def sixth_choice():
  '''
  asks player if they'd like to rest before final battle

  if so player is given ability to increase attack points by 20

  Parameters:
  -----------
  Player input : str

  Returns: 
  --------
  either pass to next function or update to self.attackPoints

  '''
  time.sleep(1)
  print ('You have ventured deep into the cave,\ncautiously approaching whatever threat lies ahead.')
  time.sleep(1)
  print ('This cave oozes senses of evil and danger,\nand you fell like you have finally reached its source.')
  time.sleep(1)
  print ('You know you have a fierce battle ahead.')
  time.sleep(1)
  print ('Do you wish to engage in a warrior\'s meditation in order\nto focus your mind, or do you want to charge straight in?')
  choices = ['Meditate', 'Charge in']
  play_cho = choices[cutie.select(choices)]
  if play_cho == 'Meditate':
    print ('Your intense meditation brings you heightened focus!')
    hero.increase_attackPoints(20)
    print ('Your attack points increased by 20!\nYou get up and charge on feeling ready')
  else:
    print ('You grab your sword and charge ahead!')
def fourth_choice():
  '''
  asks player if they want to check out a house

  Parameters:
  -----------
  player input : str

  Returns:
  --------
  either granny_house() or pass

  '''
  time.sleep(1)
  print ('You are exhausted from your battle.')
  time.sleep(1)
  print ('Off in the distance you see a red brick house\nand you detect the faintest smell of home-cooked soup.')
  time.sleep(1)
  print ('Do you check out the house or continue through the forest?')
  choices = ['Check out the house','Contine through the forest']
  play_cho = choices[cutie.select(choices)]
  if play_cho == 'Check out the house':
    granny_house()
  else:
    print ('You decide to continue on your journey.')
Example #9
0
def initialize_game():
    scroll('\n.............')
    scroll('\nInitializing program')
    scroll('\n...loading...')
    scroll('\n...loading...')
    scroll_custom('\n#########################################', 0.001)
    scroll_custom('\n#########################################', 0.001)
    scroll_custom('\n#########################################', 0.001)
    scroll_custom('\n#########################################', 0.001)
    scroll_custom('\n#########################################', 0.001)
    scroll_custom('\n#            -   want   -               #', 0.02)
    scroll_custom('\n#            -    to   -                #', 0.02)
    scroll_custom('\n#            -   play?   -              #', 0.02)
    scroll_custom('\n#########################################', 0.001)
    scroll_custom('\n#########################################', 0.001)
    scroll_custom('\n#########################################', 0.001)
    scroll_custom('\n#########################################', 0.001)
    scroll_custom('\n#########################################', 0.001)
    scroll_custom('\n#########################################', 0.001)
    return_variable = 0
    options = ['play', 'quit']
    cute_option = options[cutie.select(options)]
    if cute_option == 'play':
        return_variable = 1
    elif cute_option == 'quit':
        return_variable = 2
    return return_variable
def start_game():
  '''
  function at start of game, gives first choice using cutie

  uses cutie to ask player if they want to forge ahead into the forest

  Parameters:
  -----------
  User input : str

  Returns:
  --------
  players choice, either quit or continue the game

  '''
  time.sleep(1)
  print ('You find yourself alone in front of a dark forest.')
  print('Up ahead there is a single path, blocked by vines.')
  time.sleep(3)
  print('Do you forge on ahead, slashing the debris out of your way?')
  time.sleep(2)
  print ('Or do you chicken out and head home?')
  time.sleep(1)
  choices = ['Forge on ahead', 'Chicken out']
  play_cho = choices[cutie.select(choices)]
  if play_cho == 'Forge on ahead':
    pass
  else:
    print('Good choice, your mom made you hot coco.')
    sys.exit('Thanks for playing!') 
Example #11
0
	def solve(self):
		# solve t for y: ds = v1*dt + (1/2)a(dt)^2
		
		self.y.t = quad(0.5*self.y.a, self.y.v1, -1*self.y.s)
		if not self.y.t:
			print("No solution")
			close(0)
		if len(self.y.t) == 2:
			
			options = ["Which of these is right for time", self.y.t[0], self.y.t[1]]

			option = options[cutie.select(options, caption_indices=[0],selected_index=1)]
			if option == self.y.t[0]:
				self.y.t = self.y.t[0]
			else:
				self.y.t = self.y.t[1]
			print("\033[4A")
			print("\033[K")
			print("\033[K")
			print("\033[K")
			print("\033[K")
			print("\033[5A")
		else:
			self.y.t = self.y.t[0]

		# add to x
		self.x.t = self.y.t
		#solve for ds for x: ds = v1*dt
		self.x.s = self.x.v1*self.x.t
		# solve for v2 for y
		self.y.v2 = sqrt(2*self.y.a*self.y.s + self.y.v1*self.y.v1)
    def connect_com(self):
        print("\nConnect by COM port:")
        options = ["Auto", "Manual", "cancel"]
        selected = options[cutie.select(options)]
        if selected == "Auto":
            self.release()
            board = IMUBoard.auto(set_data_port=True)
        elif selected == "Manual":
            self.release()
            board = IMUBoard()
            board.connect_manually(set_data_port=True)
        else:  # cancel
            return
        self.board = board
        data_port_name = board.data_port_name
        board.data_connection.close()

        self.serialnum = self.retry_command(method=board.get_serial, response_types=[b'SER']).ser.decode()
        self.version = self.retry_command(method=board.get_version, response_types=[b'VER']).ver.decode()
        self.pid = self.retry_command(method=board.get_pid, response_types=[b'PID']).pid.decode()

        #let io_thread do the data connection - give it the signal, close this copy
        self.com_port.value, self.com_baud.value = data_port_name.encode(), board.baud
        self.con_type.value = b"COM"
        self.con_on.value = 1
        self.con_start.value = 1
        return {"type": "COM", "control port": board.control_port_name, "data port": data_port_name}
def first_choice():
  '''
  Provides first choice

  Asks player if they want to rest and if they say yes appends the health value of the player to + 20 points

  Parameters:
  -----------
  Player input : str

  Returns:
  --------
  appended value of character health or nothing

  '''
  time.sleep(1)
  print ('After walking for sometime you feel tired.')
  time.sleep(1)
  print ('Do you want to rest?')
  choice = ['Yes','No']
  play_cho = choice[cutie.select(choice)]
  if play_cho == 'Yes':
    time.sleep(1)
    print ('You take a small rest.')
    time.sleep(1)
    print ('You feel very well rested.')
    time.sleep(1)
    print('20 plus HP granted!\nYou continue on your journey.')
    hero.increase_health(20)
  else:
    print ('You press on like a true warrior') 
def second_choice():
  '''
  asks player if they want to eat something in the forest

  asks the player to decide if they want to eat a mushroom, and if they do rolls a dice to see if they survive food poisoning 

  Parameters:
  -----------
  player input : str

  Returns:
  --------
  whether or not player is dead and if they suffered damage

  '''
  time.sleep(2)
  print ('Having travelled for hours now,')
  time.sleep(1)
  print('You are getting quite hungry.')
  time.sleep(1)
  print('You noticed you are surrounded by\na field of polka-dotted neon green mushrooms.')
  time.sleep(2)
  print('Should you take a rest and eat some mushrooms?')
  time.sleep(1)
  choices = ['Have a snack','Keep going']
  play_cho = choices[cutie.select(choices)]
  if play_cho == 'Have a snack':
    mush_roll() 
  else:
    pass
def main():
    global cancel_count

    # Remove old shutdown file
    try:
        os.remove("/home/pi/accelerometer_raspi/source/shutdown")
    except (OSError):
        pass

    myLCD.updateLCD(str2="WELCOME", str3="REXNORD EDGE DEVICE")
    sleep(2)

    myLCD.clearLine(2)
    myLCD.clearLine(3)

    while True:
        select_option()
        cutie.getTime()
        if cancel_count >= 3:
            myLCD.clear_all()
            options = ['EXIT', 'SHUTDOWN']
            selected_option = cutie.select(options, selected_index=0)
            if selected_option == 0:
                myLCD.updateLCD(str2='EXITING PROGRAM', str3='GOODBYE')
                sleep(2)
                exit()
            elif selected_option == 1:
                myLCD.updateLCD(str2='EXITING PROGRAM', str3='GOODBYE')
                sleep(2)
                os.system('sudo shutdown now -h')
def third_choice():
  '''
  run away or go towards danger

  asks player if they want to quit or keep playing, 

  Parameters:
  -----------
  Player input : str

  Returns:
  --------
  their answer of whether or not to keep playing

  '''
  time.sleep(1)
  print ('You hear a melody in the distance.')
  time.sleep(1)
  print ('It is beautiful but you can sense danger.')
  time.sleep(1)
  print ('Do you follow the melody or do you run home?')
  choices = ['Follow the melody', 'run home']
  play_cho = choices[cutie.select(choices)]
  if play_cho == 'Follow the melody':
    follow_melo()
  else:
    time.sleep(1)
    print ('Good choice, your mom made you grilled cheese.')
    sys.exit('Thanks for playing!')
Example #17
0
def set_editor():

    editor_opts = {
        "Vim": "vim ",
        "VSCode": "start code ",
        "Notepad++": "Notepad++",
        "Sublime Text": "subl",
        "Atom": "atom"
    }
    print(
        colored('Editor selection (should be launchable from terminal)',
                'yellow'))
    print(colored('Choose editor (use up/down keys):', 'yellow'))
    editor_keys = list(editor_opts.keys())
    answer = cutie.select(editor_keys, selected_index=0)

    ## Store the config file
    config = configparser.ConfigParser()
    home = os.path.expanduser("~")
    config_file = os.path.join(home, "codecomb_config.ini")
    config.read(config_file)

    config['EDITOR'] = {"startcmd": editor_opts[editor_keys[answer]]}

    with open(config_file, "w") as fmtFile:
        config.write(fmtFile)
    def set_cfg(self):
        print("\nselect configurations to write\n")
        # hide udp settings if connected by udp. otherwise you can break the connection. or should we allow it?
        #skip_indices = UDP_FIELD_INDICES if self.connection_info["type"] == "UDP" else []

        #check if it has odometer port or not, then show/hide in options
        field_names = CFG_FIELD_NAMES[:]
        field_codes = CFG_FIELD_CODES[:]
        if not self.has_odo_port:
            ind = field_codes.index('rport3')
            field_names.pop(ind)
            field_codes.pop(ind)

        options = field_names + ["cancel"]
        selected_index = cutie.select(options)
        if options[selected_index] == "cancel":
            return
        args = {}
        name, code = field_names[selected_index], field_codes[selected_index]

        if code == "orn": # special case: choose between two common options or choose to enter it
            value = self.select_orientation()
        elif code in CFG_VALUE_OPTIONS:
            print("\nselect " + name)
            options = CFG_VALUE_OPTIONS[code]
            value = str(options[cutie.select(options)]).encode()
        else:
            print("\nenter value for " + name + " " + CFG_FIELD_EXAMPLES[code])
            value = input().encode()
        args[code] = value

        #if connected by udp, changing udp settings can disconnect - give warning
        if code in UDP_FIELDS and self.connection_info["type"] == "UDP":
            change_anyway = cutie.prompt_yes_or_no("Changing UDP settings while connected by UDP may close the connection. Change anyway?")
            if not change_anyway:
                return

        #if setting odometer unit, first set odometer to on, then set the unit
        if code == "odo":
            args2 = {"odo": b'on'}
            resp = self.retry_command(method=self.board.set_cfg_flash, args=[args2], response_types=[b'CFG', b'ERR'])

        resp = self.retry_command(method=self.board.set_cfg_flash, args=[args], response_types=[b'CFG', b'ERR'])
        if not proper_response(resp, b'CFG'):
            show_and_pause("") # proper_response already shows error, just pause to see it.
 def select_orn_24_opts(self):
     print("\nselect ORIENTATION:")
     options = CFG_VALUE_OPTIONS["orn"]
     chosen = options[cutie.select(options)]
     if "+X+Y+Z" in chosen:
         return b'+X+Y+Z'
     elif "+Y+X-Z" in chosen:
         return b'+Y+X-Z'
     else:  # select it yourself
         print("\nenter value for orientation "+ CFG_FIELD_EXAMPLES["orn"])
         return input().encode()
 def select_orn_8_opts(self):
     print("\nselect ORIENTATION:")
     options = ORN_8_OPTIONS
     chosen = options[cutie.select(options)]
     #allow notes like (north east up) in the name
     if "+X+Y+Z" in chosen:
         return b'+X+Y+Z'
     elif "+Y+X-Z" in chosen:
         return b'+Y+X-Z'
     else:
         #if no note, the value is correct
         return chosen.encode()
Example #21
0
def process_choice_input():
    inputPrompt = [
        'Enter your desired sorting method:', 'hot', 'new', 'rising',
        'random_rising', 'controversial', 'top'
    ]

    captions = [0]

    prompt = inputPrompt[cutie.select(inputPrompt,
                                      caption_indices=captions,
                                      selected_index=6)]
    return prompt
def select_option():
    global cancel_count

    options = ['RECORD DATA', 'TRANSFER DATA', 'SYSTEM FUNCTIONS']
    selected_option = cutie.select(options, selected_index=0)

    if selected_option == -1:
        cancel_count += 1
    elif selected_option == 0:
        record_data()
        cancel_count = 0
    elif selected_option == 1:
        transfer_usb()
        cancel_count = 0
    elif selected_option == 2:
        options = ['DELETE FILE', 'SET CLOCK']
        selected_option = cutie.select(options, selected_index=0)

        if selected_option == 0:
            system_functions.delete_file()
        elif selected_option == 1:
            system_functions.set_time()
Example #23
0
def main():
    """Main.
    """
    if cutie.prompt_yes_or_no('Are you brave enough to continue?'):
        # List of names to select from, including some captions
        names = [
            'Kings:', 'Arthur, King of the Britons',
            'Knights of the Round Table:', 'Sir Lancelot the Brave',
            'Sir Robin the Not-Quite-So-Brave-as-Sir-Lancelot',
            'Sir Bedevere the Wise', 'Sir Galahad the Pure',
            'Swedish captions:', 'Møøse'
        ]
        # Names which are captions and thus not selectable
        captions = [0, 2, 7]
        # Get the name
        name = names[cutie.select(names,
                                  caption_indices=captions,
                                  selected_index=8)]
        print(f'Welcome, {name}')
        # Get an integer greater or equal to 0
        age = cutie.get_number('What is your age?',
                               min_value=0,
                               allow_float=False)
        nemeses_options = [
            'The French',
            'The Police',
            'The Knights Who Say Ni',
            'Women',
            'The Black Knight',
            'The Bridge Keeper',
            'Especially terrifying:',
            'The Rabbit of Caerbannog',
        ]
        print('Choose your nemeses')
        # Choose multiple options from a list
        nemeses_indices = cutie.select_multiple(nemeses_options,
                                                caption_indices=[6])
        nemeses = [
            nemesis for nemesis_index, nemesis in enumerate(nemeses_options)
            if nemesis_index in nemeses_indices
        ]
        # Get input without showing it being typed
        quest = cutie.secure_input('What is your quest?')
        print(f'{name}\'s quest (who is {age}) is {quest}.')
        if nemeses:
            if len(nemeses) == 1:
                print(f'His nemesis is {nemeses[0]}.')
            else:
                print(f'His nemeses are {" and ".join(nemeses)}.')
        else:
            print('He has no nemesis.')
Example #24
0
def get_one_result(downloader, tv_show):
    """
    The function will get a spesific result from the search query
    :param tv_show: the name of the tv show (str)
    :return: tv_name, base_url (tupple)
    """
    search_results = downloader.search(tv_show)
    if len(search_results) == 1:  # Case that there was only one result
        return search_results[0]
    click.echo('Select TV show to download')
    index = cutie.select([str(tv) for tv in search_results] + ['Exit'])
    if index == len(search_results):  #if user wants to exit
        exit()
    return search_results[index]
Example #25
0
def askUserForScrapeYears():
    '''
    Purpose: On the command line, ask the user to input which years they would
        like to scrape statistical data for.  If the user does not want to 
        scrape data for all years, they will be asked what years they are
        specifically interested in.
        
    Input:
        - NONE
        
    Output:
        (1) scrape_year (string): Year that the user requests data for 
            (allowed values are from 2009-2020 or 'all') [default = 'all']
    '''
    # Set the default for scraping to all years
    scrape_year = 'all'

    # Prompt the user to select the years they would like to scrape data for
    list_all = ['Would you like to scrape all years?', 'Yes', 'No']
    all_years = list_all[cutie.select(list_all,
                                      caption_indices=[0],
                                      selected_index=1)]

    if all_years == 'Yes':
        print('Proceeding to scrape all available years.')
    else:
        years = [
            'Select the year you would like to scrape:', '2021', '2020',
            '2019', '2018', '2017', '2016', '2015', '2014', '2013', '2012',
            '2011', '2010', '2009', 'None'
        ]
        scrape_year = years[cutie.select(years,
                                         caption_indices=[0],
                                         selected_index=1)]
        print(f'Proceeding to scrape statistics for {scrape_year}')

    return scrape_year
Example #26
0
def next_question(concept):
    global token, responses

    if token is None:
        print('You must first log in.')
        return

    r = requests.post('http://localhost:5000/api/session/get_question',
                      json={
                          'token': token,
                          'concept': concept
                      })

    if r.status_code == 401:
        print('Please log in again.')
        return

    data = r.json()
    question = data['question']
    answer = data['answer']
    options = data['options']

    # We need to do two things: check the answer and inform the user of
    # the result, and store this info
    print(question)
    selected = cutie.select(options, selected_index=0)
    if selected == answer:
        print('Correct!')
    else:
        print('Incorrect: The right answer is option', answer + 1)

    r = requests.post('http://localhost:5000/api/session/submit',
                      json={
                          'question_id': data['_id'],
                          'response': selected,
                          'correct': answer,
                          'token': token
                      })

    if r.status_code != 200:
        print(r.json())

    responses.append({
        'question_id': data['_id'],
        'response': selected,
        'correct': answer
    })

    print('\n\n')
Example #27
0
def filter_menu():
    """prompts filter type"""

    response = convert_shared_menu()
    print('-= Which filter would you like to use? =-')
    choices = [
        'NEAREST - sharp tiles, some artifacts', 'BOX - idential weight',
        'BILINEAR - linear interpolation',
        'HAMMING - sharper than BILINEAR, less distortion than BOX',
        'BICUBIC - cubic interpolation', 'LANCZOS - trucated sinc'
    ]
    val = choices[cutie.select(choices, selected_index=1)].lower()
    response['filter_type'] = lookup_filter(val)

    return response
Example #28
0
def find_config_file():
    if user_config_file.exists() and local_config_file.exists():
        print(
            "Config files were found in both local and user directory, which do you want to use?"
        )
        opts = [user_config_file, local_config_file]
        return opts[cutie.select(opts)]
    elif local_config_file.exists():
        print("Using local config file")
        return local_config_file
    elif user_config_file.exists():
        print("Using stored config file")
        return user_config_file
    else:
        raise Exception("No config file found!")
Example #29
0
def main():
    """Main.
    """
    if cutie.prompt_yes_or_no('Are you brave enough to continue?'):
        names = [
            'Arthur, King of the Britons', 'Sir Lancelot the Brave',
            'Sir Robin the Not-Quite-So-Brave-as-Sir-Lancelot',
            'Sir Bedevere the Wise', 'Sir Galahad the Pure', 'Møøse'
        ]
        name = names[cutie.select(names, selected_index=5)]
        print(f'Welcome, {name}')
        age = cutie.get_number('What is your age?',
                               min_value=0,
                               allow_float=False)
        quest = cutie.secure_input('What is your quest?')
        print(f'{name}\'s quest (who is {age}) is {quest}.')
 def configure(self):
     if not self.board:
         show_and_pause("Must connect before configuring")
         return
     clear_screen()
     self.read_all_configs(self.board)  # show configs automatically
     #check connection again since error can be caught in read_all_configs
     if not self.con_on.value:
         return
     #print("configure:")
     actions = ["Edit", "Done"]
     selected_action = actions[cutie.select(actions)]
     if selected_action == "Edit":
         self.set_cfg()
         self.configure()  # go back to configure screen to view/edit again. or remove this line -> main screen
     else:
         return