From 0edacbe03712361bc19376272ba1eaa85e349bcc Mon Sep 17 00:00:00 2001 From: Nicholas Charriere Date: Sat, 22 Apr 2017 22:26:20 -0700 Subject: [PATCH 1/5] Prepare for v1.0.0 release --- setup.cfg | 10 ++++++++++ snappass/__init__.py | 1 + snappass/main.py | 16 +++++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..47fba4a --- /dev/null +++ b/setup.cfg @@ -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] diff --git a/snappass/__init__.py b/snappass/__init__.py index 845eb13..2f6aaaf 100644 --- a/snappass/__init__.py +++ b/snappass/__init__.py @@ -1 +1,2 @@ __author__ = 'davedash' +__version__ = 1.0.0 diff --git a/snappass/main.py b/snappass/main.py index dee873e..8f942a5 100644 --- a/snappass/main.py +++ b/snappass/main.py @@ -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, @@ -86,6 +87,7 @@ def clean_input(): return time_conversion[time_period], request.form['password'] + def request_is_valid(request): """ Ensure the request validates the following: From ee9e996fa12ae1be1669fb1ed70733f6ad538a56 Mon Sep 17 00:00:00 2001 From: Nicholas Charriere Date: Sat, 22 Apr 2017 22:29:25 -0700 Subject: [PATCH 2/5] All Caps for constant vars --- snappass/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snappass/main.py b/snappass/main.py index 8f942a5..f272d41 100644 --- a/snappass/main.py +++ b/snappass/main.py @@ -31,7 +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): @@ -82,10 +82,10 @@ 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): From 47d94630db08218d328d4d3eda4548655ff74518 Mon Sep 17 00:00:00 2001 From: Nicholas Charriere Date: Sat, 22 Apr 2017 22:33:08 -0700 Subject: [PATCH 3/5] Version should be a string --- snappass/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snappass/__init__.py b/snappass/__init__.py index 2f6aaaf..b5a206f 100644 --- a/snappass/__init__.py +++ b/snappass/__init__.py @@ -1,2 +1,2 @@ __author__ = 'davedash' -__version__ = 1.0.0 +__version__ = '1.0.0' From 6d38e2b43ef8d8eed6a14ac56597f7c074222bb5 Mon Sep 17 00:00:00 2001 From: Nicholas Charriere Date: Sat, 22 Apr 2017 22:36:41 -0700 Subject: [PATCH 4/5] Add flake8 checking --- tox.ini | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index b71fefc..5c7c00f 100644 --- a/tox.ini +++ b/tox.ini @@ -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 + +[flake8] +commands = + pip install flake8 + flake8snappass/ From 47f3a31beec15be5c046df003d10eee0a234032a Mon Sep 17 00:00:00 2001 From: Nicholas Charriere Date: Sun, 23 Apr 2017 10:08:49 -0700 Subject: [PATCH 5/5] Fix tox env name, flake8 is recognized by the flake8 tool and duplicates setup.cfg --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 5c7c00f..63a16b9 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,7 @@ commands = pip install -r requirements.txt --use-wheel py.test --junitxml=junit-{envname}.xml --cov-report xml tests.py -[flake8] +[testenv:flake8] commands = pip install flake8 - flake8snappass/ + flake8 snappass/