示例#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)
示例#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)
示例#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)
示例#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)
示例#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)
示例#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))
示例#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))
示例#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)
示例#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)
示例#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)
示例#11
0
 def do_weather(self, s):
     """Get information about today's weather."""
     weather_pinpoint.main(MEMORY, self)
示例#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)
示例#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)