Example #1
0
 def do_umbrella(self, s):
     """If you're leaving your place, Jarvis will inform you if you might need an umbrella or not"""
     s = 'umbrella'
     try:
         weather_pinpoint.main(MEMORY, self, s)
     except ConnectionError:
         print(CONNECTION_ERROR_MSG)
Example #2
0
def do_weather(self, s):
    """Get information about today's weather in your current location."""
    self = self._jarvis

    word = s.strip()
    if(len(word) > 1):
        weatherIn.main(self, s)
    else:
        weather_pinpoint.main(self.memory, self, s)
Example #3
0
def do_weather(self, s):
    """Get information about today's weather in your current location."""
    self = self._jarvis

    word = s.strip()
    if (len(word) > 1):
        weatherIn.main(self, s)
    else:
        weather_pinpoint.main(self.memory, self, s)
Example #4
0
 def do_weather(self, s):
     """Get information about today's weather."""
     try:
         word = s.strip()
         if (len(word) > 1):
             weatherIn.main(self, s)
         else:
             weather_pinpoint.main(self.memory, self, s)
     except ConnectionError:
         print(CONNECTION_ERROR_MSG)
Example #5
0
def main(self, s):
    # Trim input command to get only the location
    loc = s.replace('weather', '').replace('in ', '').strip()

    # Checks country
    country = mapps.get_location()['country_name']

    # If country is US, shows weather in Fahrenheit
    if country == 'United States':
        send_url = ("http://api.openweathermap.org/data/2.5/weather?q={0}"
                    "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=imperial".
                    format(loc))
        unit = ' ºF in '

    # If country is not US, shows weather in Celsius
    else:
        send_url = (
            "http://api.openweathermap.org/data/2.5/weather?q={0}"
            "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=metric".format(loc))
        unit = ' ºC in '
    r = requests.get(send_url)
    j = json.loads(r.text)

    if 'message' in j.keys() and ('city not found' in j['message']
                                  or 'Nothing to geocode' in j['message']):
        return pinpoint.main(Memory(), self, s)

    temperature = j['main']['temp']
    description = j['weather'][0]['main']
    location = j['name']
    print(Fore.BLUE + "It's " + str(temperature) + unit +
          str(location.title()) + " (" + str(description) + ")" + Fore.RESET)
Example #6
0
def main(self, s):
    # Trim input command to get only the location
    loc = s.replace(
        'weather',
        '').replace(
        'in ',
        '').replace(
            'at ',
        '').strip()

    # Checks country
    country = mapps.get_location()['country_name']

    # If country is US, shows weather in Fahrenheit
    if country == 'United States':
        send_url = (
            "http://api.openweathermap.org/data/2.5/weather?q={0}"
            "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=imperial".format(
                loc)
        )
        unit = ' ºF in '

    # If country is not US, shows weather in Celsius
    else:
        send_url = (
            "http://api.openweathermap.org/data/2.5/weather?q={0}"
            "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=metric".format(loc)
        )
        unit = ' ºC in '
    r = requests.get(send_url)
    j = json.loads(r.text)

    if 'message' in list(
            j.keys()) and (
            'city not found' in j['message'] or 'Nothing to geocode' in j['message']):
        print("Location invalid. Please be more specific")
        return pinpoint.main(Memory(), self, s)

    temperature = j['main']['temp']
    description = j['weather'][0]['main']
    location = j['name']
    print("{COLOR}It's {TEMP}{UNIT}{LOCATION} ({DESCRIPTION}){COLOR_RESET}"
          .format(COLOR=Fore.BLUE, COLOR_RESET=Fore.RESET,
                  TEMP=temperature, UNIT=unit, LOCATION=location.title(),
                  DESCRIPTION=description))
Example #7
0
def main(self, s):
    # Trim input command to get only the location
    loc = s.replace('weather', '').replace('in ', '').replace('at ',
                                                              '').strip()

    # Checks country
    country = mapps.get_location()['country_name']

    # If country is US, shows weather in Fahrenheit
    if country == 'United States':
        send_url = ("http://api.openweathermap.org/data/2.5/weather?q={0}"
                    "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=imperial".
                    format(loc))
        unit = ' ºF in '

    # If country is not US, shows weather in Celsius
    else:
        send_url = (
            "http://api.openweathermap.org/data/2.5/weather?q={0}"
            "&APPID=ab6ec687d641ced80cc0c935f9dd8ac9&units=metric".format(loc))
        unit = ' ºC in '
    r = requests.get(send_url)
    j = json.loads(r.text)

    if 'message' in list(j.keys()) and ('city not found' in j['message'] or
                                        'Nothing to geocode' in j['message']):
        print("Location invalid. Please be more specific")
        return pinpoint.main(Memory(), self, s)

    temperature = j['main']['temp']
    description = j['weather'][0]['main']
    location = j['name']
    print("{COLOR}It's {TEMP}{UNIT}{LOCATION} ({DESCRIPTION}){COLOR_RESET}".
          format(COLOR=Fore.BLUE,
                 COLOR_RESET=Fore.RESET,
                 TEMP=temperature,
                 UNIT=unit,
                 LOCATION=location.title(),
                 DESCRIPTION=description))
Example #8
0
 def do_weather(self, s):
     """Get information about today's weather."""
     try:
         weather_pinpoint.main(MEMORY, self, s)
     except ConnectionError:
         print(CONNECTION_ERROR_MSG)
Example #9
0
def do_umbrella(self, s):
    """will inform you if you might need an umbrella or not."""
    self = self._jarvis

    s = 'umbrella'
    weather_pinpoint.main(self.memory, self, s)
Example #10
0
def do_umbrella(self, s):
    """If you're leaving your place, Jarvis will inform you if you might need an umbrella or not."""
    self = self._jarvis

    s = 'umbrella'
    weather_pinpoint.main(self.memory, self, s)
Example #11
0
 def do_weather(self, s):
     """Get information about today's weather."""
     weather_pinpoint.main(MEMORY, self)
Example #12
0
 def do_umbrella(self, s):
     """If you're leaving your place, Jarvis will inform you if you might need an umbrella or not"""
     s = 'umbrella'
     weather_pinpoint.main(MEMORY, self, s)
Example #13
0
def do_umbrella(self, s):
    """If you're leaving your place, Jarvis will inform you if you might need an umbrella or not."""
    self = self._jarvis

    s = 'umbrella'
    weather_pinpoint.main(self.memory, self, s)