Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

view history of previous deployments

  • Loading branch information...
commit 5541fab7376b9ddc5d2cf83d927c10a7bc410cf1 1 parent 41af16d
@jasonthomas jasonthomas authored
Showing with 82 additions and 3 deletions.
  1. +24 −3 chief.py
  2. +58 −0 templates/history.html
View
27 chief.py
@@ -20,6 +20,7 @@ def do_update(app_name, app_settings, webapp_ref, who):
deploy = app_settings['script']
log_dir = os.path.join(settings.OUTPUT_DIR, app_name)
timestamp = int(time.time())
+ datetime = time.strftime("%b %d %Y %H:%M:%S", time.localtime())
if not os.path.isdir(log_dir):
os.mkdir(log_dir)
@@ -32,14 +33,14 @@ def pub(event):
d = {'event': event, 'ref': webapp_ref, 'who': who}
redis.publish(app_settings['pubsub_channel'], json.dumps(d))
- def history():
+ def history(status):
redis = redislib.Redis(**settings.REDIS_BACKENDS['master'])
- d = {'user': who, 'ref': webapp_ref}
+ d = {'timestamp':timestamp, 'datetime': datetime,
+ 'status': status, 'user': who, 'ref': webapp_ref}
key = "%s:%s" % (app_name, timestamp)
redis.hmset(key, d)
try:
- history()
pub('BEGIN')
yield 'Updating! revision: %s\n' % webapp_ref
@@ -57,11 +58,22 @@ def history():
run('deploy', output)
pub('DONE')
+ history('Success')
yield 'All done!'
except:
pub('FAIL')
+ history('Fail')
raise
+def get_history(app_name, app_settings):
+ redis = redislib.Redis(**settings.REDIS_BACKENDS['master'])
+ results = []
+ key_prefix = "%s:*" % app_name
+ for history in redis.keys(key_prefix):
+ results.append(redis.hgetall(history))
+ return sorted(results, key=lambda k: k['timestamp'], reverse=True)
+
+
@app.route("/<webapp>", methods=['GET', 'POST'])
def index(webapp):
if webapp not in settings.WEBAPPS.keys():
@@ -82,3 +94,12 @@ def index(webapp):
return render_template("index.html", app_name=webapp,
form=form, errors=errors)
+
+@app.route("/<webapp>/history", methods=['GET'])
+def history(webapp):
+ if webapp not in settings.WEBAPPS.keys():
+ abort(404)
+ else:
+ app_settings = settings.WEBAPPS[webapp]
+ results = get_history(webapp, app_settings)
+ return render_template("history.html", results=results)
View
58 templates/history.html
@@ -0,0 +1,58 @@
+<html>
+<head>
+<style type="text/css">
+#table {
+ border: 1px solid #DFDFDF;
+ background-color: #F9F9F9;
+ width: 100%;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
+ font-family: Arial,"Bitstream Vera Sans",Helvetica,Verdana,sans-serif;
+ color: #333;
+}
+#table td, #table th {
+ border-top-color: white;
+ border-bottom: 1px solid #DFDFDF;
+ color: #555;
+}
+#table th {
+ text-shadow: rgba(255, 255, 255, 0.796875) 0px 1px 0px;
+ font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
+ font-weight: normal;
+ padding: 7px 7px 8px;
+ text-align: left;
+ line-height: 1.3em;
+ font-size: 14px;
+}
+#table td {
+ font-size: 12px;
+ padding: 4px 7px 2px;
+ vertical-align: top;
+}
+</style>
+</head>
+<body>
+ <table id="table">
+ <thead>
+ <tr>
+ <th>Date</th>
+ <th>User</th>
+ <th>Ref</th>
+ <th>Status</th>
+ <th>Log</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for result in results %}
+ <tr>
+ <td>{{ result.datetime }}</td>
+ <td>{{ result.user }}</td>
+ <td>{{ result.ref }}</td>
+ <td>{{ result.status }}</td>
+ <td><a href="logs/{{ app_name }}/{{ result.ref }}.{{ result.timestamp }}">view</a></td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.