Merge pull request #59 from pinterest/10

Prepare for v1.0.0 release
This commit is contained in:
Nicholas Charriere 2017-04-23 18:30:44 -07:00 committed by GitHub
commit c377e31145
4 changed files with 28 additions and 10 deletions

10
setup.cfg Normal file
View file

@ -0,0 +1,10 @@
[bumpversion]
current_version = 1.0.0
commit = False
tag = True
[flake8]
show-source = True
max-line-length = 120
[bumpversion:file:snappass/__init__.py]

View file

@ -1 +1,2 @@
__author__ = 'davedash'
__version__ = '1.0.0'

View file

@ -9,12 +9,15 @@ from redis.exceptions import ConnectionError
from flask import abort, Flask, render_template, request
SNEAKY_USER_AGENTS = ('Slackbot', 'facebookexternalhit', 'Twitterbot', 'Facebot', 'WhatsApp', 'SkypeUriPreview')
SNEAKY_USER_AGENTS = ('Slackbot', 'facebookexternalhit', 'Twitterbot',
'Facebot', 'WhatsApp', 'SkypeUriPreview')
SNEAKY_USER_AGENTS_RE = re.compile('|'.join(SNEAKY_USER_AGENTS))
NO_SSL = os.environ.get('NO_SSL', False)
app = Flask(__name__)
if os.environ.get('DEBUG'):
app.debug = True
app.debug = True
app.secret_key = os.environ.get('SECRET_KEY', 'Secret Key')
app.config.update(
dict(STATIC_URL=os.environ.get('STATIC_URL', 'static')))
@ -28,11 +31,7 @@ else:
redis_client = redis.StrictRedis(
host=redis_host, port=redis_port, db=redis_db)
time_conversion = {
'week': 604800,
'day': 86400,
'hour': 3600
}
TIME_CONVERSION = {'week': 604800, 'day': 86400, 'hour': 3600}
def check_redis_alive(fn):
@ -65,10 +64,12 @@ def get_password(key):
redis_client.delete(key)
return password
def empty(value):
if not value:
return True
def clean_input():
"""
Make sure we're not getting bad data from the front end,
@ -81,10 +82,11 @@ def clean_input():
abort(400)
time_period = request.form['ttl'].lower()
if time_period not in time_conversion:
if time_period not in TIME_CONVERSION:
abort(400)
return time_conversion[time_period], request.form['password']
return TIME_CONVERSION[time_period], request.form['password']
def request_is_valid(request):
"""

View file

@ -1,5 +1,5 @@
[tox]
envlist = py26, py27, py33, py34, py35, py36
envlist = py26, py27, py33, py34, py35, py36, flake8
[testenv]
deps =
@ -8,3 +8,8 @@ deps =
commands =
pip install -r requirements.txt --use-wheel
py.test --junitxml=junit-{envname}.xml --cov-report xml tests.py
[testenv:flake8]
commands =
pip install flake8
flake8 snappass/