From efee61964c7b288902a43372953a4d5de0b62947 Mon Sep 17 00:00:00 2001 From: Brian Mitchell Date: Fri, 4 Jan 2019 22:58:55 -0600 Subject: [PATCH 1/7] Update deps --- requirements-dev.txt | 10 +++++----- requirements.txt | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index fad0f59..3ef31e3 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ -testfixtures>=6.0.1,<7.0 -invoke>=0.22.1,<1.0 -pylint>=1.8.4,<2.0 -yamllint>=1.11.1,<2.0 -coverage>=4.5.1,<5.0 \ No newline at end of file +testfixtures>=6.4.1,<7 +invoke>=1.2.0,<2 +pylint>=2.2.2,<3 +yamllint>=1.13.0,<2 +coverage>=4.5.2,<5 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 8204798..8576f40 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -tweepy>=3.6.0,<4.0 -python-forecastio>=1.4.0,<2.0 -pytz>=2018.4 -PyYAML>=3.12,<4.0 \ No newline at end of file +tweepy>=3.7.0,<4 +python-forecastio>=1.4.0,<2 +pytz>=2018.7 +PyYAML>=4.2b4,<5 \ No newline at end of file From 4343ebd65e32761d4d9558a48b75b5b790724551 Mon Sep 17 00:00:00 2001 From: Brian Mitchell Date: Fri, 4 Jan 2019 23:00:06 -0600 Subject: [PATCH 2/7] Linting from newly added pylint checks --- keys.py | 8 ++++---- models.py | 1 - utils.py | 11 +++++------ weatherBot.py | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/keys.py b/keys.py index b5d5eab..263da9b 100644 --- a/keys.py +++ b/keys.py @@ -19,10 +19,10 @@ def set_twitter_env_vars(): """ - If no Twitter environmental variables are set, set them based on the keys dict + If any of the Twitter environmental variables are not set, set them based on the keys dict """ - if os.getenv('WEATHERBOT_CONSUMER_KEY', 0) is 0 or os.getenv('WEATHERBOT_CONSUMER_SECRET', 0) is 0 \ - or os.getenv('WEATHERBOT_ACCESS_TOKEN', 0) is 0 or os.getenv('WEATHERBOT_ACCESS_TOKEN_SECRET', 0) is 0: + if os.getenv('WEATHERBOT_CONSUMER_KEY') is None or os.getenv('WEATHERBOT_CONSUMER_SECRET') is None \ + or os.getenv('WEATHERBOT_ACCESS_TOKEN') is None or os.getenv('WEATHERBOT_ACCESS_TOKEN_SECRET') is None: os.environ['WEATHERBOT_CONSUMER_KEY'] = KEYS['consumer_key'] os.environ['WEATHERBOT_CONSUMER_SECRET'] = KEYS['consumer_secret'] os.environ['WEATHERBOT_ACCESS_TOKEN'] = KEYS['access_token'] @@ -33,5 +33,5 @@ def set_darksky_env_vars(): """ If no Dark Sky environmental variable is set, set it based on the keys dict """ - if os.getenv('WEATHERBOT_DARKSKY_KEY', 0) is 0: + if os.getenv('WEATHERBOT_DARKSKY_KEY') is None: os.environ['WEATHERBOT_DARKSKY_KEY'] = KEYS['darksky_key'] diff --git a/models.py b/models.py index 308b672..a5688ff 100644 --- a/models.py +++ b/models.py @@ -23,7 +23,6 @@ class BadForecastDataError(Exception): """ Designed to be thrown when a Forecast object contains issues that would render the weather data unusable """ - pass class WeatherLocation: diff --git a/utils.py b/utils.py index 2a928c2..0b9cd1b 100644 --- a/utils.py +++ b/utils.py @@ -14,7 +14,6 @@ class InvalidTimeError(Exception): """Designed to be thrown when parsing a bad str for creating a Time namedtuple""" - pass def get_units(unit): @@ -40,7 +39,7 @@ def get_units(unit): 'pressure': 'mb', 'visibility': 'mi' } - elif unit == 'ca': + if unit == 'ca': return { 'unit': 'ca', 'nearestStormDistance': 'km', @@ -56,7 +55,7 @@ def get_units(unit): 'pressure': 'hPa', 'visibility': 'km' } - elif unit == 'uk2': + if unit == 'uk2': return { 'unit': 'uk2', 'nearestStormDistance': 'mi', @@ -195,11 +194,11 @@ def precipitation_intensity(precip_intensity, unit): if precip_intensity >= intensities[unit]['heavy'][1]: return intensities[unit]['heavy'][0] - elif precip_intensity >= intensities[unit]['moderate'][1]: + if precip_intensity >= intensities[unit]['moderate'][1]: return intensities[unit]['moderate'][0] - elif precip_intensity >= intensities[unit]['light'][1]: + if precip_intensity >= intensities[unit]['light'][1]: return intensities[unit]['light'][0] - elif precip_intensity >= intensities[unit]['very-light'][1]: + if precip_intensity >= intensities[unit]['very-light'][1]: return intensities[unit]['very-light'][0] return 'none' diff --git a/weatherBot.py b/weatherBot.py index 1e9c724..7b6d9b1 100755 --- a/weatherBot.py +++ b/weatherBot.py @@ -186,7 +186,7 @@ def get_location_from_user_timeline(username, fallback): logging.debug('Found %s: %f, %f', name, lat, lng) return models.WeatherLocation(lat=lat, lng=lng, name=name) # if the location is a place, not coordinates - elif tweet.place is not None: + if tweet.place is not None: point = utils.centerpoint(tweet.place.bounding_box.coordinates[0]) lat = point[0] lng = point[1] From 02aeb9ed19b75c31aebfb8e7216772ddc5d5bf0a Mon Sep 17 00:00:00 2001 From: Brian Mitchell Date: Fri, 4 Jan 2019 23:00:24 -0600 Subject: [PATCH 3/7] Run travis on python 3.7 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ff0c563..1fb62aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ python: - '3.4' - '3.5' - '3.6' +- '3.7' install: - pip install -r requirements.txt - pip install -r requirements-dev.txt From 46096a8e7e69bdc92dc048b8133c64895aea6fa4 Mon Sep 17 00:00:00 2001 From: Brian Mitchell Date: Fri, 4 Jan 2019 23:01:59 -0600 Subject: [PATCH 4/7] Increment copyright dates Is this even a thing I should be doing? --- keys.py | 2 +- models.py | 2 +- test.py | 2 +- utils.py | 2 +- weatherBot.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/keys.py b/keys.py index 263da9b..9903f96 100644 --- a/keys.py +++ b/keys.py @@ -1,7 +1,7 @@ """ weatherBot keys -Copyright 2015-2018 Brian Mitchell under the MIT license +Copyright 2015-2019 Brian Mitchell under the MIT license See the GitHub repository: https://github.com/BrianMitchL/weatherBot """ diff --git a/models.py b/models.py index a5688ff..b3face3 100644 --- a/models.py +++ b/models.py @@ -1,7 +1,7 @@ """ weatherBot models -Copyright 2015-2018 Brian Mitchell under the MIT license +Copyright 2015-2019 Brian Mitchell under the MIT license See the GitHub repository: https://github.com/BrianMitchL/weatherBot """ diff --git a/test.py b/test.py index 5371c24..77fc6cb 100644 --- a/test.py +++ b/test.py @@ -3,7 +3,7 @@ """ weatherBot tests -Copyright 2015-2018 Brian Mitchell under the MIT license +Copyright 2015-2019 Brian Mitchell under the MIT license See the GitHub repository: https://github.com/BrianMitchL/weatherBot """ diff --git a/utils.py b/utils.py index 0b9cd1b..d657019 100644 --- a/utils.py +++ b/utils.py @@ -1,7 +1,7 @@ """ weatherBot utils -Copyright 2015-2018 Brian Mitchell under the MIT license +Copyright 2015-2019 Brian Mitchell under the MIT license See the GitHub repository: https://github.com/BrianMitchL/weatherBot """ diff --git a/weatherBot.py b/weatherBot.py index 7b6d9b1..5b05753 100755 --- a/weatherBot.py +++ b/weatherBot.py @@ -3,7 +3,7 @@ """ weatherBot -Copyright 2015-2018 Brian Mitchell under the MIT license +Copyright 2015-2019 Brian Mitchell under the MIT license See the GitHub repository: https://github.com/BrianMitchL/weatherBot """ # pylint: disable=global-statement,invalid-name From 0608da469006f4ffc9ce1ed20a834aba8d2ec053 Mon Sep 17 00:00:00 2001 From: Brian Mitchell Date: Fri, 4 Jan 2019 23:16:10 -0600 Subject: [PATCH 5/7] Add docs for invoke commands Remove gemnasium badge --- README.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a367ed..027de28 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# weatherBot [![GitHub release](https://img.shields.io/github/release/BrianMitchL/weatherBot.svg?maxAge=86400)](https://github.com/BrianMitchL/weatherBot/releases/latest) [![Python Version](https://img.shields.io/badge/python-3.4+-blue.svg)](https://www.python.org) [![Build Status](https://travis-ci.org/BrianMitchL/weatherBot.svg?branch=master)](https://travis-ci.org/BrianMitchL/weatherBot) [![Coverage Status](https://coveralls.io/repos/github/BrianMitchL/weatherBot/badge.svg?branch=master)](https://coveralls.io/github/BrianMitchL/weatherBot?branch=master) [![Dependency Status](https://gemnasium.com/badges/github.com/BrianMitchL/weatherBot.svg)](https://gemnasium.com/github.com/BrianMitchL/weatherBot) +# weatherBot [![GitHub release](https://img.shields.io/github/release/BrianMitchL/weatherBot.svg?maxAge=86400)](https://github.com/BrianMitchL/weatherBot/releases/latest) [![Python Version](https://img.shields.io/badge/python-3.4+-blue.svg)](https://www.python.org) [![Build Status](https://travis-ci.org/BrianMitchL/weatherBot.svg?branch=master)](https://travis-ci.org/BrianMitchL/weatherBot) [![Coverage Status](https://coveralls.io/repos/github/BrianMitchL/weatherBot/badge.svg?branch=master)](https://coveralls.io/github/BrianMitchL/weatherBot?branch=master) A Twitter bot for weather. [Powered by Dark Sky](https://darksky.net/poweredby/). @@ -112,6 +112,56 @@ docker build -t weatherbot . ``` Start the bot using the same run command as above, while replacing the image name with what you call yours. +## Task Runner + +The following tasks are available through `invoke`. + +- `invoke lint` +```text +Docstring: + Use PyLint to check for errors and enforce a coding standard. + This will, by default, use the PyLint configuration found in '.pylintrc', + but can accept a different path. + +Options: + -e STRING, --extra=STRING Extra Python files to lint in addition to the + default. + -p STRING, --pylintrc=STRING Path to a pylintrc file for configuring + PyLint. + +``` +- `invoke clean` +```text +Docstring: + Clean (delete) files. If passed with no arguments, nothing is deleted. + +Options: + -b, --bytecode Remove bytecode files matching the pattern + '**/*.pyc'. + -c, --cache Remove the '.wbcache.p' file. + -e STRING, --extra=STRING Remove any extra files passed in here. +``` +- `invoke validateyaml` +```text +Docstring: + Use yamllint to check for errors and enforce a markup standard for the strings YAML file. + By default this will use the '.yamllint' config file to validate 'strings.yml'. + +Options: + -f STRING, --filename=STRING Path to the strings YAML file to validate. + -y STRING, --yamllintrc=STRING Path to a yamllintrc file for configuring + PyLint. +``` +- `invoke test` +```text +Docstring: + Runs tests and reports on code coverage. + Keys need to be entered in 'keys.py' or set as environmental variables. + +Options: + -r, --report Flag to print a coverage report +``` + ## Tools Used * [Tweepy](https://github.com/tweepy/tweepy) * [Dark Sky API](https://darksky.net/poweredby/) From 4825b8204e8f3d37a9e7086c74dd5fc1bb7e3c5b Mon Sep 17 00:00:00 2001 From: Brian Mitchell Date: Fri, 4 Jan 2019 23:45:42 -0600 Subject: [PATCH 6/7] Upgrade travis to xenial --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1fb62aa..3b396e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +dist: xenial language: python python: - '3.4' From 02c7b60c535a1cde4b14206de8f3d5fe86e83f39 Mon Sep 17 00:00:00 2001 From: Brian Mitchell Date: Sat, 5 Jan 2019 15:01:25 -0600 Subject: [PATCH 7/7] Add some new strings --- strings.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/strings.yml b/strings.yml index 8ce41f9..7d37b14 100644 --- a/strings.yml +++ b/strings.yml @@ -33,6 +33,8 @@ forecast_endings: - "\U0001f44c" - "\U0001f4af" - "\U0001f44c\U0001f4af" + - "It's going to be great!" + - "Oh joy \U0001f644" # use 'temp', 'summary', or 'location' normal_conditions: - "{temp} and {summary}. \U0001f937" @@ -64,12 +66,21 @@ normal_conditions: - "Only in {location} would it be {temp} and {summary} right now." - "I hope you like that it's {summary}. It's {temp}." - "{summary} and {temp}. \U0001f4af\U0001f4af\U0001f4af" + - "My word, it's {summary} and {temp}." + - "It's {summary} and {temp}. Don't forget to like, comment, and subscribe." + - "Can you believe it's {temp} and {summary}?" + - "It's {summary} and {temp}. Cheers, mate." + - "It's {temp} and {summary}. Finally!" + - "Good grief, it's {temp} and {summary}." # use 'apparent_temp', 'temp', 'wind_speed', 'wind_bearing', 'humidity', # 'summary', or 'location' special_conditions: wind-chill: # wind chill at or below -30F or -34C - "Brr! The windchill is {apparent_temp} and the wind is blowing at {wind_speed} from the {wind_bearing}. Stay safe out there!" + - "Even though it feels like {apparent_temp}, it's actually only {temp}." + - "It's cold out there! The windchill is {apparent_temp} and the wind is blowing at + {wind_speed} from the {wind_bearing}." medium-wind: - "Looks like we've got some medium wind at {wind_speed} coming from the {wind_bearing}." @@ -86,12 +97,16 @@ special_conditions: cold: # below -28C or -20F - "It's {temp}. Too cold." - "It's a wee bit chilly. {temp} \U0001f643" + - "Stupid polar vortex making things all cold, it's {temp}!" + - "It's {temp}. Just put a hat on, you'll be fine." super-hot: # over 110F or 43C - "Wowowowowowowowow, it's {temp}. I need some A/C ASAP." - "\U0001f525\U0001f525\U0001f525 \U0001f635" hot: # over 100F or 37C - "Holy moly it's {temp}. I could literally (figuratively) melt." - "\U0001f321 It's {temp}!" + - "We did it, it's {temp}!" + - "High five for climate change! It's {temp}." dry: # humidity under 25% - "{temp} with {humidity}% humidity." - "It's dry as strained pasta. {humidity}% humid right now." @@ -119,13 +134,16 @@ precipitations: - "Light rain. \U0001f326" - "Light rain. Just think how hydrated all of the plants will be!" - "Light rain? More like free car wash!" + - "Light rain. At least it's not snowing." very-light: - "Drizzlin' yo." - "Very light rain detected." + - "Hey look, it's drizzling!" snow: heavy: - "Heavy snow, bundle up." - "Heavy snow detected, good luck with that." + - "Look at the snow, there's so much of it!" moderate: - "Alert: there are flakes of crystalline water ice falling from the clouds." @@ -141,6 +159,7 @@ precipitations: very-light: - "Flurries" - "Flurries detected." + - "Hey look, flurries!" sleet: heavy: - "Heavy sleet."