RAPP Platform  v0.6.0
RAPP Platform is a collection of ROS nodes and back-end processes that aim to deliver ready-to-use generic services to robots
 All Classes Namespaces Files Functions Variables Macros
weather_reporter_factory.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- encode: utf-8 -*-
3 
4 #Copyright 2015 RAPP
5 
6 #Licensed under the Apache License, Version 2.0 (the "License");
7 #you may not use this file except in compliance with the License.
8 #You may obtain a copy of the License at
9 
10  #http://www.apache.org/licenses/LICENSE-2.0
11 
12 #Unless required by applicable law or agreed to in writing, software
13 #distributed under the License is distributed on an "AS IS" BASIS,
14 #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #See the License for the specific language governing permissions and
16 #limitations under the License.
17 
18 # Authors: Aris Thallas
19 # contact: aris.thallas@{iti.gr, gmail.com}
20 
21 from rapp_weather_reporter.yweather_reporter import YWeatherReporter
22 from rapp_weather_reporter.forecastio_reporter import ForecastIOReporter
23 
24 from rapp_utilities import RappUtilities
25 from rapp_exceptions import RappError
26 
27 
28 ## @class WeatherReporterFactory
29 # @brief Creates and returns the class of the weather reporter requested.
30 # Implements a factory pattern.
31 class WeatherReporterFactory(object):
32 
33  ## @brief Select proper weather reporter according to request
34  #
35  # @param weather_reporter [string] The name of the weather reporter
36  #
37  # @return res
38  # [rapp_weather_reporter.rapp_weather_reporter.WeatherReporterBase]
39  # The weather reporter
40  #
41  # @exceptions RappError Wrong weather reporter provided by user
42  def select_weather_reporter(self, weather_reporter=''):
43 
44  # Set yweather(Yahoo) as a default weather reporter
45  if weather_reporter == '':
46  weather_reporter = 'forecastio'
47 
48  if weather_reporter == 'yweather':
49  RappUtilities.rapp_print('Creating yweather weather reporter', 'DEBUG')
50  return YWeatherReporter()
51  elif weather_reporter == 'forecastio':
52  RappUtilities.rapp_print('Creating forecast.io weather reporter', 'DEBUG')
53  return ForecastIOReporter()
54  else:
55  RappUtilities.rapp_print('Wrong weather reporter provided', 'ERROR')
56  raise RappError('Wrong weather reporter provided')
Creates and returns the class of the weather reporter requested.
def select_weather_reporter
Select proper weather reporter according to request.