Permalink
Browse files

grrr

  • Loading branch information...
1 parent 5628287 commit f8ede2c8293efec621cea9212d65b111ea4add1f @kennethreitz kennethreitz committed Mar 26, 2012
Showing with 48 additions and 6 deletions.
  1. +1 −0 requirements.txt
  2. +32 −3 springcreek/core.py
  3. +9 −2 springcreek/models.py
  4. +6 −1 springcreek/templates/build.html
View
@@ -16,6 +16,7 @@ celery==2.5.1
certifi==0.0.8
chardet==1.0.1
distribute==0.6.24
+envoy==0.0.2
flask-heroku==0.1.2
gevent==0.13.6
greenlet==0.3.4
View
@@ -8,8 +8,10 @@
"""
import os
+import tempfile
import heroku
+import envoy
from flask import Flask, render_template, request, redirect, url_for
from flask.views import MethodView
@@ -49,9 +51,36 @@
@celery.task
-def build_task(*args, **kwargs):
- app.logger.info('inside a task...')
- print heroku
+def build_task(request):
+ app.logger.info('Starting build for {0}.'.format(request))
+
+ # Replace # w/ @
+ _split_url = request.application_url.split('@')
+ clone_url = _split_url[0]
+ clone_ref = _split_url[1] if len(_split_url) > 1 else None
+
+ h_app = heroku.apps.create(stack=cedar)
+ h_app.config['BUILDPACK_URL'] = request.buildpack_url
+
+ app.logger.info('Heroku app {0} created for {1}.'.format(h_app, request))
+
+ pwd = tempfile.mkdtemp(prefix='springcreek')
+ app.logger.info('Temp dir {0} created for {1}.'.format(pwd, request))
+ os.chdir(pwd)
+
+
+ app.logger.info('Cloning {0} created for {1}.'.format(application_url, request))
+ c = envoy.run('git clone {0} repo'.format(application_url))
+ os.chdir('repo')
+
+
+ app.logger.info('Pushing app to {0} for {1}.'.format(h_app, request))
+
+ # c = envoy.run('git push git@heroku.com:{h_app.name}.git')
+ # git clone {{ application_url }} repo
+ # cd repo
+
+ # git push {{ clone_ref }}:master
View
@@ -10,10 +10,17 @@
from flask import url_for
from flaskext.sqlalchemy import SQLAlchemy
+
db = SQLAlchemy()
-class BuildRequest(db.Model):
+class BaseModel(object):
+ def save(self):
+ db.session.add(self)
+ return db.session.commit()
+
+
+class BuildRequest(db.Model, BaseModel):
id = db.Column(db.Integer, primary_key=True)
buildpack_url = db.Column(db.String(300), unique=False)
application_url = db.Column(db.String(300), unique=False)
@@ -35,7 +42,7 @@ def __init__(self, buildpack_url, application_url, keep=False):
def url(self):
return url_for('view_build', id=self.id)
-class BuildResult(db.Model):
+class BuildResult(db.Model, BaseModel):
id = db.Column(db.Integer, primary_key=True)
request_id = db.ForeignKey('BuildRequest.id')
heroku_app = db.Column(db.String(50), unique=False)
@@ -4,6 +4,11 @@
<h1>Build #{{ request.id }}</h1>
-This is a build.
+<p>This is a build.</p>
+
+<div class="progress span4">
+ <div class="bar"
+ style="width: 60%;"></div>
+</div>
{% endblock %}

0 comments on commit f8ede2c

Please sign in to comment.