def __init__(self, conf=None): conf = conf if conf else { 'host': '127.0.0.1', 'port': 6379, 'socket_timeout': 3, 'socket_connect_timeout': 3, } hr.configure(conf)
from tempfile import TemporaryDirectory from urllib.parse import urlparse import hot_redis as redis import hug from PIL import Image, ImageDraw, ImageFont from PIL.ImageColor import getrgb as color from sh import cd, ci_worker, git, pwd, ErrorReturnCode_128, mkdir, tox __version__ = '0.0.1' NOT_FOUND = -1 REDIS_AUTH = urlparse(os.environ.get('REDISCLOUD_URL')) redis.configure({ 'host': REDIS_AUTH.hostname, 'port': REDIS_AUTH.port or 6379, 'password': REDIS_AUTH.password }) def draw_pin(text, background_color='green', font_color='white'): '''Draws and returns a pin with the specified text and color scheme''' image = Image.new('RGB', (120, 20)) draw = ImageDraw.Draw(image) draw.rectangle([(1, 1), (118, 18)], fill=color(background_color)) draw.text((10, 4), text, fill=color(font_color)) return image def pin(value): '''A small pin that represents the result of the build process'''
import sys from contextlib import contextmanager from tempfile import TemporaryDirectory from urllib.parse import urlparse import hot_redis as redis import hug from PIL import Image, ImageDraw, ImageFont from PIL.ImageColor import getrgb as color from sh import cd, ci_worker, git, pwd, ErrorReturnCode_128, mkdir, tox __version__ = '0.0.1' NOT_FOUND = -1 REDIS_AUTH = urlparse(os.environ.get('REDISCLOUD_URL')) redis.configure({'host': REDIS_AUTH.hostname, 'port': REDIS_AUTH.port or 6379, 'password': REDIS_AUTH.password}) def draw_pin(text, background_color='green', font_color='white'): '''Draws and returns a pin with the specified text and color scheme''' image = Image.new('RGB', (120, 20)) draw = ImageDraw.Draw(image) draw.rectangle([(1, 1), (118, 18)], fill=color(background_color)) draw.text((10, 4), text, fill=color(font_color)) return image def pin(value): '''A small pin that represents the result of the build process''' if value is False: return draw_pin('Build Failed', 'red')
"""Quite possibly the most simplistic remotely available todo list ever created""" import os from urllib.parse import urlparse import hot_redis import hug import requests __version__ = "0.0.3" AUTH = ("tim", "anr94230890tnarsikantAWFUNRSkviawentha") REDIS_AUTH = urlparse(os.environ.get("REDISCLOUD_URL")) ENDPOINT = "http://tims-todo-list.herokuapp.com/todos" hot_redis.configure({"host": REDIS_AUTH.hostname, "port": REDIS_AUTH.port or 6379, "password": REDIS_AUTH.password}) todos = hot_redis.List(key="my_todos") authentication = hug.authentication.basic(hug.authentication.verify(*AUTH)) @hug.get("/todos") def get_todos(): """Returns a list of all my todo items""" return list(todos) @hug.post("/todos", requires=authentication) def add_todo(todo): """Adds a new todo item""" todos.append(todo) @hug.delete("/todos", requires=authentication) def remove_todo(todo):
def config(*args, **kwargs): return hr.configure(*args, **kwargs)