Add old project to repo.

This commit is contained in:
Hyperling 2025-04-25 05:59:42 -07:00
parent 4592eb7b7d
commit df39fd1a0e
69 changed files with 1103 additions and 0 deletions

0
Buddy/Buddy/Buddy/__init__.py Executable file
View File

121
Buddy/Buddy/Buddy/settings.py Executable file
View File

@ -0,0 +1,121 @@
"""
Django settings for Buddy project.
Generated by 'django-admin startproject' using Django 2.1.4.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'p)@=f5#gy2+2^14&qy-gg968cu29*b7gbccs*!08jtbc28^f%-'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
#ALLOWED_HOSTS = ['192.168.1.67','.hyperling.com']
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'Buddy.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'Buddy.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'

24
Buddy/Buddy/Buddy/urls.py Executable file
View File

@ -0,0 +1,24 @@
"""Buddy URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('walk/', include('walk.urls')),
path('thanks/', include('thanks.urls')),
path('forecast/', include('forecast.urls')),
path('admin/', admin.site.urls),
]

16
Buddy/Buddy/Buddy/wsgi.py Executable file
View File

@ -0,0 +1,16 @@
"""
WSGI config for Buddy project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Buddy.settings')
application = get_wsgi_application()

View File

3
Buddy/Buddy/forecast/admin.py Executable file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
Buddy/Buddy/forecast/apps.py Executable file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class ForecastConfig(AppConfig):
name = 'forecast'

View File

3
Buddy/Buddy/forecast/models.py Executable file
View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
Buddy/Buddy/forecast/tests.py Executable file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
Buddy/Buddy/forecast/urls.py Executable file
View File

@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]

154
Buddy/Buddy/forecast/views.py Executable file
View File

@ -0,0 +1,154 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import requests, json, math, time
@csrf_exempt
def index(request):
# Get Zip code from request
print("Request=")
print(request)
print("Request body=")
print(request.body)
# Get weather string - ZIP is ignored for now
print("Getting weather...")
weather_string = getWeather(47715)
print("Creating payload...")
payload = { 'response_type': "in_channel", 'text': weather_string }
print("payload=")
print(payload)
print("dumps(payload)=")
print(json.dumps(payload))
print("Returning payload...")
return HttpResponse(json.dumps(payload), content_type='application/json')
## Function to call Weather API ##
def getWeather(zip_code):
## Get request ##
resp = requests.get("http://api.openweathermap.org/data/2.5/forecast?zip=" + str(zip_code) + ",us&units=imperial&APPID=ecf63d9fa178fca8a4ab21b49e9bb456")
if resp.status_code != 200:
# This means something went wrong.
raise ApiError('GET OpenWeatherMap {}'.format(resp.status_code))
response = resp.json()
forecasts = response['list']
city = response['city']
location = city['name']
output = ""
#for forecast in forecasts:
# range() = start#, stop_before, #steps
for forecast_id in range(0, 16):
forecast = forecasts[forecast_id]
## Get data from forecast ##
#location = forecast['name']
#location = str(zip_code)
weather = forecast['weather']
weather = weather[0]
weather_main = weather['main']
weather_desc = weather['description']
main = forecast['main']
temp = main['temp']
humidity = main['humidity']
wind = forecast['wind']
wind_speed = wind['speed']
cal_date = forecast['dt_txt']
cal_date = int(cal_date[8:-9])
curr_date = int(time.strftime("%d"))
cal_day = ""
if cal_date == curr_date:
cal_day = "Today"
elif cal_date == curr_date + 1 or cal_date == 1:
cal_day = "Tomorrow"
# elif cal_date == curr_date + 2 or cal_date == 1 or cal_date == 2:
# cal_day = "The day after tomorrow"
else:
continue
time_of_day = forecast['dt_txt']
time_of_day = int(time_of_day[11:-6])
time_ext = "AM"
if time_of_day - 12 >= 0:
time_of_day = time_of_day - 12
time_ext = "PM"
time_of_day = str(time_of_day) + time_ext
if time_of_day == "0PM":
time_of_day = "noon"
if time_of_day == "0AM":
time_of_day = "midnight"
cal_day = "Tonight"
# Asked for Imperial units in API request
temp_units = 'F'
wind_units = 'mph'
humidity_units = '%'
## Wind Chill ##
# Wind speed as noted in: https://answers.yahoo.com/question/index?qid=20091020183148AAHm3kB&guccounter=1
# More official source: https://www.weather.gov/media/epz/wxcalc/windChill.pdf
wind_chill = 35.74 + (0.6215 * temp) - (35.75 * (wind_speed**0.16)) + (0.4275 * temp * wind_speed**0.16)
## Heat Index ##
# Official formula: https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
heat_index = -42.379 + 2.04901523*temp + 10.14333127*humidity - 0.22475541*temp*humidity - 0.00683783*temp*temp - 0.05481717*humidity*humidity + 0.00122874*temp*temp*humidity + 0.00085282*temp*humidity*humidity - 0.00000199*temp*temp*humidity*humidity
if humidity < 13 and temp >= 80 and temp <= 112:
heat_index -= ((13-humidity)/4)*math.sqrt((17-abs(temp-95.))/17)
if humidity > 85 and temp >= 80 and temp <= 87:
heat_index += ((humidity-85)/10) * ((87-temp)/5)
if heat_index < 80:
heat_index = 0.5 * (temp + 61.0 + ((temp-68.0)*1.2) + (humidity*0.094))
heat_index = (heat_index + temp) / 2
## Check if wind chill or heat index is applicable ##
# Rules found here under the map: https://www.mesonet.org/index.php/weather/map/wind_chill_heat_index1/air_temperature
guess = "("
wind_chill_text = ""
if temp < 50 and wind_speed > 5:
wind_chill = round(wind_chill)
wind_chill_text = guess + "Wind chill of " + str(wind_chill) + temp_units + ") "
heat_index_text = ""
if temp > 80:
heat_index = round(heat_index)
heat_index_text = guess + "Heat index of " + str(heat_index) + temp_units + ") "
## Round numbers ##
temp = round(temp)
wind_speed = round(wind_speed)
heat_index = round(heat_index)
## Add to the final string ##
output = str(output + cal_day + " at " + str(time_of_day) + " it will be " + str(temp) + temp_units + " and " + weather_main +
" with " + str(wind_speed) + wind_units + " wind and " + str(humidity) + humidity_units + " humidity" +
". " + wind_chill_text + heat_index_text + "\n")
return output

15
Buddy/Buddy/manage.py Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Buddy.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

0
Buddy/Buddy/thanks/__init__.py Executable file
View File

3
Buddy/Buddy/thanks/admin.py Executable file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
Buddy/Buddy/thanks/apps.py Executable file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class ThanksConfig(AppConfig):
name = 'thanks'

View File

3
Buddy/Buddy/thanks/models.py Executable file
View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
Buddy/Buddy/thanks/tests.py Executable file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
Buddy/Buddy/thanks/urls.py Executable file
View File

@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]

33
Buddy/Buddy/thanks/views.py Executable file
View File

@ -0,0 +1,33 @@
from django.shortcuts import render
# Create your views here.
from random import randint
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import requests, json
@csrf_exempt
def index(request):
# Get Zip code from request
print("Request=")
print(request)
print("Request body=")
print(request.body)
# Create return message
thanks_array=["No problem!", "No problem at all!", "No worries, I'm here to help!", "You're welcome!", "You're very welcome!",
"My pleasure!", ":kappa:", "It is my will to serve you, my lord.", "No probs.", "As you wish, my master.",
":+1:", ":thumbsup_all:", ":heavy_check_mark:", "Just doing my job."]
thanks_string = thanks_array[randint(0,13)]
print("Creating payload...")
payload = { 'response_type': "in_channel", 'text': thanks_string }
print("payload=")
print(payload)
print("dumps(payload)=")
print(json.dumps(payload))
print("Returning payload...")
return HttpResponse(json.dumps(payload), content_type='application/json')

0
Buddy/Buddy/walk/__init__.py Executable file
View File

3
Buddy/Buddy/walk/admin.py Executable file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
Buddy/Buddy/walk/apps.py Executable file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class WalkConfig(AppConfig):
name = 'walk'

View File

3
Buddy/Buddy/walk/models.py Executable file
View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
Buddy/Buddy/walk/tests.py Executable file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
Buddy/Buddy/walk/urls.py Executable file
View File

@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]

169
Buddy/Buddy/walk/views.py Executable file
View File

@ -0,0 +1,169 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import requests, json, math
@csrf_exempt
def index(request):
# Get Zip code from request
print("Request=")
print(request)
print("Request body=")
print(request.body)
# Get weather string - ZIP is ignored for now
print("Getting weather...")
weather_string = getWeather(47715)
print("Creating payload...")
payload = { 'response_type': "in_channel", 'text': weather_string }
print("payload=")
print(payload)
print("dumps(payload)=")
print(json.dumps(payload))
print("Returning payload...")
return HttpResponse(json.dumps(payload), content_type='application/json')
#return HttpResponse(data=weather_string, status=status.HTTP_200_OK)
#return HttpResponse(status=status.HTTP_200_OK)
#return Response(status=status.HTTP_200_OK)
print("Done returning. ;)")
def getWeather(zip_code):
## Get request ##
resp = requests.get("http://api.openweathermap.org/data/2.5/weather?zip=47715,us&units=imperial&APPID=ecf63d9fa178fca8a4ab21b49e9bb456")
if resp.status_code != 200:
# This means something went wrong.
raise ApiError('GET OpenWeatherMap {}'.format(resp.status_code))
response = resp.json()
## Get data from request ##
location = response['name']
weather = response['weather']
weather = weather[0]
weather_main = weather['main']
weather_desc = weather['description']
main = response['main']
temp = main['temp']
humidity = main['humidity']
wind = response['wind']
wind_speed = wind['speed']
# Asked for Imperial units in API request
temp_units = 'F'
wind_units = 'mph'
humidity_units = '%'
## Wind Chill ##
# Wind speed as noted in: https://answers.yahoo.com/question/index?qid=20091020183148AAHm3kB&guccounter=1
# More official source: https://www.weather.gov/media/epz/wxcalc/windChill.pdf
wind_chill = 35.74 + (0.6215 * temp) - (35.75 * (wind_speed**0.16)) + (0.4275 * temp * wind_speed**0.16)
## Heat Index ##
# Official formula: https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
heat_index = -42.379 + 2.04901523*temp + 10.14333127*humidity - 0.22475541*temp*humidity - 0.00683783*temp*temp - 0.05481717*humidity*humidity + 0.00122874*temp*temp*humidity + 0.00085282*temp*humidity*humidity - 0.00000199*temp*temp*humidity*humidity
if humidity < 13 and temp >= 80 and temp <= 112:
heat_index -= ((13-humidity)/4)*math.sqrt((17-abs(temp-95.))/17)
if humidity > 85 and temp >= 80 and temp <= 87:
heat_index += ((humidity-85)/10) * ((87-temp)/5)
if heat_index < 80:
heat_index = 0.5 * (temp + 61.0 + ((temp-68.0)*1.2) + (humidity*0.094))
heat_index = (heat_index + temp) / 2
## Check if wind chill or heat index is applicable ##
# Rules found here under the map: https://www.mesonet.org/index.php/weather/map/wind_chill_heat_index1/air_temperature
guess = "My guess is that's a "
wind_chill_text = ""
if temp < 50 and wind_speed > 5:
wind_chill = round(wind_chill)
wind_chill_text = guess + "wind chill of " + str(wind_chill) + temp_units + ". "
else:
wind_chill = temp
heat_index_text = ""
if temp > 80:
heat_index = round(heat_index)
heat_index_text = guess + "heat index of " + str(heat_index) + temp_units + ". "
else:
heat_index = temp
## Who doesn't want to go? ##
besides_default = ' (Besides'
besides = besides_default
# Formula for temp/wind speed is to make sure that if it's too windy Chad doesn't go.
# The denominator controls how powerful the wind speed is taken into account and gets bigger as it increases.
chad_hates_wind = (temp/(wind_speed*(wind_speed*0.05)))
if wind_chill <= 32 or heat_index >= 100 or chad_hates_wind < 3:
if besides != besides_default:
besides += ','
besides += ' Chad'
if (temp > 95 and humidity > 40):
if besides != besides_default:
besides += ','
besides += ' Zach'
if True:
if besides != besides_default:
besides += ','
besides += ' Dan'
if besides == besides_default:
besides = ''
else:
besides += ')'
comma_count = besides.count(',')
if comma_count == 1:
besides = besides.replace(',', ' and')
elif comma_count >= 2:
besides = besides.replace(',', '|', comma_count)
besides = besides.replace('|', ',', comma_count-1)
besides = besides.replace('|', ', and')
## Check if wind chill or heat index is applicable ##
# Rules found here under the map: https://www.mesonet.org/index.php/weather/map/wind_chill_heat_index1/air_temperature
guess = "My guess is that's a "
wind_chill_text = ""
if temp < 50 and wind_speed > 5:
wind_chill = round(wind_chill)
wind_chill_text = guess + "wind chill of " + str(wind_chill) + temp_units + ". "
heat_index_text = ""
if temp > 80:
heat_index = round(heat_index)
heat_index_text = guess + "heat index of " + str(heat_index) + temp_units + ". "
## Round numbers ##
temp = round(temp)
wind_speed = round(wind_speed)
## Build the final string ##
output = str(location + " is " + str(temp) + temp_units + " and " + weather_main +
" with a wind speed of " + str(wind_speed) + wind_units + " and humidity of " + str(humidity) + humidity_units +
". " + wind_chill_text + heat_index_text +
"Who wants to walk?" + besides)
return output

View File

@ -0,0 +1,66 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import requests, json
@csrf_exempt
def index(request):
# Get Zip code from request
print("Request=")
print(request)
print("Request body=")
print(request.body)
# Get weather string - ZIP is ignored for now
print("Getting weather...")
weather_string = getWeather(47715)
print("Creating payload...")
payload = { 'response_type': "in_channel", 'text': weather_string }
print("payload=")
print(payload)
print("dumps(payload)=")
print(json.dumps(payload))
print("Returning payload...")
return HttpResponse(json.dumps(payload), content_type='application/json')
#return HttpResponse(data=weather_string, status=status.HTTP_200_OK)
#return HttpResponse(status=status.HTTP_200_OK)
#return Response(status=status.HTTP_200_OK)
print("Done returning. ;)")
def getWeather(zip_code):
resp = requests.get("http://api.openweathermap.org/data/2.5/weather?zip=47715,us&units=imperial&APPID=ecf63d9fa178fca8a4ab21b49e9bb456")
if resp.status_code != 200:
# This means something went wrong.
raise ApiError('GET OpenWeatherMap {}'.format(resp.status_code))
response = resp.json()
location = response['name']
weather = response['weather']
weather = weather[0]
weather_main = weather['main']
weather_desc = weather['description']
main = response['main']
temp = main['temp']
humidity = main['humidity']
wind = response['wind']
wind_speed = wind['speed']
temp_units = 'F'
wind_units = 'mph'
humidity_units = '%'
output = location + " is " + str(temp) + temp_units + " and " + weather_main + " with a wind speed of " + str(wind_speed) + wind_units + " and humidity of " + str(humidity) + humidity_units + ". Who wants to walk?"
return output

View File

@ -0,0 +1,91 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import requests, json
@csrf_exempt
def index(request):
# Get Zip code from request
print("Request=")
print(request)
print("Request body=")
print(request.body)
# Get weather string - ZIP is ignored for now
print("Getting weather...")
weather_string = getWeather(47715)
print("Creating payload...")
payload = { 'response_type': "in_channel", 'text': weather_string }
print("payload=")
print(payload)
print("dumps(payload)=")
print(json.dumps(payload))
print("Returning payload...")
return HttpResponse(json.dumps(payload), content_type='application/json')
#return HttpResponse(data=weather_string, status=status.HTTP_200_OK)
#return HttpResponse(status=status.HTTP_200_OK)
#return Response(status=status.HTTP_200_OK)
print("Done returning. ;)")
def getWeather(zip_code):
resp = requests.get("http://api.openweathermap.org/data/2.5/weather?zip=47715,us&units=imperial&APPID=ecf63d9fa178fca8a4ab21b49e9bb456")
if resp.status_code != 200:
# This means something went wrong.
raise ApiError('GET OpenWeatherMap {}'.format(resp.status_code))
response = resp.json()
location = response['name']
weather = response['weather']
weather = weather[0]
weather_main = weather['main']
weather_desc = weather['description']
main = response['main']
temp = main['temp']
humidity = main['humidity']
wind = response['wind']
wind_speed = wind['speed']
temp_units = 'F'
wind_units = 'mph'
humidity_units = '%'
# Who doesn't want to go?
besides_default = ' (Besides'
besides = besides_default
if (temp < 35 and wind_speed >= 5) or (temp < 55 and wind_speed >= 10) or (temp < 65 and wind_speed >= 15):
if besides != besides_default:
besides += ','
besides += ' Chad'
if besides == besides_default:
besides = ''
else:
besides += ')'
comma_count = besides.count(',')
if comma_count == 1:
besides = besides.replace(',', ' and')
elif comma_count >= 2:
besides = besides.replace(',', '|', comma_count)
besides = besides.replace('|', ',', comma_count-1)
besides = besides.replace('|', ', and')
# Finish up and return a string
output = location + " is " + str(temp) + temp_units + " and " + weather_main + " with a wind speed of " + str(wind_speed) + wind_units + " and humidity of " + str(humidity) + humidity_units + ". Who wants to walk?" + besides
return output

68
Buddy/Buddy/walk/views.py.yahoo Executable file
View File

@ -0,0 +1,68 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
import requests, json
@csrf_exempt
def index(request):
# Get Zip code from request
print("Request=")
print(request)
print("Request body=")
print(request.body)
# Get weather string - ZIP is ignored for now
print("Getting weather...")
weather_string = getWeather(47715)
print("Creating payload...")
payload = { 'response_type': "in_channel", 'text': weather_string }
print("payload=")
print(payload)
print("dumps(payload)=")
print(json.dumps(payload))
print("Returning payload...")
return HttpResponse(json.dumps(payload), content_type='application/json')
#return HttpResponse(data=weather_string, status=status.HTTP_200_OK)
#return HttpResponse(status=status.HTTP_200_OK)
#return Response(status=status.HTTP_200_OK)
print("Done returning. ;)")
def getWeather(zip_code):
return "Sorry, Yahoo APIs are no longer easily available and I don't know of any others yet. Try looking through Cheryl's office for the weather and let us know if it's worth risking a walk."
resp = requests.get("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22Evansville%2C%20in%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys")
if resp.status_code != 200:
# This means something went wrong.
raise ApiError('GET YahooWeather {}'.format(resp.status_code))
weather = resp.json()
query = weather['query']
results = query['results']
channel = results['channel']
item = channel['item']
condition = item['condition']
location = item['title']
temp = condition['temp']
text = condition['text'].lower()
units = channel['units']
temp_units = units['temperature']
wind_units = units['speed']
wind = channel['wind']
wind_speed = wind['speed']
wind_chill = wind['chill']
output = location + " are " + temp + temp_units + " and " + text + " with a wind speed of " + wind_speed + wind_units + ", resulting in a wind chill temperature of " + wind_chill + temp_units + ". Who wants to walk?"
return output

76
Buddy/buddy/bin/activate Executable file
View File

@ -0,0 +1,76 @@
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
# reset old environment variables
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
PATH="${_OLD_VIRTUAL_PATH:-}"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r
fi
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi
unset VIRTUAL_ENV
if [ ! "$1" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}
# unset irrelevant variables
deactivate nondestructive
VIRTUAL_ENV="/root/Buddy/buddy"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
if [ -n "${PYTHONHOME:-}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
unset PYTHONHOME
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
if [ "x(buddy) " != x ] ; then
PS1="(buddy) ${PS1:-}"
else
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
fi
fi
export PS1
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r
fi

37
Buddy/buddy/bin/activate.csh Executable file
View File

@ -0,0 +1,37 @@
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate'
# Unset irrelevant variables.
deactivate nondestructive
setenv VIRTUAL_ENV "/root/Buddy/buddy"
set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
set _OLD_VIRTUAL_PROMPT="$prompt"
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
if ("buddy" != "") then
set env_name = "buddy"
else
if (`basename "VIRTUAL_ENV"` == "__") then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
else
set env_name = `basename "$VIRTUAL_ENV"`
endif
endif
set prompt = "[$env_name] $prompt"
unset env_name
endif
alias pydoc python -m pydoc
rehash

75
Buddy/buddy/bin/activate.fish Executable file
View File

@ -0,0 +1,75 @@
# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
# you cannot run it directly
function deactivate -d "Exit virtualenv and return to normal shell environment"
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
functions -e fish_prompt
set -e _OLD_FISH_PROMPT_OVERRIDE
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
end
set -e VIRTUAL_ENV
if test "$argv[1]" != "nondestructive"
# Self destruct!
functions -e deactivate
end
end
# unset irrelevant variables
deactivate nondestructive
set -gx VIRTUAL_ENV "/root/Buddy/buddy"
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
# unset PYTHONHOME if set
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# fish uses a function instead of an env var to generate the prompt.
# save the current fish_prompt function as the function _old_fish_prompt
functions -c fish_prompt _old_fish_prompt
# with the original prompt function renamed, we can override with our own.
function fish_prompt
# Save the return status of the last command
set -l old_status $status
# Prompt override?
if test -n "(buddy) "
printf "%s%s" "(buddy) " (set_color normal)
else
# ...Otherwise, prepend env
set -l _checkbase (basename "$VIRTUAL_ENV")
if test $_checkbase = "__"
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)
else
printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)
end
end
# Restore the return status of the previous command.
echo "exit $old_status" | .
_old_fish_prompt
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end

11
Buddy/buddy/bin/chardetect Executable file
View File

@ -0,0 +1,11 @@
#!/root/Buddy/buddy/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from chardet.cli.chardetect import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

11
Buddy/buddy/bin/django-admin Executable file
View File

@ -0,0 +1,11 @@
#!/root/Buddy/buddy/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from django.core.management import execute_from_command_line
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(execute_from_command_line())

View File

@ -0,0 +1,5 @@
#!/root/Buddy/buddy/bin/python3
from django.core import management
if __name__ == "__main__":
management.execute_from_command_line()

11
Buddy/buddy/bin/easy_install Executable file
View File

@ -0,0 +1,11 @@
#!/root/Buddy/buddy/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from setuptools.command.easy_install import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

View File

@ -0,0 +1,11 @@
#!/root/Buddy/buddy/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from setuptools.command.easy_install import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

11
Buddy/buddy/bin/pip Executable file
View File

@ -0,0 +1,11 @@
#!/root/Buddy/buddy/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

11
Buddy/buddy/bin/pip3 Executable file
View File

@ -0,0 +1,11 @@
#!/root/Buddy/buddy/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

11
Buddy/buddy/bin/pip3.6 Executable file
View File

@ -0,0 +1,11 @@
#!/root/Buddy/buddy/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())

3
Buddy/buddy/pyvenv.cfg Executable file
View File

@ -0,0 +1,3 @@
home = /usr/bin
include-system-site-packages = false
version = 3.6.7

5
bin/init_buddy_walk.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
cd /root/Buddy/buddy
source bin/activate
cd /root/Buddy/Buddy
python manage.py runserver 0:8000 > /root/log/buddy.log

5
bin/init_python.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
cd /root/Buddy/buddy
source bin/activate
cd ../Buddy