Esempio n. 1
0
class WeatherClock(object):
    
    any_handler = None
    interval = 60
    
    def __init__(self, url):
        self._weather = Weather(url, 10)
        self.time = time.time()
        self._prev_time = time.time()
        self.temperature = 0
        self._prev_temperature = 0
        self.conditions = ''
        self._prev_conditions = ''

    def poll(self):
        self._weather.poll()
        self.time = time.time()
        self.temperature = int(float(self._weather.current_conditions()['Temperature']))
        self.conditions = self._weather.current_conditions()['Conditions']
        if self.time - self._prev_time > self.interval or self.temperature != self._prev_temperature or self.conditions != self._prev_conditions:
            if self.handler is not None:
                self.handler(self.time, self.temperature, self.conditions)
            self._prev_time = self.time
            self._prev_conditions = self.conditions
            self._prev_temperature = self.temperature
Esempio n. 2
0
def weather_current():
    weather = Weather(unit=Unit.CELSIUS)
    location = weather.lookup_by_location('jaipur')
    condition = location.condition
    con = f'It\'s {condition.text} today'
    temp =f'With temp {condition.temp}𐤏C'
    call(['notify-send','-u','normal', con, temp])
def getWeather(forecastIndex):
    weather = Weather()
    lookup = weather.lookup(26237347) #TKO
    #condition = lookup.condition()
    forecasts = lookup.forecast()
    #0 is today, 1 is tomorrow, etc...
    f = forecasts[forecastIndex]
    return  f.text() + ": hight " + str(f2c(f.high())) + " / low " +  str(f2c(f.low()))
def getWeather(forecastIndex):
    weather = Weather(unit=Unit.CELSIUS)
    lookup = weather.lookup(26237347) #TKO
    #condition = lookup.condition()
    forecasts = lookup.forecast
    #0 is today, 1 is tomorrow, etc...
    f = forecasts[forecastIndex]
#    return  [f.text, f2c(f.high), f2c(f.low)]
    return  [f.text, float(f.high), float(f.low)]
Esempio n. 5
0
 def checkWeather(self):
     wi = WeatherInfo()
     wi.parse(self._location)
     
     newWeather = Weather()
     newWeather.extractData(wi,self._unit)
     self._weather = newWeather 
   
     self.update()
Esempio n. 6
0
    def checkWeather(self):
        wi = WeatherInfo()
        mapper = ConditionMapper()
        wi.parse()
        weather = Weather()
        weather.extractData(wi, self._unit)

        self.lb_location.setText("Location: " + weather.location)

        self.lb_temperature.setText(weather.current_temperature)
        self.lb_condition.setText("Condition: " + weather.current_condition)
        self.lb_humidity.setText(weather.current_humidity)
        self.lb_wind.setText(weather.current_wind)

        # current condition image
        self.svg_current.setImagePath(self._image_prefix + mapper.getMappedImageName(weather.current_condition))
        self.svg_current.resize(self._big_img_width, self._big_img_height)
        self.svg_w_current.setSvg(self.svg_current)

        # load forecast days
        fc_day = weather.fc_dl[0]
        # self.lb_day_fc1.setText("Tomorrow")
        self.lb_day_fc1.setText(fc_day)

        fc_day = weather.fc_dl[1]
        self.lb_day_fc2.setText(fc_day)

        fc_day = weather.fc_dl[2]
        self.lb_day_fc3.setText(fc_day)

        # load forecast images
        fc = weather.fc_conditions[0]
        print fc
        self.svg_fc1.setImagePath(self._image_prefix + mapper.getMappedImageName(fc))
        self.svg_fc1.resize(self._img_width, self._img_height)
        self.svg_w_fc1.setSvg(self.svg_fc1)

        fc = weather.fc_conditions[1]
        print fc
        self.svg_fc2.setImagePath(self._image_prefix + mapper.getMappedImageName(fc))
        self.svg_fc2.resize(self._img_width, self._img_height)
        self.svg_w_fc2.setSvg(self.svg_fc2)

        fc = weather.fc_conditions[2]
        print fc
        self.svg_fc3.setImagePath(self._image_prefix + mapper.getMappedImageName(fc))
        self.svg_fc3.resize(self._img_width, self._img_height)
        self.svg_w_fc3.setSvg(self.svg_fc3)

        self.lb_temp_fc1.setText(weather.fc_low_high[0])
        self.lb_temp_fc2.setText(weather.fc_low_high[1])
        self.lb_temp_fc3.setText(weather.fc_low_high[2])

        # self.layout.addItem(label)
        # self.setLayout(self.layout)
        self.update()
Esempio n. 7
0
def StepOn(conn):
    try:
        conn.Process(1) # block 1 second
    except KeyboardInterrupt: return 0
    now = datetime.datetime.now()
    if now.hour == 8:
        log.debug("send weather...")
        from weather import Weather
        Weather.sendall(conn)
    return 1
Esempio n. 8
0
class WeatherTestCase(unittest.TestCase):

    def setUp(self):
        self.weather = Weather()

    def test_is_stormy_can_be_True(self):
        self.weather._number_generator = MagicMock(return_value=0)
        self.assertTrue(self.weather.is_stormy())

    def test_is_stormy_can_be_False(self):
        self.weather._number_generator = MagicMock(return_value=3)
        self.assertFalse(self.weather.is_stormy())
Esempio n. 9
0
    def getWeather(self,address):

        fullLocName,lat,lng = self.getLoaction(address)
        
        if fullLocName != None:
            webWeather = ServerCaller("https://api.forecast.io/forecast/0e75783f8a3fa4de5b49fff8115d93b4/"+str(lat)+","+str(lng))
            webWeather.callService()
            
            currently = Weather("Currently",webWeather.data["currently"])   
            return currently.getWeatherInfo(fullLocName)
        
        else:
            return "(wtf) - 404 Location not found!"
Esempio n. 10
0
 def post_image_weather(self):
     """ Create weather image and post to twitter """
     # get weather image
     print 'start'
     weth = Weather()
     weather_img, date_title = weth.draw_img()
     # create stream
     print 'streem'
     image_io = StringIO()
     # weather_img.save(image_io, format='JPEG', quality=100, subsampling=0, optimize=True, progressive=True)
     weather_img.save(image_io, format='PNG')
     image_io.seek(0)
     # post tweet
     print 'post'
     return self.twitter.update_status_with_media(media=image_io, status=self.weather_string % date_title)
Esempio n. 11
0
 def weather(self, irc, msg, args, loc):
     """[location]
         location must be zip
         (sorry, you international folks have to go look out a window)
         tells you the current weather for your area
     """
     self._limit_api(irc, lambda:Weather.current(loc))
Esempio n. 12
0
	def __init__(self, testmode = False, scrolling = False):
		self.logger = logging.getLogger(__name__)
		threading.Thread.__init__(self, name='infodisplay')
		self.Event = threading.Event()
		self.logger.info("Starting InfoDisplay class")
		self.chgvol_flag = False
		self.vol_string = ' '
		if keys.board not in ['oled4', 'oled2', 'lcd', 'uoled', 'tft', 'emulator']:
			print 'Error: display type not recognised.'
			sys.exit()			
		print 'Infodisplay board = ',keys.board
		board = importlib.import_module(keys.board)
		self.myScreen = board.Screen()
		if keys.board == 'oled2':
			self.myScreen.set_rowcount(2)
		self.myWeather = Weather(keys.wunder, keys.locn)
		self.myWeather.start()
		self.ending = False
		self.myScreen.start()
		self.rowcount, self.rowlength = self.myScreen.info()
		self.writerow(TITLE_ROW, 'Starting up...'.center(self.rowlength))
#		self.update_info_row()
		self.lasttime = 0
		self.delta = 0.001
		self.scroll_pointer = SCROLL_PAUSE
		self.scroll_string = '       '
		self.prog = 'Info test'
		if testmode:
			self.timer = 2
		else:
			self.timer = INFOROWUPDATEPERIOD
		self.scrolling = scrolling
		self.told = time.clock()
Esempio n. 13
0
 def __init__(self, url):
     self._weather = Weather(url, 10)
     self.time = time.time()
     self._prev_time = time.time()
     self.temperature = 0
     self._prev_temperature = 0
     self.conditions = ''
     self._prev_conditions = ''
Esempio n. 14
0
 def severe(self, irc, msg, args, loc):
     """[location]
         returns severe warnings for the area
         location must be zip
         (sorry, you international folks have to go look out a window)
         tells you the forecast for your area
     """
     self._limit_api(irc, lambda: Weather.severe(loc), 'no alerts')
Esempio n. 15
0
	def __init__(self,rowcount=4):
		self.logger = logging.getLogger(__name__)
		Oled.__init__(self, rowcount)		# We are a subclass, so need to be explicit about which init
		if rowcount == 2:
			self.rowlength = 16
		else:
			self.rowlength = 20
		self.update_row1('Starting up...   ')
		self.myWeather = Weather()
		self.update_row2(1)
		self.lasttime = 0
		self.delta = 0.001
Esempio n. 16
0
def do_weather():
    """Search for location and get current weather. Post used so search
    term can be Unicode.
    """
    post_search = bottle.request.forms.get('search_term')
    if post_search:
        search_term = post_search
    else:
        search_term = "Portland, OR"

    # Find the location
    location = Location()
    try:
        location.search(search_term)
    except TypeError:
        print "Search term error."

    # Get weather info for location
    weather = Weather(location)
    weather.get_forecast()

    return Webpage(weather).render_page()
Esempio n. 17
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("name", type=str,
                        help="Your Name")
    parser.add_argument("area", type=str,
                        help="Area where you live")
    parser.add_argument("-n", "--news", action="store_true",
                        help="")
    cat_help = 'love, inspiring, art, funny, sports, life, management'
    parser.add_argument("-c", "--category", action="store",
                        help=cat_help)

    args = parser.parse_args()
    name = args.name
    area = args.area
    print(day)
    w = Weather(area)

    if args.news:
        n2 = news()
    else:
        n2 = ''

    if args.category:
        a = vars(args)
        quote_of_day = give_quote(a['category'])

    else:
        quote_of_day = give_quote()

    quote_of_day = "Todays quote of the day. {} by {}. ".format(
                        quote_of_day['quote'], quote_of_day['author'])

    morning = Morning(name,
                      area, w.weather_combine(), quote_of_day, news=n2)

    print(subprocess.call('echo Creating MP3 ...', shell=True))
    morning.create_mp3(morning.create_greeting())
    print(morning.greeting)
Esempio n. 18
0
def main():
    dates = ['2015-06-20', '2015-06-21', '2015-06-22', '2015-06-23', '2015-06-24']
    api_key = os.environ.get("WEATHER_API_KEY", None)
    latitude, longitude = (-35.280317, 149.111644)

    weather = Weather(api_key, latitude, longitude, units='si')
    logger = LogData()

    for each_date in dates:
        forecast = weather.retrieve_forecast(each_date)

        weather_whole_day = weather.retrieve_weather_from_day(forecast)
        hourly_weather = weather.retrieve_weather_by_hour(forecast)
        weather_6_am = hourly_weather[6]

        night_weather, day_weather = weather.summarise_night_day(hourly_weather, np.mean)

        logger.log_output(weather_whole_day, each_date, 'daily')
        logger.log_output(weather_6_am, each_date, 'hourly', 6)
        logger.log_output(night_weather, each_date, 'night')
        logger.log_output(day_weather, each_date, 'day')

    logger.write_output('test.csv')
Esempio n. 19
0
 def init_physics(self):
     # Box2D Initialization
     self.worldAABB = box2d.b2AABB()
     self.worldAABB.lowerBound = (-self.window.width*4, -self.window.height*4)
     self.worldAABB.upperBound = (self.window.width*8, self.window.height*8)
     gravity = (0.0, -21.0)
     
     doSleep = True
     self.contact_listener = ContactListener()
     self.world = box2d.b2World(self.worldAABB, gravity, doSleep)
     self.world.SetContactListener(self.contact_listener)
     self.build_map_container()
     self.build_ground()
     self.build_objects()        
     self.weather = Weather(self)
Esempio n. 20
0
    def __init__(self):
        self.running = False
        self.news = NewsReader()
        self.thread_queue = Queue()
        self.voice_parser = VoiceInputParser(self)
        self.clap_detector = ClapDetector(self.thread_queue)
        self.cur_speech_process = None
        self.speech_q = Queue()
        self.last_update = datetime.now()
        self.alarms = []
        self.alarm_tones = []
        self.alarm_index = 0
        self.cur_alarm_process = None
        self.state = States.Idle

        self.weather = Weather()
Esempio n. 21
0
 def get(self, time):
     (_, measured_temp, city_url) = Weather.get_temp('Skopje')
     record = Record()
     record.temperature = measured_temp
     record.put()
     today = datetime.date.today()
     todays_records = Record.all().filter('date', today).fetch(3)
     template_values = {'temperature': measured_temp,
                        'order': ORDER[int(time)],
                        'time': TIME[int(time)],
                        'city_url': city_url}
     if len(todays_records) >= 3:
         sum = reduce(lambda a, b: a+b.temperature, todays_records, 0)
         template_values['mean'] = round(float(sum) / len(todays_records))
         template_values['day'] = today.strftime('%B %d')
     self.render_mail(MEASURE_EMAIL_TEMPLATE, template_values)
    def __init__(self, width=64, height=64):
        self.width = width
        self.height = height
        self.frame = 0
        self.starttime = time.time()

        self.im = Image.new("RGBA", (width,height), "black")
        self.im_draw = ImageDraw.Draw(self.im)

        self.bg = Image.open("images/bg_normal_big.png")
        self.bgofs = 0

        self.font = ImageFont.truetype("fonts/spincycle.ttf", 18)
        self.font_sm = ImageFont.truetype("fonts/pf_tempesta_seven.ttf", 8)

        self.clouds = Cloud.create(20)
        self.weather = Weather()
        self.rain = Rain()
        self.conditions = ""
    def __init__(self, use_sparse):
        self.config = ConfigParser.RawConfigParser()
        self.config.read(util.FEATURES_FILE)
        self.vectorizer = DictVectorizer(sparse=use_sparse)

        if self.config.getboolean(FEATURE_SELECTION, 'Cluster'):
            # Vectorizer without cluster features.
            self.precluster_vectorizer = DictVectorizer(sparse=use_sparse)
            self.clusterer = MiniBatchKMeans(n_clusters=15, init='k-means++')
        if self.config.getboolean(FEATURE_SELECTION, 'DailyWeather') or \
                self.config.getboolean(FEATURE_SELECTION, 'HourlyWeather') or \
                self.config.getboolean(FEATURE_SELECTION, 'Zone_DayOfWeek_HourlyWeather'):
            self.weather_data = Weather()

        if util.VERBOSE:
            feature_list = self.getFeatureList()
            print 'Feature Template List:'
            for feature in feature_list:
                print '\t%s' % feature
Esempio n. 24
0
 def __init__(self):
     self.weather = Weather()
     self.weather.setLocalNOAAWeather('724050-13743-2011')
     self.weather.getData()
Esempio n. 25
0
    label3.configure(text=now)
    window.after(1000, update_clock)

def update_weather():
	weather = Weather(Unit.FAHRENHEIT)
	lookup = weather.lookup_by_latlng(38.5449,-121.7405)
	condition = lookup.condition
	condtxt = condition.text
	windtxt = lookup.wind.speed	
	temptxt = lookup.condition.temp
	label4.configure(text="Current Conditions:  "+condtxt, font = "Times 15 bold")
	label5.configure(text="Temperature:  "+temptxt+ " F", font = "Times 15 bold")
	label6.configure(text="Windspeed:  "+windtxt + "  mph", font = "Times 15 bold")


weather = Weather(Unit.FAHRENHEIT)
lookup = weather.lookup_by_latlng(38.5449,-121.7405)
condition = lookup.condition
condtxt = condition.text
windtxt = lookup.wind.speed
temptxt = lookup.condition.temp

data  = np.array([])
now = datetime.datetime.now()
x = now.strftime("%Y-%m-%d %H:%M:%S")
# adding background image

background_image= PhotoImage(file = '/home/aakash/Pictures/death_star.png')
background_label = Label(window, image= background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
Esempio n. 26
0
 def __init__(self):
     self.weather = Weather()
     self.info = Sysinfo()
Esempio n. 27
0
from botclass import Bot
from weather import Weather
import time
from settings import APPID, TOKEN, WEATHER_SERVER

bot = Bot(TOKEN)
weather = Weather(APPID=APPID, WEATHER_SERVER=WEATHER_SERVER)

while True:
    time.sleep(3)
    message = bot.get_message()
    message = bot.test_message(message)

    if message == None:
        continue

    bot.confirm_message(message)
    print(message.json())
    message = bot.work_with_message(message)
    print(message['text'])
    print(message)
    answer = weather.get_weather(location=message['text'])
    if answer == None:
        bot.post_message_false(telegram_message=message)
        continue
    print(answer)

    bot.post_massage(telegram_message=message, weather_message=answer)
Esempio n. 28
0
def GetCityTemperature(city):
	weather = Weather(unit=Unit.CELSIUS)
	location = weather.lookup_by_location(city)
	forecasts = location.forecast

	return forecasts[0].high
Esempio n. 29
0
import random  # for random answer forms
from weather import Weather

CONFIGURATION_ENCODING_FORMAT = "utf-8"
CONFIG_INI = "config.ini"

class SnipsConfigParser(ConfigParser.SafeConfigParser):
    def to_dict(self):
        return {section : {option_name : option for option_name, option in self.items(section)} for section in self.sections()}


def read_configuration_file(configuration_file):
    try:
        with io.open(configuration_file, encoding=CONFIGURATION_ENCODING_FORMAT) as f:
            conf_parser = SnipsConfigParser()
            conf_parser.readfp(f)
            return conf_parser.to_dict()
    except (IOError, ConfigParser.Error) as e:
        return dict()

def subscribe_intent_callback(hermes, intentMessage):
    conf = read_configuration_file(CONFIG_INI)
    hermes.publish_end_session(intentMessage.session_id, weather.forecast_temperature(intentMessage))


if __name__ == "__main__":
    conf = read_configuration_file(CONFIG_INI)
    weather = Weather(conf)
    with Hermes("localhost:1883") as h:
        h.subscribe_intent("domi:searchWeatherForecastTemperature", subscribe_intent_callback).start()
Esempio n. 30
0
def assistant(command):
    print("Test")
    "if statements for executing commands"

    if 'open reddit' in command:
        reg_ex = re.search('open reddit (.*)', command)
        url = 'https://www.reddit.com/'
        if reg_ex:
            subreddit = reg_ex.group(1)
            url = url + 'r/' + subreddit
        webbrowser.open(url)
        print('Done!')

    elif 'open website' in command:
        reg_ex = re.search('open website (.+)', command)
        if reg_ex:
            domain = reg_ex.group(1)
            url = 'https://www.' + domain
            webbrowser.open(url)
            print('Done!')
        else:
            pass

    elif 'what\'s up' in command:
        talkToMe('Just doing my thing')
    elif 'joke' in command:
        res = requests.get(
                'https://icanhazdadjoke.com/',
                headers={"Accept":"application/json"}
                )
        if res.status_code == requests.codes.ok:
            talkToMe(str(res.json()['joke']))
        else:
            talkToMe('oops!I ran out of jokes')

    elif 'current weather in' in command:
        reg_ex = re.search('current weather in (.*)', command)
        if reg_ex:
            city = reg_ex.group(1)
            weather = Weather()
            location = weather.lookup_by_location(city)
            condition = location.condition()
            talkToMe('The Current weather in %s is %s The tempeture is %.1f degree' % (city, condition.text(), (int(condition.temp())-32)/1.8))

    elif 'weather forecast in' in command:
        reg_ex = re.search('weather forecast in (.*)', command)
        if reg_ex:
            city = reg_ex.group(1)
            weather = Weather()
            location = weather.lookup_by_location(city)
            forecasts = location.forecast()
            for i in range(0,3):
                talkToMe('On %s will it %s. The maximum temperture will be %.1f degree.'
                         'The lowest temperature will be %.1f degrees.' % (forecasts[i].date(), forecasts[i].text(), (int(forecasts[i].high())-32)/1.8, (int(forecasts[i].low())-32)/1.8))


    elif 'email' in command:
        talkToMe('Who is the recipient?')
        recipient = myCommand()

        if 'pranav' in recipient:
            talkToMe('What should I say?')
            content = myCommand()

            #init gmail SMTP
            mail = smtplib.SMTP('smtp.gmail.com', 587)

            #identify to server
            mail.ehlo()

            #encrypt session
            mail.starttls()

            #login
            mail.login('*****@*****.**', '98665076612PD')

            #send message
            mail.sendmail('Pranav', '*****@*****.**', content)

            #end mail connection
            mail.close()

            talkToMe('Email sent.')

        else:
            talkToMe('I don\'t know what you mean!')
Esempio n. 31
0
pp = PrettyPrinter(indent=4)

#Get today's date
today = date.today()

#make textual day, month, year
date_today = today.strftime('%B %d, %Y')

my_loader = jinja2.ChoiceLoader([
    app.jinja_loader,
    jinja2.FileSystemLoader('data'),
])
app.jinja_loader = my_loader


weather_app = Weather()

################################################################################
## ROUTES
################################################################################

@app.route('/')
def home():
    """Displays the homepage with forms for current or historical data."""
    context = {
        'min_date': (datetime.now() - timedelta(days=5)),
        'max_date': datetime.now()
    }
    return render_template('home.html', **context)

Esempio n. 32
0
from weather import Weather
from excel import Excel
from notepad import Notepad

cities = ['Moscow', 'Berlin', 'London', 'Saint Petersburg', 'Dresden']

weather = Weather()

cities_weather = []
for city in cities:
    celsius = weather.get_weather(city)

    cities_weather.append({
        'city': city,
        'celsius': celsius,
        'fahrenheit': round((celsius*9/5)+32)})

weather.close_window()

excel = Excel()
excel.write(cities_weather)
excel.save_file()

notepad = Notepad()
notepad.barmaglot()
Esempio n. 33
0
 def __init__(self, city, *args, **kwargs):
     self.weather = Weather(unit=Unit.CELSIUS)
     self.location = self.weather.lookup_by_location(city)
     super(YahooWeather, self).__init__(*args, **kwargs)
Esempio n. 34
0
 def __init__(self):
     self.weather = Weather(unit=Unit.FAHRENHEIT)
Esempio n. 35
0
from weather import Weather

WEEK_DAYS = 7


def testprint():
    print('Hello, %s!' % t.get())


if __name__ == '__main__':

    # GUIの初期化
    root = Tk()

    # 天気予報クラスの初期化
    weather = Weather("Tokyo,JP", "config.ini")
    print(weather.get_forecast())

    # グローバル変数の文字列変数の宣言
    t = StringVar()

    # タイトルの設定
    root.title('DeskAI')
    frame1 = ttk.Frame(root)
    frame1.grid()

    # フレームにラベルを追加
    today = date.get_today()
    today_str = date.date_format(today)

    # 今日から一週間分のラベルを作成
Esempio n. 36
0
    def on_chat_message(self, msg):
        global state, stall, stall1, can
        content_type, chat_type, chat_id = telepot.glance(msg)
        if content_type == 'text':

            # get message payload
            msg_text = msg['text']

            if (msg_text.startswith('/')):

                # parse the command excluding the '/'
                command = msg_text[1:].lower()

                # prepare the correct response based on the given command
                if (command == 'start'):
                    #display current weather at start of bot
                    weather = Weather()

                    # Lookup WOEID via http://weather.yahoo.com.
                    client = yweather.Client()
                    Singapore_NTU = client.fetch_woeid(
                        'Nanyang Technological University')
                    lookup = weather.lookup(Singapore_NTU)
                    condition = lookup.condition()
                    response = "Current Weather in NTU: " + condition[
                        'text'] + '\n\nRating Stalls or Finding Food? \nTo Rate a Stall, enter /rate\nTo Find Food, enter /find \n\nTo view all commands, enter /list'
                    bot.sendMessage(chat_id, response)

                elif (command == 'list'):
                    #dispaly list of avaiable commands
                    response = 'Here are a list of all available commands: \n/start Begin your food journey! \n/rate Rate your dining experience at stall! \n/find Find delicious food by location or cuisine! \n/feedback Send any feedback, queries or errors spotted to us! \n/quit Exit what you are doing'
                    bot.sendMessage(chat_id, response)
                elif (command == 'feedback'):
                    #set state to 4 to receive feedback from user
                    self.state = 4
                    bot.sendMessage(chat_id,
                                    'Please enter feedback your feedback!')
                elif (command == 'rate'):
                    #set state to 1 to proceed to next stage of rating process
                    self.state = 1
                    canlist = [
                        'Canteen 1', 'Canteen 2', 'Canteen 4', 'Canteen 9',
                        'Canteen 11', 'Canteen 13', 'Canteen 14', 'Canteen 16',
                        'Koufu', 'NIE Canteen', 'North Hill Canteen',
                        'North Spine Foodcourt', 'Pioneer Canteen'
                    ]
                    rm = ReplyKeyboardMarkup(
                        one_time_keyboard=True,
                        keyboard=[[KeyboardButton(text=i)] for i in canlist])
                    bot.sendMessage(chat_id, 'Choose Canteen', reply_markup=rm)

                elif (command == 'find'):
                    response = 'Filter by Canteen or Cuisine?'
                    confirm_keyboard = InlineKeyboardMarkup(inline_keyboard=[
                        [
                            InlineKeyboardButton(text='Canteen',
                                                 callback_data='can')
                        ],
                        [
                            InlineKeyboardButton(text='Cuisine',
                                                 callback_data='cui')
                        ],
                    ])
                    bot.sendMessage(chat_id,
                                    response,
                                    reply_markup=confirm_keyboard)
                elif (command == 'quit'):
                    #used to exit and reset to initial state
                    self.state = 0
            elif (self.state == 0):
                #initial state. Prompt if no valid command is entered
                bot.sendMessage(
                    chat_id,
                    "Hi, please enter /start to begin! \n\nFor feedback, please enter \n/feedback \n\nTo exit at anytime, enter /quit"
                )
            elif (self.state == 1):
                self.check = 0
                conn_string = "host='ec2-54-225-237-64.compute-1.amazonaws.com' dbname='d7dkk1sep0usei' user='******' password='******'"
                conn = psycopg2.connect(conn_string)
                cursor = conn.cursor()
                cursor.execute("SELECT * FROM store")
                rlist = cursor.fetchall()

                #check if user input for canteen is valid (matches with that in master list from database table "store")
                for i in range(len(rlist)):
                    if (msg_text == rlist[i][0]):
                        self.check = 1
                #if input valid, we set state to the next state, and prompt user for input of stall
                if (self.check):
                    can = msg_text
                    otpt = "List of stalls in " + msg_text + "\n"
                    self.stall = []
                    #find list of stalls in selected canteen
                    for i in range(0, len(rlist)):
                        if (rlist[i][0] == msg_text):
                            otpt = otpt + rlist[i][2] + "\n"
                            self.stall.append(rlist[i][2])
                    RM = ReplyKeyboardMarkup(
                        one_time_keyboard=True,
                        keyboard=[[KeyboardButton(text=stall)]
                                  for stall in self.stall])

                    bot.sendMessage(chat_id, otpt, reply_markup=RM)
                    self.state = 2
                #if input invalid, stay at current state and prompt user for input of canteen again
                else:
                    canlist = [
                        'Canteen 1', 'Canteen 2', 'Canteen 4', 'Canteen 9',
                        'Canteen 11', 'Canteen 13', 'Canteen 14', 'Canteen 16',
                        'Koufu', 'NIE Canteen', 'North Hill Canteen',
                        'North Spine Foodcourt', 'Pioneer Canteen'
                    ]
                    rm = ReplyKeyboardMarkup(
                        one_time_keyboard=True,
                        keyboard=[[KeyboardButton(text=i)] for i in canlist])
                    bot.sendMessage(chat_id, 'Choose Canteen', reply_markup=rm)
                    self.state = 1

            elif (self.state == 2):
                self.check = 0
                #check if user input of stall is valid
                for i in range(len(self.stall)):
                    if (msg_text == self.stall[i]):
                        self.check = 1
                #for valid input, ask user to input ratings and move to next state, state 3
                if (self.check == 1):
                    self.stall1 = msg_text
                    self.state = 3
                    RM = ReplyKeyboardMarkup(
                        one_time_keyboard=True,
                        keyboard=[[KeyboardButton(text=rating)]
                                  for rating in ['5', '4', '3', '2', '1']])
                    bot.sendMessage(chat_id, "Input Ratings", reply_markup=RM)
                #for invalid stall input, prompt user for input of stall, while remaining at current state
                else:
                    bot.sendMessage(chat_id,
                                    "Input Stall: ",
                                    reply_markup=ReplyKeyboardMarkup(
                                        one_time_keyboard=True,
                                        keyboard=[[KeyboardButton(text=stall)]
                                                  for stall in self.stall]))

            elif (self.state == 3):
                #for valid rating input, attempt to save review using rate.py. check for multiple rating by single user is made in rate.py
                if ((msg_text == '1') | (msg_text == '2') | (msg_text == '3') |
                    (msg_text == '4') | (msg_text == '5')):
                    self.state = 0
                    bot.sendMessage(
                        chat_id, rate(can, self.stall1, msg_text,
                                      str(chat_id)))
                #for invalid rating input, prompt user for rating input and remain at current state
                else:
                    self.state = 3
                    bot.sendMessage(
                        chat_id,
                        "Input Ratings",
                        reply_markup=ReplyKeyboardMarkup(
                            one_time_keyboard=True,
                            keyboard=[[KeyboardButton(text=rating)]
                                      for rating in ['5', '4', '3', '2', '1']
                                      ]))
            elif (self.state == 4):
                #send feedback and userid to the admin and return to initial state
                response = str(msg_text) + '\nUserID : ' + str(chat_id)
                bot.sendMessage(408469886, response)
                bot.sendMessage(chat_id,
                                'Thank you, your feedback was recorded!')
                self.state = 0
Esempio n. 37
0
 def _weather(self):
     return Weather(self._settings.get_setting('open_weather_map_key'), self._settings.get_setting('location'), float(self._settings.get_setting('latitude')), float(self._settings.get_setting('longitude')))
Esempio n. 38
0
sa = ServiceAccount()
sa.email(config.get('google_service_account_email'))
sa.scope('https://www.googleapis.com/auth/spreadsheets')
sa.private_rsa_key(config.private_rsa_key())

# create an instance of Spreadsheet which is used to write data to a sheet
spreadsheet = Spreadsheet()
spreadsheet.set_service_account(sa)
spreadsheet.set_id(config.get('google_sheet_id'))
spreadsheet.set_range('A:A')

# create a handler which takes temperature and humidity and write them to a sheet
weather_handler = WeatherHandler(spreadsheet)

# initialize the DHT22 sensor which measures temperature and humidity
weather = Weather(config.get('dht22_pin'), config.get('measurement_interval'),
                  weather_handler)

# initilize a switch which turns on the configuration mode
# if the switch changes its state, then the board is going to reboot immediately
config_mode_switch = Pin(config.get('config_mode_switch_pin'), Pin.IN)
config_mode_switch.irq(lambda pin: util.reboot())

# first, check if the configuration mode is enabled
# if so, set up an access point, and then start an HTTP server
# the server provides a web form which updates the configuraion of the device
# the server runs on http://192.168.4.1:80
if config_mode_switch.value() == 1:
    from http.server import HttpServer
    from settings import ConnectionHandler
    print('enabled configuration mode')
    access_point = util.start_access_point(ACCESS_POINT_SSID,
Esempio n. 39
0
def weather_current(flocation):
    weather = Weather(unit=Unit.CELSIUS)
    location = weather.lookup_by_location(flocation)
    condition = location.condition
    print("It's " + condition.text + " today")
    print("With temp " + condition.temp + "𐤏C")
Esempio n. 40
0
 def test_search(self):
     w = Weather()
     data = w.lookup_by_location('Dublin')
     self.assertTrue('Dublin' in data.description())
Esempio n. 41
0
def mycommand(command):
    if "hi friday" in command:
        friday("hello sir")
        friday("what can i do for you?")

    #command for system time
    elif "what is the time now" in command:
        friday(time.asctime())

    elif "how are you" in command:
        friday("I am great")
        friday("I hope you are also doing well sir")

    #command for shutdown
    elif "shutdown" in command:
        friday("shuting down in")
        os.system("shutdown -s")

    elif "what is the weather today" in command:
        weather = Weather(unit=Unit.CELSIUS)
        location = weather.lookup_by_location('chennai')
        condition = location.condition
        friday(condition.text)
        friday(weather.text)

    #command for forecast
    elif "what will be the weather in coming days" in command:
        engine = ts.init()
        weather = Weather(unit=Unit.CELSIUS)
        engine.say("weather about upcoming days")
        location = weather.lookup_by_location('chennai')
        forecasts = location.forecast
        for forecast in forecasts:
            engine.say("it seems to be" + forecast.text)
            engine.say("on" + forecast.date)
            engine.say("high will be" + forecast.high + "degree celsius")
            engine.say("low will be" + forecast.low + "degree celsius")
            engine.runAndWait()

    #command for room temeprature
    #I used arduino for getting my room temperature from dht-11 sensor

    elif "what is my room temperature" in command:
        income = str(ardserial.readline()[0:-2])
        friday(income + "degree celsius")

    elif "friday you up" in command:
        friday("yes sir!")

    #command for restart
    elif "restart" in command:
        friday("Sure!")
        os.startfile("shutdown -r")

    #command for opening google
    elif "go to google" in command:
        os.startfile("https://www.google.co.in/")

    #command for opening email
    elif "send an email" in command:
        friday("Who is the recipient?")
        recipient = recognizeaudio()

        #type your recipient name in quotes to whom you want to send
        if "spider" in recipient:

            friday('What should I say?')
            content = recognizeaudio()

            #init gmail SMTP
            mail = smtplib.SMTP('smtp.gmail.com', 587)

            #identify to server
            mail.ehlo()

            #encrypt session
            mail.starttls()

            #Give your username and password to login
            mail.login("xxxx", "xxxx")

            #your recipient username and mail id
            mail.sendmail("xxx", "xxx", content)

            #end mail connection
            mail.close()

            friday("Email sent.")

    else:
        friday("I don't know what do you mean sir!")
        friday("try speaking correctly")
Esempio n. 42
0
import serial
import time
import string
import datetime
from DriveStatusLog import DriveStatusLog
from weather import Weather, Unit

ser = serial.Serial('/dev/ttyACM3', 9600)
msg = "a".encode('utf-8')
weather = Weather(unit=Unit.FAHRENHEIT)
logs = DriveStatusLog()
readCount = 0


while True:
    currentWeather = weather.lookup_by_location("detroit").condition.text
    sensorRead = ser.readline()

    if readCount == 0:
        logs.timeStamp = str(datetime.datetime.now())
        print("Timestamp: \t", logs.timeStamp)

        logs.currentWeather = currentWeather
        print("Weather: \t " + logs.currentWeather)
            
        water = sensorRead.decode('utf-8')
        logs.water = water[:len(water)-2]
        readCount += 1

        print("Water: \t\t", logs.water)
            
Esempio n. 43
0
def weather_loc(loc):
    weather = Weather(unit=Unit.FAHRENHEIT)
    location = weather.lookup_by_location(loc)
    forecasts = location.forecast
    return "Weather: <br>"+ "&emsp; High: " + forecasts[0].high +"\n" + "Low: " + forecasts[0].low
Esempio n. 44
0
# -*- coding: utf-8 -*-
import tweepy
from secret import *
from weather import Weather # 추가

class TwitterAPI:

    def __init__(self):
        auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
        auth.set_access_token(access_token, access_token_secret)
        self.api = tweepy.API(auth)

    def tweet(self, message):
        self.api.update_status(status=message)

if __name__ == "__main__":
    twitter = TwitterAPI()
    weather = Weather() # 추가
    twitter.tweet(weather.get_text()) # 수정
Esempio n. 45
0
 def test_lookup(self):
     w = Weather()
     data = w.lookup(woeid=560743)
     self.assertTrue('Dublin' in data.description())
Esempio n. 46
0
class MyImage():
    def __init__(self):
        self.weather = Weather()
        self.info = Sysinfo()

    def get(self, rotate: int = 180):
        image = Image.new("RGB", SIZE, "#74a8ce")
        draw = ImageDraw.Draw(image)

        sysinfo = self.info.get()

        draw.rectangle([(10, 140), (309, 229)], fill="#000000")
        draw.text((15, 145),
                  f"> ip: {sysinfo['ip']}",
                  fill="#00FF00",
                  font=mono)
        draw.text((15, 165),
                  f"> mem_total: {sysinfo['memory']['total']} MB",
                  fill="#00FF00",
                  font=mono)
        draw.text((15, 185),
                  f"> mem_avail: {sysinfo['memory']['avail']} MB",
                  fill="#00FF00",
                  font=mono)
        draw.text((15, 205),
                  f"> cpu_temp: {sysinfo['temp']}",
                  fill="#00FF00",
                  font=mono)

        name, weather = self.weather.get()
        if not weather:
            return image.rotate(rotate)

        now = weather["now"]
        forecast = weather["forecast"]

        with Image.open(f"/home/pi/workspace/LCD/icon/{now['icon']}.png") as f:
            f = f.resize((96, 96))
            draw.bitmap((1, 0), f, fill="#FFFFFF")
        draw.text((100, 5), name, fill="#FFFFFF", font=sans_normal)
        draw.text((120, 25),
                  f"{now['temp']}/{now['feelsLike']}°",
                  fill="#FFFFFF",
                  font=sans_big)
        draw.text((160, 5),
                  f"{now['text']} Hum:{now['humidity']}%",
                  font=sans_normal,
                  fill="#FFFFFF")

        for i, info in enumerate(forecast):
            icon, tmin, tmax = info
            with Image.open(f"/home/pi/workspace/LCD/icon/{icon}.png") as f:
                f = f.resize((40, 40))
                draw.bitmap((20 + i * 100, 90), f, fill="#FFFFFF")
                draw.text((60 + i * 100, 110),
                          f"{tmin}~{tmax}",
                          fill="#FFFFFF",
                          font=sans_normal)

        return image.rotate(rotate)

    def update(self):
        self.weather.update()
        self.info.update()
Esempio n. 47
0
import telebot
from telebot.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
# import os
import time
from weather import Weather, Unit

weather = Weather(unit=Unit.CELSIUS)
forecasts_moscow = weather.lookup_by_location('moscow').forecast
forecasts_swamp = weather.lookup_by_location('petersburg').forecast
# Здесь с помощью weather-api предзагружаем прогноз погоды,
# т.к. библиотека не работает через прокси
'''
os.startfile(os.path.dirname(__file__) + "/Ultrasurf.exe")
# После чего запускаем прокси. fck da Роскомнадзор
time.sleep(15)  # Время, чтобы соединение стабилизировалось.
#  За 10 секунд оно не всегда успевает
'''
city = activity = None
token = '776536658:AAHuHAi28nhFCKyGgASAHWd-063hyItVEmQ'
bot = telebot.TeleBot(token)


def activity_ask(message: Message):  # Выбор типа активности, флекс или же чилл
    keyboard = InlineKeyboardMarkup()
    button_flex = InlineKeyboardButton(text='🤩',
                                       callback_data='set_activity_flex')
    button_chill = InlineKeyboardButton(text='🤤',
                                        callback_data='set_activity_chill')
    keyboard.add(button_flex, button_chill)
    bot.send_message(message.chat.id,
                     text='Флексить или чиллить?'
def assistant(command):
    "if statements for executing commands"
    if 'open reddit' in command:
        reg_ex = re.search('open reddit (.*)', command)
        url = 'https://www.reddit.com/'
        if reg_ex:
            subreddit = reg_ex.group(1)
            url = url + 'r/' + subreddit
        webbrowser.open(url)
        print('Done!')
    elif "time" in command:
        talkToMe("The current time is " + getTime())

    #Opens websites in default browser
    elif 'open website' in command:
        reg_ex = re.search('open website (.+)', command)
        possibleDomains = [".com", ".org", ".gov"]
        if reg_ex:
            domain = reg_ex.group(1)

            url = domain

            if url not in possibleDomains:
                url = findUrl(domain, possibleDomains)

            else:
                url = "https://www." + domain

            webbrowser.open(url)
            print('Done!')
        else:
            pass

    elif 'what\'s up' in command:
        talkToMe('Just doing my thing')

    elif "run" in command:
        command = re.sub("run", "", command)
        command = re.sub(assistantName, "", command)
        command = re.sub("jarvis", "", command)
        command = re.sub("dash", "-", command)
        command = re.sub(" ", "", command)
        print("Running " + command + " for you!")
        process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
        output, error = process.communicate()
        #os.system("clear")

    elif 'joke' in command:
        res = requests.get('https://icanhazdadjoke.com/',
                           headers={"Accept": "application/json"})
        if res.status_code == requests.codes.ok:
            talkToMe(str(res.json()['joke']))
        else:
            talkToMe('oops!I ran out of jokes')

    elif 'current weather in' in command:
        reg_ex = re.search('current weather in (.*)', command)
        if reg_ex:
            city = reg_ex.group(1)
            weather = Weather()
            location = weather.lookup_by_location(city)
            condition = location.condition()
            talkToMe(
                'The Current weather in %s is %s The tempeture is %.1f degree'
                % (city, condition.text(), (int(condition.temp()) - 32) / 1.8))

    elif 'weather forecast in' in command:
        reg_ex = re.search('weather forecast in (.*)', command)
        if reg_ex:
            city = reg_ex.group(1)
            weather = Weather()
            location = weather.lookup_by_location(city)
            forecasts = location.forecast()
            for i in range(0, 3):
                talkToMe(
                    'On %s will it %s. The maximum temperture will be %.1f degree.'
                    'The lowest temperature will be %.1f degrees.' %
                    (forecasts[i].date(), forecasts[i].text(),
                     (int(forecasts[i].high()) - 32) / 1.8,
                     (int(forecasts[i].low()) - 32) / 1.8))
    elif "bye" in command:
        talkToMe("Goodbye user")
        time.sleep(1)
        #os.system("clear")
        sys.exit()
    elif "upgrade packages" in command:
        talkToMe('Upgrading packages, this may require your password')
        upgradeCommand = "pamac upgrade"
        process = subprocess.Popen(upgradeCommand.split(),
                                   stdout=subprocess.PIPE)
        output, error = process.communicate()

    else:
        talkToMe('I don\'t know what you mean!')
Esempio n. 49
0
    def weather(self, location, num_of_days=2, date='today'):
        """
        Try to get forecast for given location.
        Location pass one of the following:

            City and Town name

            Acceptable formats are:
                City Name
                City Name, State (US only)
                City Name, State, Country
                City Name, Country
            e.g.: q=New+York or q=New+york,ny or q=London,united+kingdom

            IP address
            e.g.: q=101.25.32.325

            UK or Canada Postal Code or US Zipcode
            e.g.: q=SW1 or q=90201

            Latitude,Longitude (in decimal degree)
            e.g.: q=48.834,2.394

        Return current condition as :class:`Weather` and forecast as list of :class:`Weather`
        """
        path = 'weather'

        if isinstance(location, City):
            location = '{0},{1},{2}'.format(location.areaName, location.region, location.country)

        response = self.__request(path, {
            'q':location,
            'num_of_days':num_of_days,
            'format':self.format,
            'date':date,
            })

        tree = ET.fromstring(response)

        if tree.find('error'):
            raise Exception(tree.find('error').find('msg').text)

        condition = Condition()
        for node in tree.find('current_condition').getchildren():
            if node.tag == 'observation_time':
                utcnow = datetime.utcnow()
                source = '{0}-{1}-{2} '.format(
                    utcnow.year,
                    utcnow.month,
                    utcnow.day
                ) + node.text
                date = datetime.strptime(source,'%Y-%m-%d %I:%M %p')
                condition.__setattr__(node.tag, date)
                continue
            condition.__setattr__(node.tag, node.text)

        forecast = list()
        for node in tree.findall('weather'):
            weather = Weather()
            for child in node.getchildren():
                if child.tag == 'date':
                    date = datetime.strptime(child.text,'%Y-%m-%d')
                    weather.__setattr__(child.tag, date)
                    continue
                weather.__setattr__(child.tag, child.text)
            forecast.append(weather)

        return condition, forecast
Esempio n. 50
0
 def setUp(self):
     self.weather = Weather()
Esempio n. 51
0
class Features:

    # initialise features
    def __init__(self, config_provider):

        text_to_speech = None
        if (config_provider.acting or config_provider.browser or
            config_provider.calculator or config_provider.hand_gesture or
            config_provider.happy_colour or config_provider.mixing_desk or
            config_provider.optical_character_recognition or config_provider.play_your_cards_right or
            config_provider.slideshow or config_provider.weather):
            from texttospeech import TextToSpeech
            text_to_speech = TextToSpeech()

        speech_to_text = None
        if (config_provider.acting or config_provider.browser or
            config_provider.calculator or config_provider.mixing_desk or
            config_provider.phrase_translation or config_provider.play_your_cards_right or
            config_provider.weather):
            from speechtotext import SpeechToText
            speech_to_text = SpeechToText()

        self.acting = None
        if config_provider.acting:
            from acting import Acting
            self.acting = Acting(text_to_speech, speech_to_text)

        self.browser = None
        if config_provider.browser:
            from browser import Browser
            self.browser = Browser(text_to_speech, speech_to_text)

        self.calculator = None
        if config_provider.calculator:
            from calculator import Calculator
            self.calculator = Calculator(text_to_speech, speech_to_text)

        self.hand_gesture = None
        if config_provider.hand_gesture:
            from handgesture import HandGesture
            self.hand_gesture = HandGesture(text_to_speech)

        self.happy_colour = None
        if config_provider.happy_colour:
            from happycolour import HappyColour
            self.happy_colour = HappyColour(text_to_speech)

        self.mixing_desk = None
        if config_provider.mixing_desk:
            from mixingdesk import MixingDesk
            self.mixing_desk = MixingDesk(text_to_speech, speech_to_text)

        self.optical_character_recognition = None
        if config_provider.optical_character_recognition:
            from opticalcharacterrecognition import OpticalCharacterRecognition
            self.optical_character_recognition = OpticalCharacterRecognition(text_to_speech)

        self.phrase_translation = None
        if config_provider.phrase_translation:
            from phrasetranslation import PhraseTranslation
            self.phrase_translation = PhraseTranslation(speech_to_text)

        self.play_your_cards_right = None
        if config_provider.play_your_cards_right:
            from playyourcardsright import PlayYourCardsRight
            self.play_your_cards_right = PlayYourCardsRight(text_to_speech, speech_to_text)

        self.slideshow = None
        if config_provider.slideshow:
            from slideshow import Slideshow
            self.slideshow = Slideshow(text_to_speech)

        self.television = None
        if config_provider.television:
            from television import Television
            self.television = Television()

        self.weather = None
        if config_provider.weather:
            from weather import Weather
            self.weather = Weather(text_to_speech, speech_to_text)

    # indicate whether a feature is speaking
    def is_speaking(self):
        return ((self.acting and self.acting.is_speaking) or
                (self.browser and self.browser.is_speaking) or
                (self.calculator and self.calculator.is_speaking) or           
                (self.hand_gesture and self.hand_gesture.is_speaking) or
                (self.happy_colour and self.happy_colour.is_speaking) or                
                (self.mixing_desk and self.mixing_desk.is_speaking) or
                (self.optical_character_recognition and self.optical_character_recognition.is_speaking) or
                (self.phrase_translation and self.phrase_translation.is_speaking) or
                (self.play_your_cards_right and self.play_your_cards_right.is_speaking) or
                (self.slideshow and self.slideshow.is_speaking) or
                (self.weather and self.weather.is_speaking))

    # provide emotion from a feature
    def get_emotion(self):
        if self.acting: 
            return self.acting.emotion
        elif self.hand_gesture: 
            return self.hand_gesture.emotion
        elif self.happy_colour: 
            return self.happy_colour.emotion
        else:
            return None

    # update background image from a feature
    def update_background_image(self, image):
        if self.slideshow and self.slideshow.background_image.size > 0: 
            return self.slideshow.background_image  
        elif self.television and self.television.background_image.size > 0: 
            return self.television.background_image
        else:
            return image

    # handle features
    def handle(self, rocky_robot, sporty_robot, image):
        self._handle_acting(rocky_robot, sporty_robot)
        self._handle_browser(rocky_robot, sporty_robot)
        self._handle_calculator(rocky_robot, sporty_robot)
        self._handle_hand_gesture(rocky_robot, sporty_robot, image)
        self._handle_happy_colour(rocky_robot, image)
        self._handle_mixing_desk(rocky_robot)
        self._handle_optical_character_recognition(rocky_robot, sporty_robot, image)
        self._handle_phrase_translation(sporty_robot)
        self._handle_play_your_cards_right(sporty_robot)
        self._handle_slideshow(rocky_robot, sporty_robot, image)
        self._handle_television(rocky_robot, sporty_robot, image)
        self._handle_weather(rocky_robot, sporty_robot)

    # handle acting
    def _handle_acting(self, rocky_robot, sporty_robot):
        if not self.acting: return
 
        if rocky_robot.is_facing or sporty_robot.is_facing:
            self.acting.start()
        else:
            self.acting.stop()

    # handle browser
    def _handle_browser(self, rocky_robot, sporty_robot):
        if not self.browser: return

        if rocky_robot.is_facing:
            self.browser.start(ROCK)
        elif sporty_robot.is_facing:
            self.browser.start(SPORT)
        else:
            self.browser.stop()

    # handle calculator
    def _handle_calculator(self, rocky_robot, sporty_robot):
        if not self.calculator: return
 
        if rocky_robot.is_facing or sporty_robot.is_facing:
            self.calculator.start()
        else:
            self.calculator.stop()

    # handle hand gesture
    def _handle_hand_gesture(self, rocky_robot, sporty_robot, image):
        if not self.hand_gesture: return

        if rocky_robot.is_facing or sporty_robot.is_facing:
            self.hand_gesture.start(image)
        else:
            self.hand_gesture.stop()

    # handle happy colour
    def _handle_happy_colour(self, rocky_robot, image):
        if not self.happy_colour: return

        if rocky_robot.is_facing:
            self.happy_colour.start(image)
        else:
            self.happy_colour.stop()

    # handle mixing desk
    def _handle_mixing_desk(self, rocky_robot):
        if not self.mixing_desk: return
 
        if rocky_robot.is_facing:
            self.mixing_desk.start()
        else:
            self.mixing_desk.stop()

    # handle optical character recognition
    def _handle_optical_character_recognition(self, rocky_robot, sporty_robot, image):
        if not self.optical_character_recognition: return

        if rocky_robot.is_facing or sporty_robot.is_facing:
            self.optical_character_recognition.start(image)
        else:
            self.optical_character_recognition.stop()

    # handle phrase translation
    def _handle_phrase_translation(self, sporty_robot):
        if not self.phrase_translation: return

        if sporty_robot.is_facing:
            self.phrase_translation.start()
        else:
            self.phrase_translation.stop()

    # handle play your cards right
    def _handle_play_your_cards_right(self, sporty_robot):
        if not self.play_your_cards_right: return

        if sporty_robot.is_facing:
            self.play_your_cards_right.start()
        else:
            self.play_your_cards_right.stop()

    # handle slideshow
    def _handle_slideshow(self, rocky_robot, sporty_robot, image):
        if not self.slideshow: return

        if rocky_robot.is_facing or sporty_robot.is_facing:
            self.slideshow.start(image)
        else:
            self.slideshow.stop()

    # handle television
    def _handle_television(self, rocky_robot, sporty_robot, image):
        if not self.television: return

        if rocky_robot.is_rendered or sporty_robot.is_rendered:
            self.television.start(image)
        else:
            self.television.stop()

    # handle weather
    def _handle_weather(self, rocky_robot, sporty_robot):
        if not self.weather: return

        if rocky_robot.is_facing or sporty_robot.is_facing:
            self.weather.start()
        else:
            self.weather.stop()
Esempio n. 52
0
#!/usr/bin/env python
 
from weatherInfo import WeatherInfo
from weather import Weather
 
wi = WeatherInfo()
wi.parse()
 
weather = Weather()
weather.extractData(wi,"SI")
weather.show()
Esempio n. 53
0
from weather import Weather, Unit

weather = Weather(unit=Unit.CELSIUS)
location = weather.lookup_by_location('Moormerland')
condition = location.condition
print(condition.text)
print(condition.temp)
Esempio n. 54
0
def main():
    #try:
		#vk_auth
        session = requests.Session()
        level2=[]
        level3=[]
        level4=[]
        ids=[]
        days_mass=[]
        Ids_mass=[]
    
        vk_session = vk_api.VkApi(token='42117b3a93e9f6f9bb1de66446b4856a460db93cf87bff530e62de233503df5c42c13203de0f3a0ec3cc6')#quant
        #vk_session = vk_api.VkApi(token='069d9ce67dc166da0a16c9b233575e280daa970b2884df2dec367532d5798f9c87963d600a69ca66feb60')#buhi 

        vk = vk_session.get_api()

        upload = VkUpload(vk_session)  # Для загрузки изображений
        longpoll = VkLongPoll(vk_session)
        	
        text='Вы хотите забронировать Хайтек цех ?'
        
        keyboard = VkKeyboard(one_time=True)
        keyboard_2 = VkKeyboard(one_time=True) 
		
        text_button11="Привет"
        text_button12="Бронь"
        text_button13="Погода"
        text_button21="В начало"
        text_button22="След. даты"
        text_button23=""
        text_button31="Назад"
        text_button32="Выход"
        hide_key=0 ##для каждого айди
        keyboard.add_button(text_button11, color=VkKeyboardColor.DEFAULT)
        keyboard.add_button(text_button12, color=VkKeyboardColor.DEFAULT)
        keyboard.add_button(text_button13, color=VkKeyboardColor.DEFAULT)
        keyboard.add_line()  # Переход на вторую строку
        keyboard.add_button(text_button21, color=VkKeyboardColor.NEGATIVE)
        kb_m=keyboard
        days_plus=0 
        book_date=datetime.datetime.utcnow().isoformat()
   
          
   
    

        for event in longpoll.listen():
       
        
            if event.type == VkEventType.MESSAGE_NEW and event.to_me and event.text:
                
                #print('написал id{}: "{}"'.format(event.user_id, event.text), end=' ')
                #jhg=vk.users.get(user_id=event.user_id)
                #name_user=jhg[0]['first_name']+'  '+jhg[0]['last_name']
                #print (name_user + " : " + event.text)
                print("HTBot -- message from user --  " + str(event.user_id))
                
                if event.text==text_button21: ##в начало
                   
                   days_plus=0
                   text="Добро пожаловать, воспользуйтесь клавиатурой"
                   kb_m=keyboard
                   if event.user_id in level4:
                       level4.remove(event.user_id)
                       Ids_mass.pop(level4.index(event.user_id))
                   if event.user_id in level3:
                       level3.remove(event.user_id)
                   if event.user_id in level2:
                       days_mass.pop(level2.index(event.user_id))
                       level2.remove(event.user_id)
                       
                       #четвертый уровень################################################## add info
                elif event.user_id in level4:
                    asdasd=vk.users.get(user_id=event.user_id)
                    name_user=asdasd[0]['first_name']+'  '+asdasd[0]['last_name']
                    text=('Вы,  '+name_user + ", успешно забронировали и можете посмотреть на это в календаре https://calendar.google.com/calendar/b/1?cid=aHRib29raW5nZWtiQGdtYWlsLmNvbQ  "  )
                    booking_by_eventId(Ids_mass[level4.index(event.user_id)],name_user,event.text)
                    Ids_mass.pop(level4.index(event.user_id))
                    
                    level4.remove(event.user_id)
                    kb_m=keyboard
                    vk.messages.send(user_id=19132305,random_id=get_random_id(),message=("Ура, забронировали ,   "+name_user))
                    print("successfull booking")
                    #vk.messages.send(user_id=1295019,random_id=get_random_id(),message=("Ура, забронили,  "+name_user))
                #третий уровень####################################################################time choose
                elif event.user_id in level3:

                    if event.text== 'К выбору даты':#### на пред. уровень
                        level3.remove(event.user_id)
                        level2.append(event.user_id)
                        days_mass.append(0)

                        text="Когда хотите посетить ХайТек цех ?"
                        date_1=datetime.datetime.today()
                        d1=(date_1-datetime.timedelta(hours=(datetime.datetime.now().hour)))
                        d2=(d1+datetime.timedelta(days=1))
                        d3=(d1+datetime.timedelta(days=2))
                        d4=(d1+datetime.timedelta(days=3))
  
                        kb_m=get_date_buttons(d1,d2,d3,d4)
                    else:
                        
                        if event.text==time_format(ids[1][0]):
                            Ids_mass.append(ids[0][0]) 
                        elif event.text==time_format(ids[1][1]):
                            Ids_mass.append(ids[0][1]) 
                        elif event.text==time_format(ids[1][2]):
                            Ids_mass.append(ids[0][2]) 
                        elif event.text==time_format(ids[1][3]):
                            Ids_mass.append(ids[0][3]) 
                        elif event.text==time_format(ids[1][4]):
                            Ids_mass.append(ids[0][4]) 
                            
                        
                        level3.remove(event.user_id)
                        level4.append(event.user_id)
                      
                        text="Какое оборудование и материалы будут необходимы?"
                        kb_m=keyboard_2
                      #второй уровень     
                elif event.user_id in level2:
                   
                    ##обрабатываем дату
                    
               ############################################################выбор даты№№№№№№№№№№№№№№№№№№№№№№№№
                    if event.text==d1.strftime("%d-%m-%Y") or event.text==d2.strftime("%d-%m-%Y") or event.text==d3.strftime("%d-%m-%Y") or event.text==d4.strftime("%d-%m-%Y"):
                        #print("trigger 1")
                        if event.text==d1.strftime("%d-%m-%Y"):
                            ids=id_events_call(d1)
                      
                        elif event.text==d2.strftime("%d-%m-%Y"):
                            ids=id_events_call(d2)
                        
                        elif event.text==d3.strftime("%d-%m-%Y"):
                            ids=id_events_call(d3)
                          
                        else:
                            ids=id_events_call(d4)
                    
                                    
                        
                        
                        

                        
                    
                        if ids[1][0]=='zero':
                           
                            text='В этот день Hi-tech цех уже занят, выберете другую дату'

                        
                        elif ids[1][1]=='zero':
                            kb_m=get_time_buttons(time_format(ids[1][0]),'zero','zero','zero','zero')
                            text='Одно свободное окно на выбранную дату'
                            if event.user_id in level2:
                                days_mass.pop(level2.index(event.user_id))
                                level2.remove(event.user_id)
                            if event.user_id not in level3:
                                level3.append(event.user_id)
                                
                        elif ids[1][2]=='zero':
                            kb_m=get_time_buttons(time_format(ids[1][0]),time_format(ids[1][1]),'zero','zero','zero')
                            text='Два свободных окна на выбранную дату, выберете время'
                            if event.user_id in level2:
                                days_mass.pop(level2.index(event.user_id))
                                level2.remove(event.user_id)
                            if event.user_id not in level3:
                                level3.append(event.user_id)
                        elif ids[1][3]=='zero':
                            kb_m=get_time_buttons(time_format(ids[1][0]),time_format(ids[1][1]),time_format(ids[1][2]),'zero','zero')
                            text='Три свободных окна на выбранную дату, выберете время'
                            if event.user_id in level2:
                                days_mass.pop(level2.index(event.user_id))
                                level2.remove(event.user_id)
                            if event.user_id not in level3:
                                level3.append(event.user_id)
                        elif ids[1][4]=='zero':
                            kb_m=get_time_buttons(time_format(ids[1][0]),time_format(ids[1][1]),time_format(ids[1][2]),time_format(ids[1][3]),'zero')
                            text='Четыре свободных окна на выбранную дату, выберете время'
                            if event.user_id in level2:
                                days_mass.pop(level2.index(event.user_id))
                                level2.remove(event.user_id)
                            if event.user_id not in level3:
                                level3.append(event.user_id)
                        elif ids[1][5]=='zero':
                            kb_m=get_time_buttons(time_format(ids[1][0]),time_format(ids[1][1]),time_format(ids[1][2]),time_format(ids[1][3]),time_format(ids[1][4]))
                            text='Пять свободных окон на выбранную дату, выберете время'
                            if event.user_id in level2:
                                days_mass.pop(level2.index(event.user_id))
                                level2.remove(event.user_id)
                            if event.user_id not in level3:
                                level3.append(event.user_id)
                             #kb_m=get_time_buttons(time_format(ids[1][0]),time_format(ids[1][1]),time_format(ids[1][1]),time_format(ids[1][1])) ######Вот здесь надо поработать, создание кнопок времени и тд
                        #else:
                            #kb_m=get_time_buttons(time_format(ids[1][0]),time_format(ids[1][1]),time_format(ids[1][2]),time_format(ids[1][3]))
                           # text='Весь день свободен'
                        #else:
                           # print("else works")
                           # if event.user_id in level2:
                            #    days_mass.pop(level2.index(event.user_id))
                            #    level2.remove(event.user_id)
                           # if event.user_id not in level3:
                            #    level3.append(event.user_id)
                                
                                
                        
                    elif event.text==text_button22: #след неделя
                        
                        days_mass[level2.index(event.user_id)]=days_mass[level2.index(event.user_id)]+4
                        #days_mass.append(0)
                        
                        days_plus=days_mass[level2.index(event.user_id)]
                        date_1=datetime.datetime.today()+datetime.timedelta(days=days_plus)
                        d1=date_1-datetime.timedelta(hours=(datetime.datetime.now().hour))
                        d2=(d1+datetime.timedelta(days=1))
                   
                        d3=(d1+datetime.timedelta(days=2))
                        d4=(d1+datetime.timedelta(days=3))
                       # print('secind date')
                       #print(days_plus)
                        kb_m=get_date_buttons(d1,d2,d3,d4)

                        
                #########################################################################################################################################
                 #если юзер нажал на бронь
                elif event.text in booking_asso and event.user_id not in level2: 
                    text="Когда хотите посетить Hi-tech цех?"
                    date_1=datetime.datetime.today()
                    d1=(date_1-datetime.timedelta(hours=(datetime.datetime.now().hour)))
                    d2=(d1+datetime.timedelta(days=1))
                    d3=(d1+datetime.timedelta(days=2))
                    d4=(d1+datetime.timedelta(days=3))
                   # print('first date')

                    kb_m=get_date_buttons(d1,d2,d3,d4)
                    if event.user_id not in level2:
                        level2.append(event.user_id)
                        days_mass.append(0)

                   # print(str(level2.index(event.user_id))+'     номер юзера')
            #если юзер нажал привет                                                  
                elif event.text in hello_asso and event.user_id not in level2:
                    text="Привет"
            #если юзер нажал на погоду    
                elif event.text in weather_asso and event.user_id not in level2:
                    text=Weather.get_weather_today()
                elif event.user_id  in level2:
                       text="мне нужна дата"
                else:
                    text="Воспользуйтесь клавиатурой"
                    kb_m=keyboard
                    
                ##vk.messages.send(user_id=event.user_id,random_id=get_random_id(),keyboard=get_time_buttons(time_format(ids[1][0]),time_format(ids[1][1]),time_format(ids[1][1]),time_format(ids[1][1])).get_keyboard(),message=text)
                if kb_m==keyboard_2:
                    vk.messages.send(user_id=event.user_id,random_id=get_random_id(),message=text)
                else:
                    vk.messages.send(user_id=event.user_id,random_id=get_random_id(),keyboard=kb_m.get_keyboard(),message=text)    
Esempio n. 55
0
                if inp == "4":
                    uval = int(kernel.getPredicate('expression'))
                    num = random.randint(1, uval)
                kernel.setPredicate('expression', str(num))
                bot_response += kernel.respond('die outcome')
                bot_speech = bot_response[l:]

            elif inp == '5' or inp == '6':
                if inp == '5':
                    city = kernel.getPredicate('home_city')
                    if city is "":
                        city = "Secunderabad"
                else:
                    city = kernel.getPredicate('city')

                w = Weather.get_current_weather(city)
                if w['success']:
                    bot_response += "The weather in {} is {}. The temperature is {} with a minimum of {} and a maximum of {} celcius. The humidity is {}%.".format(
                        w['place'], w['desc'], w['temp'], w['temp_min'],
                        w['temp_max'], w['humidity'])

                else:
                    bot_response += "Sorry, couldn't get the weather"

                bot_speech = bot_response[l:]

            elif inp == '7' or inp == '8':
                if inp == '7':
                    city = kernel.getPredicate('home_city')
                    if city is "":
                        city = "Secunderabad"
Esempio n. 56
0
#!/usr/bin/env python
import sys
import logging
import logging.config
from weather import Weather


def handle_exception(exc_type, exc_value, exc_traceback):
    if issubclass(exc_type, KeyboardInterrupt):
        sys.__excepthook__(exc_type, exc_value, exc_traceback)
        return

    logger.error("Uncaught Exception",
                 exc_info=(exc_type, exc_value, exc_traceback))


sys.excepthook = handle_exception

if __name__ == "__main__":
    logging.config.fileConfig(
        '/home/pi/projects/weather-python/rpi-rgb-led-matrix/bindings/python/samples/mylogger.conf',
        disable_existing_loggers=False)
    logger = logging.getLogger('mylogger')
    weather = Weather()
    if (not weather.process()):
        weather.print_help()
Esempio n. 57
0
    def __init__(self, config_provider):

        text_to_speech = None
        if (config_provider.acting or config_provider.browser or
            config_provider.calculator or config_provider.hand_gesture or
            config_provider.happy_colour or config_provider.mixing_desk or
            config_provider.optical_character_recognition or config_provider.play_your_cards_right or
            config_provider.slideshow or config_provider.weather):
            from texttospeech import TextToSpeech
            text_to_speech = TextToSpeech()

        speech_to_text = None
        if (config_provider.acting or config_provider.browser or
            config_provider.calculator or config_provider.mixing_desk or
            config_provider.phrase_translation or config_provider.play_your_cards_right or
            config_provider.weather):
            from speechtotext import SpeechToText
            speech_to_text = SpeechToText()

        self.acting = None
        if config_provider.acting:
            from acting import Acting
            self.acting = Acting(text_to_speech, speech_to_text)

        self.browser = None
        if config_provider.browser:
            from browser import Browser
            self.browser = Browser(text_to_speech, speech_to_text)

        self.calculator = None
        if config_provider.calculator:
            from calculator import Calculator
            self.calculator = Calculator(text_to_speech, speech_to_text)

        self.hand_gesture = None
        if config_provider.hand_gesture:
            from handgesture import HandGesture
            self.hand_gesture = HandGesture(text_to_speech)

        self.happy_colour = None
        if config_provider.happy_colour:
            from happycolour import HappyColour
            self.happy_colour = HappyColour(text_to_speech)

        self.mixing_desk = None
        if config_provider.mixing_desk:
            from mixingdesk import MixingDesk
            self.mixing_desk = MixingDesk(text_to_speech, speech_to_text)

        self.optical_character_recognition = None
        if config_provider.optical_character_recognition:
            from opticalcharacterrecognition import OpticalCharacterRecognition
            self.optical_character_recognition = OpticalCharacterRecognition(text_to_speech)

        self.phrase_translation = None
        if config_provider.phrase_translation:
            from phrasetranslation import PhraseTranslation
            self.phrase_translation = PhraseTranslation(speech_to_text)

        self.play_your_cards_right = None
        if config_provider.play_your_cards_right:
            from playyourcardsright import PlayYourCardsRight
            self.play_your_cards_right = PlayYourCardsRight(text_to_speech, speech_to_text)

        self.slideshow = None
        if config_provider.slideshow:
            from slideshow import Slideshow
            self.slideshow = Slideshow(text_to_speech)

        self.television = None
        if config_provider.television:
            from television import Television
            self.television = Television()

        self.weather = None
        if config_provider.weather:
            from weather import Weather
            self.weather = Weather(text_to_speech, speech_to_text)
import unittest
from weather import Weather

weather = Weather()
# Lookup via location name.
print('enter a city:')
x=input('')
location = weather.lookup_by_location(x)
condition = location.condition()

# Get weather forecasts for the upcoming days.
for forecasts in location.forecast():
    a=[forecasts['high']]
    b=[forecasts['low']]
    for i in a:
      print ([i])
    """list1=[a]
    list2=[b]
    print(list1)
    
    
    print ("Max value element : ", max(list1))
    print ("Max value element : ", max(list2))"""
Esempio n. 59
0
class MainApp(MDApp):
    Window.size = (400, 600)
    with open("lat.txt", "r") as lat_coord:
        lat_coord = lat_coord.read()
    with open("lon.txt", "r") as lon_coord:
        lon_coord = lon_coord.read()
    with open("api.txt", "r") as apikey:
        apikey = apikey.read()
    with open("units.txt", "r") as um:
        um = um.read()
    with open("addr.txt", "r") as addr:
        addr = addr.read()

    w = Weather(lat_coord, lon_coord, apikey, um, addr)

    def on_start(self):
        self.theme_cls.primary_palette = 'Blue'
        self.search_menu = SearchPopupMenu()
        # print(self.theme_cls.primary_palette)
        # print(self.root.ids)
        # print(self.w.forecastDescIcon[0])
        # print(len(self.w.apiForecastData['list']))

        # print(self.root.ids.outlook)

    def updateTemp(self):
        # get new lat lon

        # send lat and lon to Weather object

        # assign text values to the new Weather object
        self.root.ids.l1.text = self.w.addr
        self.root.ids.l1.secondary_text = 'lat: ' + self.w.lati + ' lon: ' + self.w.long
        self.root.ids.l2.text = self.w.liveDescription.title()
        self.root.ids.l3.text = self.w.liveTemp + '  |  Feels: ' + self.w.liveFeelsLike
        self.root.ids.l4.text = 'Wind: ' + self.w.liveWindDirection + " " + self.w.liveWindSpeed
        self.root.ids.l5.text = 'Humidity: ' + self.w.liveHumidity
        self.root.ids.l6.text = 'Barometer: ' + self.w.livePressure
        self.root.ids.l7.text = 'Sunrise: ' + self.w.liveSunrise
        self.root.ids.l8.text = 'Sunset: ' + self.w.liveSunset
        self.root.ids.l9.text = 'As of: ' + self.w.lastRefresh.strftime(
            '%a: %m/%d%l:%M%p')

        self.root.ids.f00.text = self.w.addr
        self.root.ids.f00.secondary_text = 'lat: ' + self.w.lati + ' lon: ' + self.w.long
        self.root.ids.f0.text = str(
            self.w.forecastTemp[0]
        ) + 'F' + ' ' + self.w.forecastDescription[0].title()
        self.root.ids.f0.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[0]) + ' ' + str(
                self.w.forecastWindSpeed[0]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[0]) + "%"
        self.root.ids.f0.tertiary_text = self.w.forecastDateTime[0].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f0icon.source = 'icons/' + str(
            self.w.forecastDescIcon[0]) + '.png'

        self.root.ids.f1.text = str(
            self.w.forecastTemp[1]
        ) + 'F' + ' ' + self.w.forecastDescription[1].title()
        self.root.ids.f1.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[1]) + ' ' + str(
                self.w.forecastWindSpeed[1]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[1]) + "%"
        self.root.ids.f1.tertiary_text = self.w.forecastDateTime[1].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f1icon.source = 'icons/' + str(
            self.w.forecastDescIcon[1]) + '.png'

        self.root.ids.f2.text = str(
            self.w.forecastTemp[2]
        ) + 'F' + ' ' + self.w.forecastDescription[2].title()
        self.root.ids.f2.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[2]) + ' ' + str(
                self.w.forecastWindSpeed[2]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[2]) + "%"
        self.root.ids.f2.tertiary_text = self.w.forecastDateTime[2].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f2icon.source = 'icons/' + str(
            self.w.forecastDescIcon[2]) + '.png'

        self.root.ids.f3.text = str(
            self.w.forecastTemp[3]
        ) + 'F' + ' ' + self.w.forecastDescription[3].title()
        self.root.ids.f3.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[3]) + ' ' + str(
                self.w.forecastWindSpeed[3]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[3]) + "%"
        self.root.ids.f3.tertiary_text = self.w.forecastDateTime[3].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f3icon.source = 'icons/' + str(
            self.w.forecastDescIcon[3]) + '.png'

        self.root.ids.f4.text = str(
            self.w.forecastTemp[4]
        ) + 'F' + ' ' + self.w.forecastDescription[4].title()
        self.root.ids.f4.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[4]) + ' ' + str(
                self.w.forecastWindSpeed[4]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[4]) + "%"
        self.root.ids.f4.tertiary_text = self.w.forecastDateTime[4].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f4icon.source = 'icons/' + str(
            self.w.forecastDescIcon[4]) + '.png'

        self.root.ids.f5.text = str(
            self.w.forecastTemp[5]
        ) + 'F' + ' ' + self.w.forecastDescription[5].title()
        self.root.ids.f5.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[5]) + ' ' + str(
                self.w.forecastWindSpeed[5]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[5]) + "%"
        self.root.ids.f5.tertiary_text = self.w.forecastDateTime[5].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f5icon.source = 'icons/' + str(
            self.w.forecastDescIcon[5]) + '.png'

        self.root.ids.f6.text = str(
            self.w.forecastTemp[6]
        ) + 'F' + ' ' + self.w.forecastDescription[6].title()
        self.root.ids.f6.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[6]) + ' ' + str(
                self.w.forecastWindSpeed[6]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[6]) + "%"
        self.root.ids.f6.tertiary_text = self.w.forecastDateTime[6].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f6icon.source = 'icons/' + str(
            self.w.forecastDescIcon[6]) + '.png'

        self.root.ids.f7.text = str(
            self.w.forecastTemp[7]
        ) + 'F' + ' ' + self.w.forecastDescription[7].title()
        self.root.ids.f7.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[7]) + ' ' + str(
                self.w.forecastWindSpeed[7]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[7]) + "%"
        self.root.ids.f7.tertiary_text = self.w.forecastDateTime[7].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f7icon.source = 'icons/' + str(
            self.w.forecastDescIcon[7]) + '.png'

        self.root.ids.f8.text = str(
            self.w.forecastTemp[8]
        ) + 'F' + ' ' + self.w.forecastDescription[8].title()
        self.root.ids.f8.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[8]) + ' ' + str(
                self.w.forecastWindSpeed[8]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[8]) + "%"
        self.root.ids.f8.tertiary_text = self.w.forecastDateTime[8].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f8icon.source = 'icons/' + str(
            self.w.forecastDescIcon[8]) + '.png'

        self.root.ids.f9.text = str(
            self.w.forecastTemp[9]
        ) + 'F' + ' ' + self.w.forecastDescription[9].title()
        self.root.ids.f9.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[9]) + ' ' + str(
                self.w.forecastWindSpeed[9]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[9]) + "%"
        self.root.ids.f9.tertiary_text = self.w.forecastDateTime[9].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f9icon.source = 'icons/' + str(
            self.w.forecastDescIcon[9]) + '.png'

        self.root.ids.f10.text = str(
            self.w.forecastTemp[10]
        ) + 'F' + ' ' + self.w.forecastDescription[10].title()
        self.root.ids.f10.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[10]) + ' ' + str(
                self.w.forecastWindSpeed[10]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[10]) + "%"
        self.root.ids.f10.tertiary_text = self.w.forecastDateTime[10].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f10icon.source = 'icons/' + str(
            self.w.forecastDescIcon[10]) + '.png'

        self.root.ids.f11.text = str(
            self.w.forecastTemp[11]
        ) + 'F' + ' ' + self.w.forecastDescription[11].title()
        self.root.ids.f11.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[11]) + ' ' + str(
                self.w.forecastWindSpeed[11]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[11]) + "%"
        self.root.ids.f11.tertiary_text = self.w.forecastDateTime[11].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f11icon.source = 'icons/' + str(
            self.w.forecastDescIcon[11]) + '.png'

        self.root.ids.f12.text = str(
            self.w.forecastTemp[12]
        ) + 'F' + ' ' + self.w.forecastDescription[12].title()
        self.root.ids.f12.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[12]) + ' ' + str(
                self.w.forecastWindSpeed[12]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[12]) + "%"
        self.root.ids.f12.tertiary_text = self.w.forecastDateTime[12].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f12icon.source = 'icons/' + str(
            self.w.forecastDescIcon[12]) + '.png'

        self.root.ids.f13.text = str(
            self.w.forecastTemp[13]
        ) + 'F' + ' ' + self.w.forecastDescription[13].title()
        self.root.ids.f13.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[13]) + ' ' + str(
                self.w.forecastWindSpeed[13]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[13]) + "%"
        self.root.ids.f13.tertiary_text = self.w.forecastDateTime[13].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f13icon.source = 'icons/' + str(
            self.w.forecastDescIcon[13]) + '.png'

        self.root.ids.f14.text = str(
            self.w.forecastTemp[14]
        ) + 'F' + ' ' + self.w.forecastDescription[14].title()
        self.root.ids.f14.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[14]) + ' ' + str(
                self.w.forecastWindSpeed[14]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[14]) + "%"
        self.root.ids.f14.tertiary_text = self.w.forecastDateTime[14].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f14icon.source = 'icons/' + str(
            self.w.forecastDescIcon[14]) + '.png'

        self.root.ids.f15.text = str(
            self.w.forecastTemp[15]
        ) + 'F' + ' ' + self.w.forecastDescription[15].title()
        self.root.ids.f15.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[15]) + ' ' + str(
                self.w.forecastWindSpeed[15]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[15]) + "%"
        self.root.ids.f15.tertiary_text = self.w.forecastDateTime[15].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f15icon.source = 'icons/' + str(
            self.w.forecastDescIcon[15]) + '.png'

        self.root.ids.f16.text = str(
            self.w.forecastTemp[16]
        ) + 'F' + ' ' + self.w.forecastDescription[16].title()
        self.root.ids.f16.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[16]) + ' ' + str(
                self.w.forecastWindSpeed[16]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[16]) + "%"
        self.root.ids.f16.tertiary_text = self.w.forecastDateTime[16].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f16icon.source = 'icons/' + str(
            self.w.forecastDescIcon[16]) + '.png'

        self.root.ids.f17.text = str(
            self.w.forecastTemp[17]
        ) + 'F' + ' ' + self.w.forecastDescription[17].title()
        self.root.ids.f17.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[17]) + ' ' + str(
                self.w.forecastWindSpeed[17]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[17]) + "%"
        self.root.ids.f17.tertiary_text = self.w.forecastDateTime[17].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f17icon.source = 'icons/' + str(
            self.w.forecastDescIcon[17]) + '.png'

        self.root.ids.f18.text = str(
            self.w.forecastTemp[18]
        ) + 'F' + ' ' + self.w.forecastDescription[18].title()
        self.root.ids.f18.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[18]) + ' ' + str(
                self.w.forecastWindSpeed[18]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[18]) + "%"
        self.root.ids.f18.tertiary_text = self.w.forecastDateTime[18].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f18icon.source = 'icons/' + str(
            self.w.forecastDescIcon[18]) + '.png'

        self.root.ids.f19.text = str(
            self.w.forecastTemp[19]
        ) + 'F' + ' ' + self.w.forecastDescription[19].title()
        self.root.ids.f19.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[19]) + ' ' + str(
                self.w.forecastWindSpeed[19]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[19]) + "%"
        self.root.ids.f19.tertiary_text = self.w.forecastDateTime[19].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f19icon.source = 'icons/' + str(
            self.w.forecastDescIcon[19]) + '.png'

        self.root.ids.f20.text = str(
            self.w.forecastTemp[20]
        ) + 'F' + ' ' + self.w.forecastDescription[20].title()
        self.root.ids.f20.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[20]) + ' ' + str(
                self.w.forecastWindSpeed[20]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[20]) + "%"
        self.root.ids.f20.tertiary_text = self.w.forecastDateTime[20].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f20icon.source = 'icons/' + str(
            self.w.forecastDescIcon[20]) + '.png'

        self.root.ids.f21.text = str(
            self.w.forecastTemp[21]
        ) + 'F' + ' ' + self.w.forecastDescription[21].title()
        self.root.ids.f21.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[21]) + ' ' + str(
                self.w.forecastWindSpeed[21]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[21]) + "%"
        self.root.ids.f21.tertiary_text = self.w.forecastDateTime[21].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f21icon.source = 'icons/' + str(
            self.w.forecastDescIcon[21]) + '.png'

        self.root.ids.f22.text = str(
            self.w.forecastTemp[22]
        ) + 'F' + ' ' + self.w.forecastDescription[22].title()
        self.root.ids.f22.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[22]) + ' ' + str(
                self.w.forecastWindSpeed[22]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[22]) + "%"
        self.root.ids.f22.tertiary_text = self.w.forecastDateTime[22].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f22icon.source = 'icons/' + str(
            self.w.forecastDescIcon[22]) + '.png'

        self.root.ids.f23.text = str(
            self.w.forecastTemp[23]
        ) + 'F' + ' ' + self.w.forecastDescription[23].title()
        self.root.ids.f23.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[23]) + ' ' + str(
                self.w.forecastWindSpeed[23]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[23]) + "%"
        self.root.ids.f23.tertiary_text = self.w.forecastDateTime[23].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f23icon.source = 'icons/' + str(
            self.w.forecastDescIcon[23]) + '.png'

        self.root.ids.f24.text = str(
            self.w.forecastTemp[24]
        ) + 'F' + ' ' + self.w.forecastDescription[24].title()
        self.root.ids.f24.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[24]) + ' ' + str(
                self.w.forecastWindSpeed[24]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[24]) + "%"
        self.root.ids.f24.tertiary_text = self.w.forecastDateTime[24].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f24icon.source = 'icons/' + str(
            self.w.forecastDescIcon[24]) + '.png'

        self.root.ids.f25.text = str(
            self.w.forecastTemp[25]
        ) + 'F' + ' ' + self.w.forecastDescription[25].title()
        self.root.ids.f25.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[25]) + ' ' + str(
                self.w.forecastWindSpeed[25]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[25]) + "%"
        self.root.ids.f25.tertiary_text = self.w.forecastDateTime[25].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f25icon.source = 'icons/' + str(
            self.w.forecastDescIcon[25]) + '.png'

        self.root.ids.f26.text = str(
            self.w.forecastTemp[26]
        ) + 'F' + ' ' + self.w.forecastDescription[26].title()
        self.root.ids.f26.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[26]) + ' ' + str(
                self.w.forecastWindSpeed[26]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[26]) + "%"
        self.root.ids.f26.tertiary_text = self.w.forecastDateTime[26].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f26icon.source = 'icons/' + str(
            self.w.forecastDescIcon[26]) + '.png'

        self.root.ids.f27.text = str(
            self.w.forecastTemp[27]
        ) + 'F' + ' ' + self.w.forecastDescription[27].title()
        self.root.ids.f27.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[27]) + ' ' + str(
                self.w.forecastWindSpeed[27]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[27]) + "%"
        self.root.ids.f27.tertiary_text = self.w.forecastDateTime[27].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f27icon.source = 'icons/' + str(
            self.w.forecastDescIcon[27]) + '.png'

        self.root.ids.f28.text = str(
            self.w.forecastTemp[28]
        ) + 'F' + ' ' + self.w.forecastDescription[28].title()
        self.root.ids.f28.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[28]) + ' ' + str(
                self.w.forecastWindSpeed[28]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[28]) + "%"
        self.root.ids.f28.tertiary_text = self.w.forecastDateTime[28].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f28icon.source = 'icons/' + str(
            self.w.forecastDescIcon[28]) + '.png'

        self.root.ids.f29.text = str(
            self.w.forecastTemp[29]
        ) + 'F' + ' ' + self.w.forecastDescription[29].title()
        self.root.ids.f29.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[29]) + ' ' + str(
                self.w.forecastWindSpeed[29]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[29]) + "%"
        self.root.ids.f29.tertiary_text = self.w.forecastDateTime[29].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f29icon.source = 'icons/' + str(
            self.w.forecastDescIcon[29]) + '.png'

        self.root.ids.f30.text = str(
            self.w.forecastTemp[30]
        ) + 'F' + ' ' + self.w.forecastDescription[30].title()
        self.root.ids.f30.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[30]) + ' ' + str(
                self.w.forecastWindSpeed[30]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[30]) + "%"
        self.root.ids.f30.tertiary_text = self.w.forecastDateTime[30].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f30icon.source = 'icons/' + str(
            self.w.forecastDescIcon[30]) + '.png'

        self.root.ids.f31.text = str(
            self.w.forecastTemp[31]
        ) + 'F' + ' ' + self.w.forecastDescription[31].title()
        self.root.ids.f31.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[31]) + ' ' + str(
                self.w.forecastWindSpeed[31]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[31]) + "%"
        self.root.ids.f31.tertiary_text = self.w.forecastDateTime[31].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f31icon.source = 'icons/' + str(
            self.w.forecastDescIcon[31]) + '.png'

        self.root.ids.f32.text = str(
            self.w.forecastTemp[32]
        ) + 'F' + ' ' + self.w.forecastDescription[32].title()
        self.root.ids.f32.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[32]) + ' ' + str(
                self.w.forecastWindSpeed[32]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[32]) + "%"
        self.root.ids.f32.tertiary_text = self.w.forecastDateTime[32].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f32icon.source = 'icons/' + str(
            self.w.forecastDescIcon[32]) + '.png'

        self.root.ids.f33.text = str(
            self.w.forecastTemp[33]
        ) + 'F' + ' ' + self.w.forecastDescription[33].title()
        self.root.ids.f33.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[33]) + ' ' + str(
                self.w.forecastWindSpeed[33]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[33]) + "%"
        self.root.ids.f33.tertiary_text = self.w.forecastDateTime[33].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f33icon.source = 'icons/' + str(
            self.w.forecastDescIcon[33]) + '.png'

        self.root.ids.f34.text = str(
            self.w.forecastTemp[34]
        ) + 'F' + ' ' + self.w.forecastDescription[34].title()
        self.root.ids.f34.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[34]) + ' ' + str(
                self.w.forecastWindSpeed[34]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[34]) + "%"
        self.root.ids.f34.tertiary_text = self.w.forecastDateTime[34].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f34icon.source = 'icons/' + str(
            self.w.forecastDescIcon[34]) + '.png'

        self.root.ids.f35.text = str(
            self.w.forecastTemp[35]
        ) + 'F' + ' ' + self.w.forecastDescription[35].title()
        self.root.ids.f35.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[35]) + ' ' + str(
                self.w.forecastWindSpeed[35]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[35]) + "%"
        self.root.ids.f35.tertiary_text = self.w.forecastDateTime[35].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f35icon.source = 'icons/' + str(
            self.w.forecastDescIcon[35]) + '.png'

        self.root.ids.f36.text = str(
            self.w.forecastTemp[36]
        ) + 'F' + ' ' + self.w.forecastDescription[36].title()
        self.root.ids.f36.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[36]) + ' ' + str(
                self.w.forecastWindSpeed[36]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[36]) + "%"
        self.root.ids.f36.tertiary_text = self.w.forecastDateTime[36].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f36icon.source = 'icons/' + str(
            self.w.forecastDescIcon[36]) + '.png'

        self.root.ids.f37.text = str(
            self.w.forecastTemp[37]
        ) + 'F' + ' ' + self.w.forecastDescription[37].title()
        self.root.ids.f37.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[37]) + ' ' + str(
                self.w.forecastWindSpeed[37]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[37]) + "%"
        self.root.ids.f37.tertiary_text = self.w.forecastDateTime[37].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f37icon.source = 'icons/' + str(
            self.w.forecastDescIcon[37]) + '.png'

        self.root.ids.f38.text = str(
            self.w.forecastTemp[38]
        ) + 'F' + ' ' + self.w.forecastDescription[38].title()
        self.root.ids.f38.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[38]) + ' ' + str(
                self.w.forecastWindSpeed[38]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[38]) + "%"
        self.root.ids.f38.tertiary_text = self.w.forecastDateTime[38].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f38icon.source = 'icons/' + str(
            self.w.forecastDescIcon[38]) + '.png'

        self.root.ids.f39.text = str(
            self.w.forecastTemp[39]
        ) + 'F' + ' ' + self.w.forecastDescription[39].title()
        self.root.ids.f39.secondary_text = 'Wd: ' + self.w.windDirection(
            self.w.forecastWindDeg[39]) + ' ' + str(
                self.w.forecastWindSpeed[39]) + ' MPH' + ' | Hum: ' + str(
                    self.w.forecastHumidity[39]) + "%"
        self.root.ids.f39.tertiary_text = self.w.forecastDateTime[39].strftime(
            '%a: %m/%d/%y %l:%M%p')
        self.root.ids.f39icon.source = 'icons/' + str(
            self.w.forecastDescIcon[39]) + '.png'

    def build(self):
        pass
Esempio n. 60
0
print(
    'This is a very simple chatbot, it does not employ machine learning at all and just a little bit of NLP'
)
print('Please install weather-api and geotext libraries')
print(
    "Please provide a city name always otherwise api won't be able to give a proper answer, "
    "also this chatbot gives only current information and not on forecasting")
print('To exit the bot, just press enter without typing anything\n')

# Give me a working demo of bots from which I can ask about the weather. My question will be " How is the weather' ?

# You can send me the link and also make sure that demo can answer couple of more questions, like how is the weather in
# New delhi  ? Is it going to rain today ? it is sunshine ?

chat_input = ['Hi', 'Hello', 'Hey']
weather = Weather(unit=Unit.CELSIUS)

while True:
    inp = input('User: '******'':
        break
    inp = inp.title()
    if inp in chat_input:
        print('Bot: Hello, what can I do for you?')
    else:
        places = GeoText(inp)
        city = places.cities
        if city:
            lookup = weather.lookup_by_location(city[0])
            condition = lookup.condition
            condition_text = condition.text