expose full rethinkdb entry as yaml on job page

This commit is contained in:
Noah Levitt 2016-06-22 22:29:07 +00:00
parent 510456eef2
commit 9b3f3809cc
5 changed files with 40 additions and 20 deletions

View file

@ -21,7 +21,7 @@ import glob
setuptools.setup( setuptools.setup(
name='brozzler', name='brozzler',
version='1.1.dev18', version='1.1.dev19',
description='Distributed web crawling with browsers', description='Distributed web crawling with browsers',
url='https://github.com/internetarchive/brozzler', url='https://github.com/internetarchive/brozzler',
author='Noah Levitt', author='Noah Levitt',

View file

@ -1,21 +1,21 @@
# '''
# brozzler-webconsole/__init__.py - flask app for brozzler web console, defines brozzler-webconsole/__init__.py - flask app for brozzler web console, defines
# api endspoints etc api endspoints etc
#
# Copyright (C) 2014-2016 Internet Archive Copyright (C) 2014-2016 Internet Archive
#
# Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
# You may obtain a copy of the License at You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and See the License for the specific language governing permissions and
# limitations under the License. limitations under the License.
# '''
import flask import flask
import rethinkstuff import rethinkstuff
@ -25,6 +25,7 @@ import os
import importlib import importlib
import rethinkdb import rethinkdb
import logging import logging
import yaml
# flask does its own logging config # flask does its own logging config
# logging.basicConfig( # logging.basicConfig(
@ -90,6 +91,7 @@ def pages(site_id):
app.logger.info("flask.request.args=%s", flask.request.args) app.logger.info("flask.request.args=%s", flask.request.args)
start = int(flask.request.args.get("start", 0)) start = int(flask.request.args.get("start", 0))
end = int(flask.request.args.get("end", start + 90)) end = int(flask.request.args.get("end", start + 90))
app.logger.info("yes new query")
pages_ = r.table("pages").between( pages_ = r.table("pages").between(
[site_id, 1, r.minval], [site_id, r.maxval, r.maxval], [site_id, 1, r.minval], [site_id, r.maxval, r.maxval],
index="least_hops").order_by(index="least_hops")[start:end].run() index="least_hops").order_by(index="least_hops")[start:end].run()
@ -118,6 +120,14 @@ def job(job_id):
job_ = r.table("jobs").get(job_id).run() job_ = r.table("jobs").get(job_id).run()
return flask.jsonify(job_) return flask.jsonify(job_)
@app.route("/api/jobs/<int:job_id>/yaml")
@app.route("/api/job/<int:job_id>/yaml")
def job_yaml(job_id):
job_ = r.table("jobs").get(job_id).run()
return app.response_class(
yaml.dump(job_, default_flow_style=False),
mimetype='application/yaml')
@app.route("/api/workers") @app.route("/api/workers")
def workers(): def workers():
workers_ = service_registry.available_services("brozzler-worker") workers_ = service_registry.available_services("brozzler-worker")

View file

@ -137,6 +137,7 @@ function loadSiteStats($http, site, job) {
brozzlerControllers.controller("JobController", ["$scope", "$routeParams", "$http", brozzlerControllers.controller("JobController", ["$scope", "$routeParams", "$http",
function($scope, $routeParams, $http) { function($scope, $routeParams, $http) {
$scope.show_yaml = false;
// console.log('JobController'); // console.log('JobController');
$http.get("/api/config").success(function(data) { $http.get("/api/config").success(function(data) {
$scope.config = data.config; $scope.config = data.config;
@ -158,6 +159,9 @@ brozzlerControllers.controller("JobController", ["$scope", "$routeParams", "$htt
} }
}); });
}); });
$http.get("/api/jobs/" + $routeParams.id + "/yaml").success(function(data) {
$scope.job_yaml = data;
});
}]); }]);
brozzlerControllers.controller("SiteController", ["$scope", "$routeParams", "$http", "$window", brozzlerControllers.controller("SiteController", ["$scope", "$routeParams", "$http", "$window",

View file

@ -10,7 +10,12 @@
</div> </div>
<div> <div>
<h2>Job {{job.id}} <small>{{job.started}}-{{job.finished}} {{job.status}}</small></h2> <h2 ng-click="show_yaml = !show_yaml">
<span class="fa fa-caret-right"
ng-class="{ 'fa-caret-right': !show_yaml, 'fa-caret-down': !!show_yaml }"></span>
Job {{job.id}} <small>{{job.started}}-{{job.finished}}: {{job.status}}</small>
</h2>
<pre style="display:{{show_yaml?'block':'none'}}">{{job_yaml}}</pre>
<div class="row bigstats"> <div class="row bigstats">
<div class="col-sm-6 col-md-3"> <div class="col-sm-6 col-md-3">

View file

@ -1,3 +1,4 @@
rethinkstuff>=0.1.5 rethinkstuff>=0.1.5
flask>=0.11 flask>=0.11
gunicorn gunicorn
PyYAML