Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

chchchcanges

  • Loading branch information...
commit 5628287843966f4b01a0296150f084e940fd84b8 1 parent 1867ec2
@kennethreitz kennethreitz authored
Showing with 16 additions and 37 deletions.
  1. +2 −0  .gitignore
  2. +0 −25 springcreek/builder.py
  3. +14 −12 springcreek/core.py
View
2  .gitignore
@@ -0,0 +1,2 @@
+
+springcreek/test.db
View
25 springcreek/builder.py
@@ -1,25 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
-springcreek.builder
-~~~~~~~~~~~~~~~~
-
-This module contains the configuration.
-"""
-
-import os
-from flask import current_app
-import heroku
-
-from .models import db, BuildRequest, BuildResult
-
-
-app = current_app
-
-# Heroku API Client.
-heroku = heroku.from_key(os.environ.get('HEROKU_API_KEY'))
-
-def build(request):
- """Builds a build from a BuildRequest"""
-
- print heroku
View
26 springcreek/core.py
@@ -9,6 +9,7 @@
import os
+import heroku
from flask import Flask, render_template, request, redirect, url_for
from flask.views import MethodView
@@ -19,7 +20,6 @@
from flask.ext.celery import Celery
from .models import db, BuildRequest, BuildResult
-from .builder import build
app = Flask(__name__)
app.secret_key = 'some-secret-key'
@@ -30,7 +30,9 @@
# Heroku API Key.
+app.config['HEROKU_API_KEY'] = os.environ.get('HEROKU_API_KEY')
app.config['DEBUG_TB_ENABLED'] = True
+app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False
# Bootstrap Heroku environment variables.
heroku_env = Heroku(app)
@@ -43,29 +45,28 @@
toolbar = DebugToolbarExtension(app)
celery = Celery(app)
+heroku = heroku.from_key(app.config['HEROKU_API_KEY'] )
+
+
@celery.task
def build_task(*args, **kwargs):
- print 'I am a delayed job!'
- import os
- os.system('say yay')
- # print 'yay'
- import time
- time.sleep(20)
- return build(*args, **kwargs)
+ app.logger.info('inside a task...')
+ print heroku
+
@app.route('/')
-# @auth.required
+@auth.required
def landing_page():
return render_template('index.html')
class Builds(MethodView):
- # @auth.required
+ @auth.required
def get(self):
return str(len(BuildRequest.query.all()))
- # @auth.required
+ @auth.required
def post(self):
"""Create a new BuildRequest."""
@@ -78,6 +79,7 @@ def post(self):
db.session.commit()
# Send the build task off to work.
+ app.logger.info('Sending off a task...')
build_task.delay(r)
return redirect(r.url)
@@ -85,7 +87,7 @@ def post(self):
app.add_url_rule('/builds', view_func=Builds.as_view('builds'))
@app.route('/builds/<id>')
-# @auth.required
+@auth.required
def view_build(id):
b_request = BuildRequest.query.filter_by(id=id).first()
Please sign in to comment.
Something went wrong with that request. Please try again.