Esempio n. 1
0
    def ask_solution_stack(cls, parameter_pool):

        # Skip if user supplies solution stack string as CLI arguments, or already by terminal
        if parameter_pool.has(ParameterName.SolutionStack) \
            and ParameterSource.is_ahead(parameter_pool.get_source(ParameterName.SolutionStack),
                                         ParameterSource.ConfigFile):
            print((TerminalPromptSettingParameterMessage[ParameterName.SolutionStack].\
                  format(parameter_pool.get_value(ParameterName.SolutionStack))))
            return

        original_value = parameter_pool.get_value(ParameterName.SolutionStack) \
            if parameter_pool.has(ParameterName.SolutionStack) else None
        append_message = '' if original_value is None \
            else TerminalMessage.CurrentValue.format(original_value)
        print((TerminalPromptAskingMessage[ParameterName.SolutionStack].\
              format(append_message)))

        stacks = api_wrapper.retrieve_solution_stacks(parameter_pool)
        stack_index = cls.single_choice(stacks,
                                        TerminalMessage.AvailableSolutionStack,
                                        None, original_value is not None)

        value = stacks[
            stack_index] if stack_index is not None else original_value
        stack = Parameter(ParameterName.SolutionStack, value,
                          ParameterSource.Terminal)
        parameter_pool.put(stack, True)
 def ask_solution_stack(cls, parameter_pool):
     
     # Skip if user supplies solution stack string as CLI arguments, or already by terminal
     if parameter_pool.has(ParameterName.SolutionStack) \
         and ParameterSource.is_ahead(parameter_pool.get_source(ParameterName.SolutionStack),
                                      ParameterSource.ConfigFile):
         print(TerminalPromptSettingParameterMessage[ParameterName.SolutionStack].\
               format(parameter_pool.get_value(ParameterName.SolutionStack)))
         return            
     
     original_value = parameter_pool.get_value(ParameterName.SolutionStack) \
         if parameter_pool.has(ParameterName.SolutionStack) else None
     append_message = u'' if original_value is None \
         else TerminalMessage.CurrentValue.format(original_value)        
     print(TerminalPromptAskingMessage[ParameterName.SolutionStack].\
           format(append_message))
     
     stacks = api_wrapper.retrieve_solution_stacks(parameter_pool)
     stack_index = cls.single_choice(stacks, 
                                     TerminalMessage.AvailableSolutionStack, None,
                                     original_value is not None)
     
     value = stacks[stack_index] if stack_index is not None else original_value
     stack = Parameter(ParameterName.SolutionStack, value, ParameterSource.Terminal)
     parameter_pool.put(stack, True)