Пример #1
0
    def getInputCountry(self, country=None):

        countries = OrderedDict()
        countries[1] = 'SLOVENIA'
        countries[2] = 'AUSTRIA'
        countries[3] = 'ITALY'
        countries[4] = 'GERMANY'
        countries[5] = 'NETHERLANDS'
        countries[6] = 'CROATIA'
        countries[7] = 'FRANCE'
        countries[8] = 'FRANCE-NICE'
        countries[9] = 'GREECE'

        if country in countries:
            return countries[country]

        for key, value in countries.items():
            print key, ' --> ', value

        user_input = getInputInt(
            "Please input country number to use (or press Enter to use DEFAULT): ",
            default=None)
        user_choice = countries.get(user_input)
        if user_choice is None:
            print "User choice: 'DEFAULT'"
        else:
            print "User choice: %r" % user_choice
        return user_choice
Пример #2
0
    def getStartEndResolution(self, simulation_no, iteration_no):
        """return  StartEndResolution based on default values and user input, that can modify defaults"""

        config_values = self.db.getIterationValuesFromDb(
            simulation_no=simulation_no,
            fields=['main_configs'],
            yearly=False,
            iteration_no=iteration_no,
            one_result=True,
        )['main_configs']

        def_start = config_values['start_date']  #get defaults
        def_end = config_values['end_date']  #get defaults
        def_res = int(config_values['resolution'])  #get defaults

        memo = " (from %s to %s)" % (def_start, def_end)
        memo_res = "Please select resolution of graph in days (or press Enter to use default %s) : " % def_res

        start_date = getInputDate(
            text="Start date" + memo,
            default=def_start)  #get user input of use default
        end_date = getInputDate(text="End date" + memo, default=def_end)
        resolution = getInputInt(memo_res,
                                 default=def_res)  # ask user resolution
        return (start_date, end_date, resolution)
Пример #3
0
 def simulationsLog(self, last=None):
     """Show last simulation logs - short information about number of iterations,date and comments"""
     default = 10
     if last is None:
         last = getInputInt(
             "Please input number of number of last simulations to display (or press Enter to use default %s) : "
             % default, default)
     self.db.printLastSimulationsLog(last)
Пример #4
0
 def getInputWeatherElectricitySimulationNoOrAll(self, what='????'):
     """User Input for simulation or return None"""
     return getInputInt(
         "Please input which %s simulation Number to plot (or press Enter to plot ALL ): "
         % what,
         default=None)
Пример #5
0
 def getInputIteration(self, text, simulation_no):
     """User input for choosing iteration no"""
     iterations = "[1-%s]" % (self.db.getIterationsNumber(simulation_no))
     return getInputInt(
         "Please enter iteration of Simulation %s for %s from %s (or press Enter to use first): "
         % (simulation_no, text, iterations), 1)
Пример #6
0
 def getInputSimulation(self, text=""):
     """User input for choosing simulation no"""
     last_simulation = self.db.getLastSimulationNo()
     return getInputInt(
         "Please input ID of simulation for %s (or press Enter to use last-run %s): "
         % (text, last_simulation), last_simulation)
Пример #7
0
 def getNumberIterations(self, text="", default=""):
     """User input for number of iterations"""
     return getInputInt(
         "Please select number of iterations to run (or press Enter to use default %s) : "
         % default, default)