def getWeather(): global cityID_, zip_, city_, temperature_, conditions_ if city_ != "": city = pywapi.get_location_ids(city_) cityID = list(city.keys()) tmp = list(city.values()) city_ = tmp[0] cityID_ = cityID result = pywapi.get_weather_from_weather_com(cityID[0]) conditions_ = str(result['current_conditions']['text']) temperature_ = float(result['current_conditions']['temperature']) * 1.8 + 32 else: newCity = "" zip = pywapi.get_location_ids(zip_) cityName = list(zip.values()) for i in cityName[0]: if not i.isdigit() and i != '(' and i != ')': newCity += i city_ = newCity cityList = pywapi.get_location_ids(newCity) cityID = list(cityList.keys()) cityID_ = cityID result = pywapi.get_weather_from_weather_com(cityID[0]) conditions_ = str(result['current_conditions']['text']) temperature_ = float(result['current_conditions']['temperature']) * 1.8 + 32
def weather_intent(chat): output1 = "" output2 = "" response = conversation.message(workspace_id=workspace_id, input={ 'text': chat}) if(location != -1): # location not available location_ID = pywapi.get_location_ids(location) loc_id = probable_location(location_ID) output1 = loc_id if(loc_id != str(-1)): try: now = 'current_conditions' # print (response) if(response['entities'] != []): for i in response['entities']: for j in i: if(j == 'entity' and i[j] == 'location'): location_ID = pywapi.get_location_ids(i['value']) loc_id = probable_location(location_ID) if(loc_id == -1): return 0 if(j == 'entity' and i[j] == 'time'): now = i['value'] Weather_details = pywapi.get_weather_from_weather_com(loc_id) #print(Weather_details) if(now == 'current_conditions'): output1 = str('It is '+Weather_details[now]['text']+' and '+Weather_details[now]['wind']['speed'] + 'Km/hr now in '+ Weather_details[now]['station']) else: overcast = 0 for i in Weather_details: if(i == 'forecasts'): for j in Weather_details[i]: #print(j) for k in j: #print (now) #print (str(k) + str(j[k])) if(k == 'day_of_week' and j[k].lower() == now): # print ('*') output1 = str('It is '+ j['day']['text'] + ' on ' + now) if(j['day']['text'] == 'overcast' or j['day']['text'] == 'storm'): overcast+=1 if(overcast <= 1): output2 = str('No need to worry, there are no overcast for this week') else: output2 = str('There are quite a few chances for overcast, please be patient and calm') else: Weather_details = pywapi.get_weather_from_weather_com(loc_id) output1 = str('It is '+Weather_details[now]['text']+' and '+Weather_details[now]['wind']['speed'] + 'Km/hr windspeed now in '+ Weather_details[now]['station']) except: output1 = ('Server seems busy, cannot display weather information. till then have cup of tea') return (output1+output2)
def weather(self, order): words = order.split(" ") try: city_index = words.index("in") + 1 except ValueError: self.add_anger() print "Wrong syntax" return("No!") if words[city_index] == "city": city_index+=1 if words[-1] == "please": city_arr = words[city_index:-1] self.add_please() else: city_arr = words[city_index:] city = " ".join(city_arr) loc_id = pywapi.get_location_ids(city) city_id = self.get_city_id(loc_id) try: self.add_please() all_info = pywapi.get_weather_from_weather_com( city_id , units = 'metric' ) weather = all_info['current_conditions']['temperature'] text = all_info['current_conditions']['text'] weather_respone = ('It is ' + text + ', Temperature: ' + weather + ' celsius degrees in ' + city) return(weather_respone) except: e = sys.exc_info()[0] print "Error: %s" % e print "Weather occurs some problems" return("NO!")
def getWeather(self): city = "Buffalo" lookup = pywapi.get_location_ids(city) for i in lookup: location_id = i weather_com_result = pywapi.get_weather_from_weather_com( location_id, units="imperial") current_conditions = weather_com_result['current_conditions'][ 'text'].lower() if "cloudy" in current_conditions: self.canvas.create_image(50, 50, image=self.cloudy) elif "rain" in current_conditions: self.canvas.create_image(50, 50, image=self.rain) elif "clear" in current_conditions: self.canvas.create_image(50, 50, image=self.clear) elif "snow" in current_conditions: self.canvas.create_image(50, 50, image=self.snow) else: self.canvas.create_image(50, 50, image=self.clear) return "Currently the weather is " + weather_com_result[ 'current_conditions']['text'].lower( ) + " and " + weather_com_result['current_conditions'][ 'temperature'] + "°F in " + city + "."
def weather(msg): try: if msg: city = msg lookup = pywapi.get_location_ids(city) for i in lookup: location_id = i weather_com_result = pywapi.get_weather_from_weather_com(location_id) cond=weather_com_result['current_conditions']['text'].lower() temp=weather_com_result['current_conditions']['temperature'] if cond=="haze": emo=fog elif cond=="mostly cloudy": emo=cloud elif cond=="fair": emo=part elif cond=="clear": emo=sun elif cond=="partly cloudy": emo=cloud elif cond=="cloudy": emo=cloud else: emo=moneky message="Weather Conditions\n=================\n"+msg+"\n"+emo+"\n\nIt is "+cond+" and "+temp+degree_sign+ "C" return message except: return "error"
def weather(loc,type): ''' tells you the weather :param loc: a str containing a location :param type: the type of weather asked for (current only works right now) :return: ''' lookup = pywapi.get_location_ids(loc) loc_id='blank' for i in lookup: loc_id = i if(loc_id=='blank'): print("\n\nI couldn't figure out where " + loc + " is, try again?") return 0 weather_com_result = pywapi.get_weather_from_weather_com(loc_id,'imperial') try: if(type=='current'): text = weather_com_result['current_conditions']['text'] if text == 'N/A': text = "I dont know current cloud conditions here :(" temp = str(weather_com_result['current_conditions']['temperature']) moon = weather_com_result['current_conditions']['moon_phase']['text'] print("\n\nAcquiring current conditions in " + weather_com_result['location']['name'] + "\n" + text + "\nTemperature is " + temp + '\nMoon phase is ' + moon ) except KeyError or IndexError or ValueError: print("\n\nSorry, something broken...\n\nTry again!") pass
def getweather(location, manualweather): try: if not manualweather: locationid = pywapi.get_location_ids(location) for key in locationid: locationid = key else: locationid = manualweather weather = pywapi.get_weather_from_weather_com(str(locationid), units='imperial') condition = str(weather['current_conditions']['text']).lower() feels_like = str(weather['current_conditions']['feels_like']) temperature = str(weather['current_conditions']['temperature']) wind = str(weather['current_conditions']['wind']['speed']) humidity = str(weather['current_conditions']['humidity']) location = str(weather['location']['name']) if wind == "calm": wind = f"the wind is {wind}" else: wind = f"and wind at {wind} mph" if condition == "": final = f"It is {temperature}° with humidity at {humidity}% and wind at {wind} mph in {location}. It feels like {feels_like}°\n\n" else: final = f"""It is {condition} and {temperature}° with humidity at {humidity}% {wind} in {location}. It feels like {feels_like}°\n\n""" return final except Exception as e: print(location + " has an invalid location for weather!") database.log(f"weather", str({location}), None, None, None, None, "Weather error, most likely invalid location.") return ""
def lookup_weather(): import pywapi import pprint city_file = open("/home/pi/421_521_final_project/Anand_Test/Personal_Stuff/city/Dan_city.txt", "r") city = city_file.read() # this will give you a dictionary of all cities in the world with this city's name - be specific print("Your city is " + city) lookup = pywapi.get_location_ids(city) # workaround to access last item of dictionary for i in lookup: location_id = i # location_id now contains the city's code weather_com_result = pywapi.get_weather_from_weather_com(location_id) print( "The current weather is " + weather_com_result["current_conditions"]["text"].lower() + " and " + weather_com_result["current_conditions"]["temperature"] + "C in " + city + "." )
def forecast(bot, event, *args): if args: place = ' '.join(args) lookup = pywapi.get_location_ids(place) for i in lookup: location_id = i else: location_id = 'USVA0140' yield from bot.coro_send_message(event.conv, _("No location given; defaulting to Chantilly, VA")) weather_com_result = pywapi.get_weather_from_weather_com( location_id, units='imperial') place = weather_com_result['location']['name'] high = weather_com_result['forecasts'][1]['high'] low = weather_com_result['forecasts'][1]['low'] day = weather_com_result['forecasts'][1]['day']['text'] if day == '': day = 'N/A' night = weather_com_result['forecasts'][1]['night']['text'] if night == '': night = 'N/A' date = weather_com_result['forecasts'][1]['date'] url = links.shorten( 'http://www.weather.com/weather/today/l/' + location_id) msg = _("<b>Forecast for {} on {}:</b><br>Conditions: Day - {}; Night - {}<br>High: {}<br>Low: {}<br>For more information visit {}").format( place, date, day, night, high, low, url) yield from bot.coro_send_message(event.conv, msg)
def weather(bot, event, *args): '''Gets weather from weather.com. Defaults to Chantilly, VA if no location given. Format is /bot weather <city>,<state/country>''' try: if args: place = ' '.join(args) lookup = pywapi.get_location_ids(place) for i in lookup: location_id = i else: location_id = 'USVA0140' yield from bot.coro_send_message(event.conv, _("No location given; defaulting to Chantilly, VA")) weather_com_result = pywapi.get_weather_from_weather_com( location_id, units='imperial') condition = weather_com_result['current_conditions']['text'].lower() temp = weather_com_result['current_conditions']['temperature'] feelslike = weather_com_result['current_conditions']['feels_like'] place = weather_com_result['location']['name'] url = links.shorten( 'http://www.weather.com/weather/today/l/' + location_id) msg = _('<b>Today in {}:</b><br>Temp: {}°F (Feels like: {}°F)<br>Conditions: {}<br>For more information visit {}').format( place, temp, feelslike, condition, url) yield from bot.coro_send_message(event.conv, msg) except BaseException as e: msg = _('{} -- {}').format(str(e), event.text) yield from bot.coro_send_message(CONTROL, msg)
def getposit(city): x = 0 pos = pywapi.get_location_ids(city) for i in pos: x += 1 location_id = i result = pywapi.get_weather_from_weather_com(location_id) return(result['current_conditions']['temperature'])
def set_weather_id(self, location): ids = pywapi.get_location_ids(location); if len(ids) == 0: self.loc_id = None; else: for w_id in ids: self.loc_id = w_id; break;
def get_location_id(self): city = self.location.partition(',')[0].strip() smallest_discance = 100 best_location_id = None location_ids = pywapi.get_location_ids(city) for location_id, name in list(location_ids.items()): distance = levenshtein(name.lower(), self.location.lower()) if distance < smallest_discance: best_location_id, smallest_discance = location_id, distance return best_location_id
def main(): try: arguments = docopt.docopt(__doc__) city = arguments['--city'] except docopt.DocoptExit as e: print(e) else: p = pywapi.get_location_ids(city.lower()) for i, ci in enumerate(p): print(i, ' -> ' + p[ci] + ' -- ' + ci )
def noaa(zipcode): location = geocoder.google(zipcode) lookup = pywapi.get_location_ids(location.city + "," + location.state) key = lookup.keys() optimalWeather = list() weather_result = pywapi.get_weather_from_weather_com(key[0]) for x in range(0, len(weather_result["forecasts"])): print (weather_result["forecasts"][x]["date"] + ": " + weather_result["forecasts"][x]["night"]["brief_text"]) if "Clear" in weather_result["forecasts"][x]["night"]["brief_text"]: optimalWeather.append(weather_result["forecasts"][x]["date"]) print optimalWeather
def get_location_id(self, city): # Get location ID for that city count = 0 flag = True lookup = pywapi.get_location_ids(city) while len(lookup) != 1: if len(lookup) > 1: for key, value in lookup.items(): if 'India' in value: location_id = key city = value lookup = pywapi.get_location_ids(city) flag = False break if flag == False: break if len(lookup) == 0: return "Fail", None for k in lookup: location_id = k return location_id, city
def post(self): location = self.request.get('location') location_id = pywapi.get_location_ids(location) weather_data = pywapi.get_weather_from_weather_com(location_id) self.response.write("""<!doctype html> <html> <body> Location: %s <br> Current conditions: %s <br> <a href='/'>back</a> </body> </html>""" % (weather_data["loc"]["name"], weather_data["current_conditions"]["text"]) )
def handle_text(message): try: city = pywapi.get_location_ids(message.text) for i in city: cityCode = i weather_com_result = pywapi.get_weather_from_weather_com(cityCode) weatherReport = "It is " + weather_com_result['current_conditions'][ 'text'].lower( ) + " and " + weather_com_result['current_conditions'][ 'temperature'] + "°C now in " + message.text + "." + "\n" + "Feels like " + weather_com_result[ 'current_conditions'][ 'feels_like'] + "°C. \n" + "Last update - " + weather_com_result[ 'current_conditions']['last_updated'] bot.send_message(message.chat.id, weatherReport) except: bot.send_message(message.chat.id, 'нет такого города и страны')
def Weather(self): for i in self.trying: i.Destroy() self.trying = [] sizer = wx.GridBagSizer() city='limoges' lookup = pywapi.get_location_ids(city) #work around to access last item of dictionary for i in lookup: location_id = i weather_com_result = pywapi.get_weather_from_weather_com(location_id) yahoo_result = pywapi.get_weather_from_yahoo(location_id) txt_temperature = u"%s°C" % (yahoo_result['condition']['temp']) self.text = wx.StaticText(self.wuw,-1,txt_temperature, pos=(0,0)) font1 = wx.Font(38, wx.NORMAL, wx.NORMAL, wx.NORMAL) self.text.SetFont(font1) text_align = self.text.GetTextExtent(txt_temperature) self.text.SetSize(text_align[0],text_align[1]) self.text.SetPosition(((100*self.Grid/2)-text_align[0]/2, 100*self.Grid/2-text_align[1]/2)) weather1 = self.trying.append(self.text) pos_img_weather = (100*self.Grid/2-225/2, 100*self.Grid/2-225-text_align[1]) if 'swon' in str.lower(str(yahoo_result['condition']['text'])): pass self.img= wx.Image(os.path.realpath('images/nuage-ensoleillé.png.png'),wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.staticBmp= wx.StaticBitmap(self.wuw,-1,self.img,pos=pos_img_weather) elif 'cloudy' in str.lower(str(yahoo_result['condition']['text'])): pass self.img= wx.Image(os.path.realpath('images/nuage.png'),wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.staticBmp= wx.StaticBitmap(self.wuw,-1,self.img,pos=pos_img_weather) elif 'rain' in str.lower(str(yahoo_result['condition']['text'])): pass self.img= wx.Image(os.path.realpath('images/pluie.png'),wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.staticBmp= wx.StaticBitmap(self.wuw,-1,self.img,pos=pos_img_weather) elif 'sun' in str.lower(str(yahoo_result['condition']['text'])): pass self.img= wx.Image(os.path.realpath('images/sun.jpeg'),wx.BITMAP_TYPE_JPEG).ConvertToBitmap() self.staticBmp= wx.StaticBitmap(self.wuw,-1,self.img,pos=pos_img_weather) elif 'fair' in str.lower(str(yahoo_result['condition']['text'])): pass self.img= wx.Image(os.path.realpath('images/nuage.png'),wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.staticBmp= wx.StaticBitmap(self.wuw,-1,self.img,pos=pos_img_weather) wx.CallLater(900000,self.Weather)
def weather(request): less = 'null' form = Cityform(request.POST or None) if form.is_valid(): city = form.cleaned_data['city_name'] lookup = pywapi.get_location_ids(city) for i in lookup: location = i weather_com_result = pywapi.get_weather_from_weather_com(location) city_name = city temperature = weather_com_result['current_conditions']['temperature'] humidity = weather_com_result['current_conditions']['humidity'] visibility = weather_com_result['current_conditions']['visibility'] weather_obj = WeatherCondition(city_name=city_name, temperature=temperature, humidity=humidity, visibility=visibility) weather_obj.save() j = 0 temp = [] temp2 = [] date = [] for i in weather_com_result['forecasts']: temp.append(i['high']) for i in weather_com_result['forecasts']: temp2.append(i['low']) for i in weather_com_result['forecasts']: date.append(i['date']) variables = RequestContext( request, { 'weather_com_result': weather_com_result, 'city': city, 'form': form, 'j': j, 'temp': temp, 'temp2': temp2, 'date': date, }) else: variables = RequestContext(request, { 'weather_com_result': less, 'form': form, }) return render_to_response("weather.html", variables)
def get_weathercom(location): lookup = pywapi.get_location_ids(location) for i in lookup: location_id = i weathercom_result = pywapi.get_weather_from_weather_com(location_id) #output = {} #output["today"] = {} #output["today"]["temperature"] = weathercom_result["current_conditions"]["temperature"] #output["today"]["text"] = weathercom_result["current_conditions"]["text"] #output["tomorrow"] = {} #output["tomorrow"][] return weathercom_result
def doAction(self,r,sr,words,sensorList): if "how's the weather in" in words: location = words.split("how's the weather in")[-1].strip(" ") else: os.system("espeak -s 120 'searching'") lastFix = sensorList['location'].getLastData() if lastFix["lastFix"] == None: return "I don't know where you are" geoloc = Nominatim() coor = str(lastFix["lastFix"]['lat'])+", "+str(lastFix["lastFix"]['lon']) loc = geoloc.reverse(coor,timeout=10) loc1 = loc.address location = loc1.split(", ")[-2] location = pywapi.get_location_ids(location) if len(location) == 0: return "location not found" locationId = next (iter (location.keys())) w = pywapi.get_weather_from_weather_com(locationId, units="imperial") return "It is " + w["current_conditions"]["temperature"] + "degrees and " + w["current_conditions"]["text"]
def getWeather(self): city="Buffalo" lookup = pywapi.get_location_ids(city) for i in lookup: location_id = i weather_com_result = pywapi.get_weather_from_weather_com(location_id, units="imperial") current_conditions = weather_com_result['current_conditions']['text'].lower() if "cloudy" in current_conditions: self.canvas.create_image(50, 50, image=self.cloudy) elif "rain" in current_conditions : self.canvas.create_image(50, 50, image=self.rain) elif "clear" in current_conditions : self.canvas.create_image(50, 50, image=self.clear) elif "snow" in current_conditions : self.canvas.create_image(50, 50, image=self.snow) else: self.canvas.create_image(50, 50, image=self.clear) return "Currently the weather is " + weather_com_result['current_conditions']['text'].lower() + " and " + weather_com_result['current_conditions']['temperature'] + "°F in " + city + "."
def location(self): if(not hasattr(self, '_loc')): try: #raise urllib2.URLError('Testing') loc = json.load(urllib2.urlopen('http://freegeoip.net/json', timeout=20)) #self._pp.pprint(self._loc) if(loc['zipcode'] != ''): self._loc = loc['zipcode'] else: city = (loc['city'], loc['region_code']) locations = pywapi.get_location_ids('%s, %s' % city) #self._pp.pprint(locations) if(len(locations.items()) == 0): self.error.emit(self.locationMsg) self._loc = '' self._loc = locations.items()[0][0] except urllib2.URLError: self.error.emit(self.locationMsg) self._loc = '' return self._loc
def location(self): if (not hasattr(self, '_loc')): try: #raise urllib2.URLError('Testing') loc = json.load( urllib2.urlopen('http://freegeoip.net/json', timeout=20)) #self._pp.pprint(self._loc) if (loc['zipcode'] != ''): self._loc = loc['zipcode'] else: city = (loc['city'], loc['region_code']) locations = pywapi.get_location_ids('%s, %s' % city) #self._pp.pprint(locations) if (len(locations.items()) == 0): self.error.emit(self.locationMsg) self._loc = '' self._loc = locations.items()[0][0] except urllib2.URLError: self.error.emit(self.locationMsg) self._loc = '' return self._loc
def getallweather(location, manualweather): try: if not manualweather: locationid = pywapi.get_location_ids(location) for key in locationid: locationid = key else: locationid = manualweather weather = pywapi.get_weather_from_weather_com(str(locationid), units='imperial') final = weather['current_conditions']['temperature'] if final == '': return 50 # For handling exceptions if the site returns null else: return final except Exception as e: print(location + " Error trying to get all weather location for stats.") print(str(e)) database.log(f"weather", str({location}), None, None, None, None, "Weather error, most likely invalid location. " + str(e)) return 50 # For handling exceptions if the site returns null
def weather(request): less='null' form=Cityform(request.POST or None) if form.is_valid(): city=form.cleaned_data['city_name'] lookup= pywapi.get_location_ids(city) for i in lookup: location=i weather_com_result = pywapi.get_weather_from_weather_com(location) city_name=city temperature=weather_com_result['current_conditions']['temperature'] humidity=weather_com_result['current_conditions']['humidity'] visibility=weather_com_result['current_conditions']['visibility'] weather_obj=WeatherCondition(city_name = city_name, temperature = temperature , humidity = humidity, visibility = visibility) weather_obj.save() j=0 temp=[] temp2=[] date=[] for i in weather_com_result['forecasts']: temp.append(i['high']) for i in weather_com_result['forecasts']: temp2.append(i['low']) for i in weather_com_result['forecasts']: date.append(i['date']) variables = RequestContext(request,{ 'weather_com_result' : weather_com_result, 'city' : city, 'form' : form, 'j' : j, 'temp' :temp, 'temp2' :temp2, 'date' :date, }) else: variables = RequestContext(request,{ 'weather_com_result' : less, 'form' : form,}) return render_to_response("weather.html", variables)
def fetchWeather(data): "This function fetches weather details for the client requested location" city = str(data) lookup = pywapi.get_location_ids(city) #workaround to access last item of dictionary #print lookup for i in lookup: location_id = i #location_id now contains the city's code try: weatherResult = pywapi.get_weather_from_weather_com(location_id , units = 'metric') returnedData = weatherResult["location"]["name"] + "$" + weatherResult["current_conditions"]["temperature"] + u"\u00B0" + "C$" + "It is " + weatherResult["current_conditions"]["text"] + "$" + weatherResult["current_conditions"]["humidity"] + "%" + "$\n " for days in weatherResult["forecasts"]: returnedData = returnedData + days["day_of_week"] + "^" + days["high"] + u"\u00B0" +"C^" + days["low"] + u"\u00B0" + "C$" return returnedData except UnboundLocalError: print "City does not exist" return "0" except KeyError: print "Key Error Exception caught" return "0"
def post(self): town = self.get_argument("town"); county = self.get_argument("county"); state = self.get_argument("state"); location = self.get_argument("location"); latitude = self.get_argument("latitude"); longitude = self.get_argument("longitude"); time = datetime.now(); fatalities = self.get_argument("fatalities"); weather_dic = pywapi.get_weather_from_yahoo(pywapi.get_location_ids(town + ", " + state).keys()[0]); weather = (weather_dic['condition']['text']) + ", " + (weather_dic['condition']['temp']) + "C."; crashinfo = json.dumps({ 'town': town, 'county': county, 'state': state, 'location': location, 'latitude': latitude, 'longitude': longitude, 'weather': weather, 'time': time.strformat("'%Y-%m-%dT%H:%M:%S'"), }) self.write(crashinfo) self.finish()
def handle(): try: Config.read(jangopath.CONFIG_PATH) except: print "Couldn't read config file." return city = Config.get("Location", "name") lookup = pywapi.get_location_ids(city) for i in lookup: loc_id = i break try: weather_com_result = pywapi.get_weather_from_weather_com(loc_id) except: print "Something went wrong." return print weather_com_result["current_conditions"]["text"] + " :", print "Temperature " + weather_com_result["current_conditions"]["temperature"] + " c", print "but feels like " + weather_com_result["current_conditions"]["feels_like"] + " c"
weatherlocation = order[(int(weatherstring[1:-1]) + 3):] elif "of" in order: n = order.index('of') weatherstring = str([ i for (i, c) in enumerate(order) if c == 'o' and n <= i <= n + len('of') ]) weatherlocation = order[(int(weatherstring[1:-1]) + 3):] elif "at" in order: n = order.rindex('at') weatherstring = str([ i for (i, c) in enumerate(order) if c == 'a' and n <= i <= n + len('at') ]) weatherlocation = order[(int(weatherstring[1:-1]) + 3):] lookup = pywapi.get_location_ids(weatherlocation) for i in lookup: location_id = i weather_com_result = pywapi.get_weather_from_weather_com( location_id) print "\nIt is " + string.lower( weather_com_result['current_conditions'] ['text']) + " and " + weather_com_result['current_conditions'][ 'temperature'] + "*C now in " + weatherlocation + "\n" #Abbreviations code elif "fullform" in order or "full form" in order or "abbreviation" in order: ''' USE CASE Ask : What is the fullform of cs? ASK : Fullform of dbms
import pywapi cities = ["Vienna", "Madrid", "Munich"] sentence = "Forecast please. City: Vienna" for city in cities: if city in sentence: print(city) new_sentence = sentence.replace("Forecast please. City: ", "") print new_sentence names = pywapi.get_location_ids("Chicago") print """Which location did you mean? Please find the location in the following list, and reformulate your request with the correct city code:""" for thing in names: print "City: " + names[thing] + " Code: " + thing
def city_name_attribute(city_name, session): lookup = get_location_ids(city_name) if not lookup: return {"city": "invalid"} else: return {"city": city_name}
def test(): weather_com_result = pywapi.get_weather_from_weather_com('CAXX0225') print pywapi.get_location_ids("kingston, CA") print "Weather.com says: It is " + string.lower(weather_com_result['current_conditions']['text']) + " and " + weather_com_result['current_conditions']['temperature'] + "C now in Kingston.\n\n"
import pywapi as weather ids=weather.get_location_ids(boston) w=weather.get_weather_from_weather_com("SFXX8501",units="metric")
def buttonClick(): speak = wincl.Dispatch("SAPI.SpVoice") recengine = "google" mixer.init() x = 0 y = 0 flag = False mode = 0 r = sr.Recognizer() global ok if ok: playSound("msg1.mp3") ok = 0 recognised = u"" with sr.Microphone() as source: r.adjust_for_ambient_noise(source) playSound("start.mp3") f1 = False print u"আপনার বাক্য বলুন" with sr.Microphone() as source: audio = r.listen(source) try: recognised = r.recognize_google(audio, language='bn-BD') f1 = True except sr.UnknownValueError: print(u"গুগল স্পিচ রিকগনিশন অডিও বুঝতে পারেনি(১)") except sr.RequestError as e: print(u"গুগল স্পিচ রিকগনিশন অডিও বুঝতে পারেনি(২)") #print("Could not request results from Google Speech Recognition service; {0}".format(e)) if f1: print u"সফল হয়েছে" entry1.focus() entry1.delete(0, END) entry1.insert(0, recognised) if findWholeWord('hello')(recognised) or findWholeWord('hi')( recognised) or findWholeWord('hey')( recognised) or findWholeWord("what's up")(recognised): speak.Speak("greetings to you too. I'm ready to do your bidding.") elif findWholeWord('good morning')(recognised) or findWholeWord( 'good afternoon')(recognised) or findWholeWord('good evening')( recognised): speak.Speak("greetings to you too. I'm ready to do your bidding.") elif findBanglaWord(recognised, u"সুপ্রভাত") or findBanglaWord( recognised, u"শুভ সকাল"): textToSpeech( u"সুপ্রভাত! একটি চমৎকার দিন আশা করছি আপনার জন্য স্যার") playSound("result.mp3") elif findBanglaWord(recognised, u"শুভ অপরাহ্ন"): textToSpeech(u"ধন্যবাদ। শুভ অপরাহ্ন") playSound("result.mp3") elif findBanglaWord(recognised, u"শুভ সন্ধ্যা"): textToSpeech(u"ধন্যবাদ। শুভ সন্ধ্যা") playSound("result.mp3") elif findWholeWord('thank you')(recognised) or findWholeWord('thank')( recognised): speak.Speak("You are welcome.") elif findBanglaWord(recognised, u"ধন্যবাদ"): textToSpeech(u"আপনাকে স্বাগতম") playSound("result.mp3") elif findWholeWord('how are you')(recognised): speak.Speak("I am fine. Thank you") elif findBanglaWord(recognised, u"কেমন আছেন") or findBanglaWord( recognised, u"আছেন কেমন") or findBanglaWord( recognised, u"কেমন আছো"): textToSpeech(u"আমি ভালো। আপনি কেমন আছেন?") playSound("result.mp3") elif findWholeWord('your name')(recognised): speak.Speak("I am Smarty. I can make your work a lot easier.") elif findBanglaWord(recognised, u"নাম কি") or findBanglaWord( recognised, u"কি নাম"): textToSpeech(u"আমি Smarty") playSound("result.mp3") elif findWholeWord('open browser')(recognised) or findWholeWord( 'open chrome')(recognised) or findWholeWord('open firefox')( recognised) or findWholeWord('open internet explorer')( recognised): if findWholeWord('open browser')(recognised) or findWholeWord( 'browser')(recognised): speak.Speak("All right, I will do it for you.") webbrowser.open('http://www.google.com') elif findWholeWord('open chrome')(recognised): speak.Speak("All right, I will open Chrome.") url = 'chrome://newtab' chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' webbrowser.get(chrome_path).open(url) elif findWholeWord('open internet explorer')( recognised) or findWholeWord('internet explorer')( recognised): ie = webbrowser.get(webbrowser.iexplore) ie.open('google.com') elif findWholeWord('open mozilla firefox')( recognised) or findWholeWord('open firefox')( recognised) or findWholeWord('firefox')(recognised): speak.Speak("All right, I will open Firefox for you.") webbrowser.get( 'C:/Program Files/Mozilla Firefox/firefox.exe %s').open( 'http://www.google.com') elif findWholeWord('what time is it')(recognised) or findWholeWord( 'what is the time now')(recognised) or findWholeWord( 'tell me the time')( recognised) or findWholeWord('what time')( recognised) and findWholeWord('now')(recognised): timenow = time.localtime() timeh = timenow.tm_hour timem = timenow.tm_min if timeh < 13: ampm = "AM" else: ampm = "PM" if timem > 9: extra = " " else: extra = "oh" speak.Speak("the time is " + str(timeh) + extra + str(timem) + ampm) elif findBanglaWord(recognised, u"কয়টা বাজে") or findBanglaWord( recognised, u"বাজে কয়টা") or findBanglaWord( recognised, u"সময় কত"): timenow = time.localtime() timeH = timenow.tm_hour timeM = timenow.tm_min ampm = "AM" if timeH == 0: timeH = 12 if timeH == 12: ampm = "PM" if timeH > 12 and timeH <= 23: timeH = timeH - 12 ampm = "PM" if ampm == "AM": somoy = u"এখন সময় সকাল " + avro.parse( str(timeH)) + u" টা বেজে " + avro.parse( str(timeM)) + u" মিনিট" else: somoy = u"এখন সময় বিকেল " + avro.parse( str(timeH)) + u" টা বেজে " + avro.parse( str(timeM)) + u" মিনিট" print somoy textToSpeech(somoy) playSound("result.mp3") elif findWholeWord('what is the temperature')( recognised) or findWholeWord('what is the weather')( recognised) or findWholeWord('weather in')(recognised): loc = "Sylhet, Bangladesh" if "dhaka" in recognised: loc = "Dhaka, Bangladesh" elif "chittagong" in recognised: loc = "Chittagong, Bangladesh" elif "new york" in recognised: loc = "New York" lookup = pywapi.get_location_ids(loc) #print lookup for i in lookup: location_id = i print "loocation_id = " + location_id weather = pywapi.get_weather_from_weather_com(location_id) speak.Speak("the weather in " + loc + " is " + weather['current_conditions']['text'] + ". Current temp " + weather['current_conditions']['temperature'] + " degrees Celsius") elif findBanglaWord(recognised, u"ওয়েদার কেমন") or findBanglaWord( recognised, u"আবহাওয়া কেমন") or findBanglaWord( recognised, u"আবহাওয়ার খবর") or findBanglaWord( recognised, u"তাপমাত্রা কেমন") or findBanglaWord( recognised, u"আবহাওয়ার কি অবস্থা"): loc = "Sylhet, Bangladesh" lookup = pywapi.get_location_ids(loc) for i in lookup: location_id = i weather = pywapi.get_weather_from_weather_com(location_id) text = weather['current_conditions']['text'] temp = weather['current_conditions']['temperature'] abohowya = u"বর্তমান আবহাওয়া " + text + u" এবং তাপমাত্রা " + avro.parse( str(temp)) + u" ডিগ্রি সেলসিয়াস" textToSpeech(abohowya) playSound("result.mp3") elif findWholeWord('go to')(recognised) and ".com" in recognised: domain = recognised.split("go to ", 1)[1] speak.Speak("All right, I will take you to" + domain) webbrowser.open('http://www.' + domain) elif findWholeWord('close')(recognised): f = recognised.split("close ", 1)[1] speak.Speak(f + " is closed Sir.") p = 'TASKKILL /F /IM ' + f + '.exe' try: os.system(p) except: speak.Speak(f + " is already closed Sir") elif findWholeWord('lock')(recognised) and findWholeWord('pc')( recognised ) or findWholeWord('lock')(recognised) and findWholeWord('computer')( recognised) or findWholeWord('lock')( recognised) and findWholeWord('system')(recognised): ctypes.windll.user32.LockWorkStation() elif findBanglaWord(recognised, "কম্পিউটার তালা"): ctypes.windll.user32.LockWorkStation() elif findWholeWord('shutdown')(recognised) and findWholeWord('pc')( recognised ) or findWholeWord('shutdown')(recognised) and findWholeWord( 'computer')(recognised) or findWholeWord('shutdown')( recognised) and findWholeWord('system')(recognised): os.system('shutdown -s') elif findBanglaWord( recognised, "কম্পিউটার বন্ধ করুন") or findBanglaWord( recognised, "কম্পিউটার বন্ধ করো") or findBanglaWord( recognised, "কম্পিউটার বন্ধ কর"): os.system('shutdown -s') else: #internal search qDict = {} cntDict = {} for word in recognised.split(): qDict[word] = 1 path = u"""C:/Users/royta/Desktop/Final/""" files = os.listdir(path) for txtfiles in files: if ".txt" in txtfiles: p = path + txtfiles cnt = 0 with codecs.open(p, 'r', encoding='utf-8', errors='ignore') as f: for line in f: for word in line.split(): if word in qDict: cnt += 1 cntDict[txtfiles] = cnt Max = 0 fileName = "" for key, value in cntDict.iteritems(): #print key, "-->", value if value > Max: Max = value fileName = key if Max == 0: print "Nothing matched. Looking online for solution." else: print "Maximum matched ", fileName, " --> ", Max #end of the internal search print recognised if detect(recognised) == "en": #wikipedia English stuff querySummary = "" wikipedia.set_lang("en") try: idx = 0 searchResult = wikipedia.search(recognised) length = len(searchResult) i = 0 while i < length: if searchResult[i] == recognised: idx = i break i += 1 querySummary = wikipedia.summary(searchResult[idx], sentences=3) result = remove_text_between_parens(querySummary) print result speak.Speak(result) except IndexError: playSound("error.mp3") except wikipedia.exceptions.DisambiguationError: playSound("error.mp3") except wikipedia.exceptions.PageError: playSound("error.mp3") else: #wikipedia Bangla stuff querySummary = u"" wikipedia.set_lang("bn") try: idx = 0 searchResult = wikipedia.search(recognised) length = len(searchResult) i = 0 while i < length: if searchResult[i] == recognised: idx = i break i += 1 playSound("waitmsg.mp3") querySummary = wikipedia.summary(searchResult[idx]) #3 line summary result = sentence(3, querySummary) result = remove_text_between_parens(result) #print result textToSpeech(result) playSound("result.mp3") except IndexError: playSound("error.mp3") except wikipedia.exceptions.DisambiguationError: playSound("error.mp3") except wikipedia.exceptions.PageError: playSound("error.mp3") else: playSound("error.mp3")
if "p.m" in recognised or "evening" in recognised or "evening" in recognised: call(["espeak","OK I can set an alarm at "+recognised[location-2:location+3]+"in the evening"]) else: call(["espeak","OK I can set an alarm at "+recognised[location-2:location+3]+"in the morning"]) elif "hello" in recognised or "good morning" in recognised or "hi" in recognised: call(["espeak","greetings to you too. I'm ready tou do your bidding."]) elif "open" in recognised: if "browser" in recognised or "internet" in recognised or "firefox" in recognisedd: call(["espeak","OK I'll open a browser"]) call(["firefox","www.google.com"]) elif "weather" in recognised: loc="Bolton" lookup = pywapi.get_location_ids(loc) for i in lookup: location_id = i weather=pywapi.get_weather_from_weather_com(location_id) call (["espeak", "the weather in "+loc+" is "+weather['current_conditions']['text']+". Current temp "+weather['current_conditions']['temperature']+" degrees centigrade"]) elif "thank" in recognised: call(["espeak","You're welcome."]) elif "dictation" in recognised: if "start" in recognised or "mode" in recognised: mode=1 call(["espeak","entering dictation mode"]) elif "what" in recognised:
subreddit = r.get_subreddit('fyyntest') scanned_comments = subreddit.get_comments() for comment in scanned_comments: if "Forecast please" in comment.body and comment.id not in already_done: try: city = comment.body.replace("Forecast please. City: ", "") print str(city) fore = pywapi.get_weather_from_yahoo(str(city), units='metric') print fore fore_message = "The Temperature is " + \ fore['condition']['temp'] + "in" + city comment.reply(fore_message) already_done.append(comment.id) print already_done except: fore = pywapi.get_weather_from_yahoo(str(city), units='metric') names = pywapi.get_location_ids(city) comment.reply("Which location did you mean? Please"\ "reformulate your request with the" \ "correct City code:") citylist = "" for thing in names: citylist += "City: " + str(names[thing]) + \ "Code: " + str(thing) + "," comment.reply(citylist) already_done.append(comment.id) time.sleep(100)
def getLocationCode(self, address): return pywapi.get_location_ids(self.getCityStrFromAddr(address))
def Weather(self): for i in self.trying: i.Destroy() self.trying = [] sizer = wx.GridBagSizer() city = 'limoges' lookup = pywapi.get_location_ids(city) #work around to access last item of dictionary for i in lookup: location_id = i weather_com_result = pywapi.get_weather_from_weather_com(location_id) yahoo_result = pywapi.get_weather_from_yahoo(location_id) txt_temperature = u"%s°C" % (yahoo_result['condition']['temp']) self.text = wx.StaticText(self.wuw, -1, txt_temperature, pos=(0, 0)) font1 = wx.Font(38, wx.NORMAL, wx.NORMAL, wx.NORMAL) self.text.SetFont(font1) text_align = self.text.GetTextExtent(txt_temperature) self.text.SetSize(text_align[0], text_align[1]) self.text.SetPosition(((100 * self.Grid / 2) - text_align[0] / 2, 100 * self.Grid / 2 - text_align[1] / 2)) weather1 = self.trying.append(self.text) pos_img_weather = (100 * self.Grid / 2 - 225 / 2, 100 * self.Grid / 2 - 225 - text_align[1]) if 'swon' in str.lower(str(yahoo_result['condition']['text'])): pass self.img = wx.Image( os.path.realpath('images/nuage-ensoleillé.png.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.staticBmp = wx.StaticBitmap(self.wuw, -1, self.img, pos=pos_img_weather) elif 'cloudy' in str.lower(str(yahoo_result['condition']['text'])): pass self.img = wx.Image(os.path.realpath('images/nuage.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.staticBmp = wx.StaticBitmap(self.wuw, -1, self.img, pos=pos_img_weather) elif 'rain' in str.lower(str(yahoo_result['condition']['text'])): pass self.img = wx.Image(os.path.realpath('images/pluie.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.staticBmp = wx.StaticBitmap(self.wuw, -1, self.img, pos=pos_img_weather) elif 'sun' in str.lower(str(yahoo_result['condition']['text'])): pass self.img = wx.Image(os.path.realpath('images/sun.jpeg'), wx.BITMAP_TYPE_JPEG).ConvertToBitmap() self.staticBmp = wx.StaticBitmap(self.wuw, -1, self.img, pos=pos_img_weather) elif 'fair' in str.lower(str(yahoo_result['condition']['text'])): pass self.img = wx.Image(os.path.realpath('images/nuage.png'), wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.staticBmp = wx.StaticBitmap(self.wuw, -1, self.img, pos=pos_img_weather) wx.CallLater(900000, self.Weather)
bus.write_byte_data(ADDRC,PORTA,0xFF) bus.write_byte_data(ADDRC,PORTB,~column) elif color == GREEN: bus.write_byte_data(ADDRC,PORTB,0xFF) bus.write_byte_data(ADDRC,PORTA,~column) elif color == YELLOW: bus.write_byte_data(ADDRC,PORTB,~column) bus.write_byte_data(ADDRC,PORTA,~column) bus.write_byte_data(ADDRR,PORTA,1<<row) bus = smbus.SMBus(1) initialise() ledColor = GREEN location = pywapi.get_location_ids('London') #print location weather_com_result = pywapi.get_weather_from_weather_com('44418') string1 = "Weather.com says: It is " + string.lower(weather_com_result['current_conditions']['text']) + " and " + weather_com_result['current_conditions']['temperature'] + "C now in New York." textScroll(int(ledColor),string1) ledColor = RED yahoo_result = pywapi.get_weather_from_yahoo('10001') string2 = "Yahoo says: It is " + string.lower(yahoo_result['condition']['text']) + " and " + yahoo_result['condition']['temp'] + "C now in New York." textScroll(int(ledColor),string2) print "Weather.com says: It is " + string.lower(weather_com_result['current_conditions']['text']) + " and " + weather_com_result['current_conditions']['temperature'] + "C now in New York.\n\n" print "Yahoo says: It is " + string.lower(yahoo_result['condition']['text']) + " and " + yahoo_result['condition']['temp'] + "C now in New York.\n\n"
results - The result of the PostUpdate call. """ #Initialize flag, stringify status, and get a list of tweets from your account status = str(status) feed = api.GetUserTimeline("rationalWeather") #For the tweet in the feed for tweet in feed: #If this tweet is a duplicate if status == tweet.text: #Destroy that tweet api.DestroyStatus(tweet.id) #Post the status and return the results return api.PostUpdate(status, in_reply_tweet) location = pywapi.get_location_ids('Ames, Iowa') #print location weather = pywapi.get_weather_from_yahoo('50011', '') windchill = weather['wind'] weather = weather['condition'] #removed loop because it was not working exactly like I thought it was. #if it's cold outside, choose from the windChill list, else, choose from the normal list if windchill['chill'] <= '20': currentCondition = random.choice(windChill[weather[u'code']]) else: currentCondition = random.choice(weatherCodes[weather[u'code']]) print currentCondition
def Src(self): global text global temp global loc global time global hum global day1 global day1Temp global day1Hum global day1Text global day2 global day2Temp global day2Hum global day2Text global day3 global day3Temp global day3Hum global day3Text global day4 global day4Temp global day4Hum global day4Text global day5 global day5Temp global day5Hum global day5Text try: text = self.line.text() location_info = pywapi.get_location_ids(text) for i in location_info: location_id = i for i in location_info.values(): loc = i print(location_id, loc) except: self.text.hide() self.time.hide() self.pic.hide() self.temp.hide() self.loc.hide() self.hum.hide() self.error.show() self.first.hide() self.firstTemp.hide() self.firstHum.hide() self.firstText.hide() self.sec.hide() self.secTemp.hide() self.secHum.hide() self.secText.hide() self.three.hide() self.threeTemp.hide() self.threeHum.hide() self.threeText.hide() self.four.hide() self.fourTemp.hide() self.fourHum.hide() self.fourText.hide() self.five.hide() self.fiveTemp.hide() self.fiveHum.hide() self.fiveText.hide() weather_com_result = pywapi.get_weather_from_weather_com(location_id) print(weather_com_result['current_conditions']['text'], weather_com_result['current_conditions']['temperature'] + " ", weather_com_result['current_conditions']['last_updated'], weather_com_result["current_conditions"]["humidity"]) text = weather_com_result['current_conditions']['text'] temp = weather_com_result['current_conditions']['temperature'] + "C" time = "last updated " + weather_com_result['current_conditions'][ 'last_updated'] hum = " " + weather_com_result['current_conditions']['humidity'] + "%" day1 = weather_com_result['forecasts'][0][ 'day_of_week'] + " " + weather_com_result['forecasts'][0]['date'] day1Temp = weather_com_result['forecasts'][0][ 'high'] + "/" + weather_com_result['forecasts'][0]['low'] day1Hum = " " + weather_com_result['forecasts'][0]['day'][ 'humidity'] + "%" day1Text = weather_com_result['forecasts'][0]['day']['text'] day2 = weather_com_result['forecasts'][1][ 'day_of_week'] + " " + weather_com_result['forecasts'][1]['date'] day2Temp = weather_com_result['forecasts'][1][ 'high'] + "/" + weather_com_result['forecasts'][1]['low'] day2Hum = " " + weather_com_result['forecasts'][1]['day'][ 'humidity'] + "%" day2Text = weather_com_result['forecasts'][1]['day']['text'] day3 = weather_com_result['forecasts'][2][ 'day_of_week'] + " " + weather_com_result['forecasts'][2]['date'] day3Temp = weather_com_result['forecasts'][2][ 'high'] + "/" + weather_com_result['forecasts'][2]['low'] day3Hum = " " + weather_com_result['forecasts'][2]['day'][ 'humidity'] + "%" day3Text = weather_com_result['forecasts'][2]['day']['text'] day4 = weather_com_result['forecasts'][3][ 'day_of_week'] + " " + weather_com_result['forecasts'][3]['date'] day4Temp = weather_com_result['forecasts'][3][ 'high'] + "/" + weather_com_result['forecasts'][3]['low'] day4Hum = " " + weather_com_result['forecasts'][3]['day'][ 'humidity'] + "%" day4Text = weather_com_result['forecasts'][3]['day']['text'] day5 = weather_com_result['forecasts'][4][ 'day_of_week'] + " " + weather_com_result['forecasts'][4]['date'] day5Temp = weather_com_result['forecasts'][4][ 'high'] + "/" + weather_com_result['forecasts'][4]['low'] day5Hum = " " + weather_com_result['forecasts'][4]['day'][ 'humidity'] + "%" day5Text = weather_com_result['forecasts'][4]['day']['text'] self.Forecast()
#!/usr/bin/env python3 import pywapi #city = input("Enter city name: ") location = pywapi.get_location_ids('astoria') for i in location: location_id = i weather = pywapi.get_weather_from_weather_com(location_id, 'imperial') print weather
import pywapi import pprint pp = pprint.PrettyPrinter(indent=4) # set up pretty printer object pp.pprint(pywapi.get_location_ids("Sacramento"))
def weather(): """ get weather and stuff """ if text.lower().find("!weather") != -1: # gets the weather for a given location try: string = text[text.lower().rfind("!w") :] location = string[string.find(" ") + 1 :].rstrip("\n") # location = " ".join(text.split()[4:]) lookup = pywapi.get_location_ids(location) for i in lookup: location_id = i weather_com_result = pywapi.get_weather_from_weather_com(location_id) temperature = weather_com_result["current_conditions"]["temperature"] weather_text = weather_com_result["current_conditions"]["text"] wind_direction = weather_com_result["current_conditions"]["wind"]["text"] wind_speed = weather_com_result["current_conditions"]["wind"]["speed"] place = weather_com_result["location"]["name"] sendmsg( place + " | " + weather_text + " | " + temperature + " C | " + wind_speed + " km/h " + wind_direction + " wind" ) except: sendmsg(error) if text.lower().find("!moon") != -1: # gets the current moonphase try: location = "new york" lookup = pywapi.get_location_ids(location) for i in lookup: location_id = i weather_com_result = pywapi.get_weather_from_weather_com(location_id) moon = weather_com_result["current_conditions"]["moon_phase"]["text"] if moon.lower() == "new": moon += " | " + "\x031,0" + u"\U0001F311" elif moon.lower() == "new moon": moon += " | " + "\x031,0" + u"\U0001F311" elif moon.lower() == "waxing crescent": moon += " | " + "\x031,0" + u"\U0001F312" elif moon.lower() == "first quarter": moon += " | " + "\x031,0" + u"\U0001F313" elif moon.lower() == "waxing gibbous": moon += " | " + "\x031,0" + u"\U0001F314" elif moon.lower() == "full moon": moon += " | " + "\x031,0" + u"\U0001F315" elif moon.lower() == "waning gibbous": moon += " | " + "\x031,0" + u"\U0001F316" elif moon.lower() == "last quarter": moon += " | " + "\x031,0" + u"\U0001F317" elif moon.lower() == "waning crescent": moon += " | " + "\x031,0" + u"\U0001F318" sendmsg(unicode(moon).encode("utf-8", "ignore")) except: sendmsg(error)
import pywapi city = raw_input("Enter the city to check forecast: ") lookup = pywapi.get_location_ids(city) for i in lookup: location_id = i weather_com_result = pywapi.get_weather_from_weather_com(location_id) print "Weather for %s is %s degree celcius " % ( str(city), str(weather_com_result['current_conditions']['temperature']))