CodeFurther v 0.1.0.dev9 Released

The good news is that the latest version of CodeFurther has been pushed to PyPI. Please be aware that it is not yet ready to be used in anger in the classroom, as I need to get much more feedback. That said, I am looking for a small number of educators that know Python, who would be willing to use in a controlled fashion, and provide feedback.

The bad, well, the less good news is that the documentation and test cases haven’t been updated to reflect the many changes.

New Data Sources

In this release I’ve added another two data sources:

Weather forecasts

Python

1

2

3

4

5

6

7

8

9

fromcodefurther.weather importWeather

forecast=Weather()

tomorrows_weather=forecast.tomorrow(

"Winchester, UK"

)

print(tomorrows_weather)

Football Data

Python

1

2

3

4

5

6

7

fromcodefurther.football importpremier_league

forline inpremier_league.league_headings:

print(line)

forleague_entry inpremier_league.league_table:

print(league_entry)

New Ways to Share Information

This version of CodeFurther now makes it easy to share information socially. Note there are some setup requirements in order to get these to work. See here.

Twitter

Python

1

2

3

4

5

6

7

8

9

10

11

fromcodefurther.weather importWeather

fromcodefurther.twitter importTwitter

weather_getter=Weather()

tweeter=Twitter()

tomorrows_forecast=weather_getter.tomorrow('Winchester, UK')

tweeter.tweet(

str(tomorrows_forecast)

)

Email

Python

1

2

3

4

5

6

7

8

9

10

11

12

13

14

fromcodefurther.weather importWeather

fromcodefurther.emailimportEmail

weather_getter=Weather()

emailer=Email()

tomorrows_forecast=weather_getter.tomorrow('Winchester, UK')

emailer.send(

'cherbourg.code.club@gmail.com',

'danny@codefurther.org',

"Here is tomorrow's weather forecast",

str(tomorrows_forecast)

)

SMS Text Message

Python

1

2

3

4

5

6

7

8

9

10

11

12

fromcodefurther.weather importWeather

fromcodefurther.textmessage importTextMessage

weather_getter=Weather()

texter=TextMessage()

tomorrows_forecast=weather_getter.tomorrow('Winchester, UK')

texter.send(

'07795 054500',

str(tomorrows_forecast)

)

Messages via Slack.com

Python

1

2

3

4

5

6

7

8

9

10

11

12

fromcodefurther.weather importWeather

fromcodefurther.slack importSlack

weather_getter=Weather()

slacker=Slack()

tomorrows_forecast=weather_getter.tomorrow('Winchester, UK')

slacker.post_message(

str(tomorrows_forecast),

'#general'

)

Configuration Settings

The weather forecast data sources and all of the new ways to share data require configuration values to be set. There are two ways to achieve this.

cf_settings.py file

Create a cf_settings.py file and add the following (case sensitive) variables to it.

Python

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

CF_TWITTER_APP_KEY='***************************'

CF_TWITTER_APP_SECRET='***************************'

CF_TWITTER_OAUTH_TOKEN='***************************'

CF_TWITTER_OAUTH_TOKEN_SECRET='***************************'

CF_SLACK_API_KEY='***************************'

CF_SMTP_SERVER='***************************'

CF_SMTP_PORT=000

CF_SMTP_USERNAME='***************************'

CF_SMTP_PASSWORD='***************************'

CF_TWILIO_ACCOUNT='***************************'

CF_TWILIO_TOKEN='***************************'

CF_TWILIO_FROM='***************************'

CF_FORECASTIO_API_KEY='***************************'

CodeFurther will look for this file in the following locations:

The current working directory

The user configuration directory – e.g. on Windows this might be C:\Users\USERNAME\AppData\Local\codefurther\codefurther.

Environment Variables

Set an environment variable that corresponds to the Python variable in cf_settings.py above. This will override any settings found in the cf_settings.py file.

Encryption of Settings

So that raw settings are never visible to anyone, the settings (except numeric settings) are encrypted using a simple rot_13 rotational cypher. You can set encrypted passwords using a helper function from the CodeFurther package like this.