From fa17ebb9c7c2b290033b28e2c74dc8e0edf1aedd Mon Sep 17 00:00:00 2001 From: Tim Flink Date: Apr 01 2014 19:39:10 +0000 Subject: fixing production config startup check issue, getting setup.py version from __init__.py --- diff --git a/fake_fedorainfra/__init__.py b/fake_fedorainfra/__init__.py index bde8682..f6c73a0 100644 --- a/fake_fedorainfra/__init__.py +++ b/fake_fedorainfra/__init__.py @@ -19,7 +19,7 @@ # Josef Skladanka -from flask import Flask, render_template +from flask import Flask from flask.ext.login import LoginManager from flask.ext.sqlalchemy import SQLAlchemy @@ -28,12 +28,12 @@ import os # the version as used in setup.py -__version__ = "0.0.1" +__version__ = "0.1.5" # Flask App app = Flask(__name__) -app.secret_key = 'not-really-a-secret' +app.secret_key = 'replace-me-with-something-random' # load default configuration if os.getenv('DEV') == 'true': @@ -41,8 +41,6 @@ if os.getenv('DEV') == 'true': elif os.getenv('TEST') == 'true': app.config.from_object('fake_fedorainfra.config.TestingConfig') else: - if app.secret_key == 'not-really-a-secret': - raise Warning("You need to change the app.secret_key value for production") app.config.from_object('fake_fedorainfra.config.ProductionConfig') @@ -60,7 +58,10 @@ if not app.testing: else: app.logger.info('No extra config found, using defaults') -# setup logging +# make sure that we're not using the default secret_key for production +if app.config['PRODUCTION']: + if app.secret_key == 'replace-me-with-something-random': + raise Warning("You need to change the app.secret_key value for production") # setup logging fmt = '[%(filename)s:%(lineno)d] ' if app.debug else '%(module)-12s ' diff --git a/setup.py b/setup.py index 7de628d..8e24c1b 100644 --- a/setup.py +++ b/setup.py @@ -11,10 +11,21 @@ class PyTest(Command): errno = subprocess.call(['py.test', 'testing']) raise SystemExit(errno) +def read(*parts): + return codecs.open(os.path.join(here, *parts), 'r').read() + + +def find_version(*file_paths): + version_file = read(*file_paths) + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", + version_file, re.M) + if version_match: + return version_match.group(1) + raise RuntimeError("Unable to find version string.") setup(name='fake_fedorainfra', - version='0.1.4', - description='Mock Fedora infrastructure designed to test AutoQA', + version=find_version('blockerbugs', '__init__.py'),, + description='Mock Fedora infrastructure designed to test QA Automation Projects', author='Tim Flink', author_email='tflink@fedoraproject.org', license='GPLv2+',