From 9b3f3809cc8740003e07f11a4bbc85beeff14b57 Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Wed, 22 Jun 2016 22:29:07 +0000 Subject: [PATCH] expose full rethinkdb entry as yaml on job page --- setup.py | 2 +- webconsole/brozzler-webconsole/__init__.py | 46 +++++++++++-------- .../brozzler-webconsole/static/js/app.js | 4 ++ .../static/partials/job.html | 7 ++- webconsole/requirements.txt | 1 + 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/setup.py b/setup.py index c93cef0..be2bb60 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ import glob setuptools.setup( name='brozzler', - version='1.1.dev18', + version='1.1.dev19', description='Distributed web crawling with browsers', url='https://github.com/internetarchive/brozzler', author='Noah Levitt', diff --git a/webconsole/brozzler-webconsole/__init__.py b/webconsole/brozzler-webconsole/__init__.py index 88f63f3..cc6d90b 100644 --- a/webconsole/brozzler-webconsole/__init__.py +++ b/webconsole/brozzler-webconsole/__init__.py @@ -1,21 +1,21 @@ -# -# brozzler-webconsole/__init__.py - flask app for brozzler web console, defines -# api endspoints etc -# -# Copyright (C) 2014-2016 Internet Archive -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# +''' +brozzler-webconsole/__init__.py - flask app for brozzler web console, defines +api endspoints etc + +Copyright (C) 2014-2016 Internet Archive + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +''' import flask import rethinkstuff @@ -25,6 +25,7 @@ import os import importlib import rethinkdb import logging +import yaml # flask does its own logging config # logging.basicConfig( @@ -90,6 +91,7 @@ def pages(site_id): app.logger.info("flask.request.args=%s", flask.request.args) start = int(flask.request.args.get("start", 0)) end = int(flask.request.args.get("end", start + 90)) + app.logger.info("yes new query") pages_ = r.table("pages").between( [site_id, 1, r.minval], [site_id, r.maxval, r.maxval], 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() return flask.jsonify(job_) +@app.route("/api/jobs//yaml") +@app.route("/api/job//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") def workers(): workers_ = service_registry.available_services("brozzler-worker") diff --git a/webconsole/brozzler-webconsole/static/js/app.js b/webconsole/brozzler-webconsole/static/js/app.js index 95d59fb..f74c3f9 100644 --- a/webconsole/brozzler-webconsole/static/js/app.js +++ b/webconsole/brozzler-webconsole/static/js/app.js @@ -137,6 +137,7 @@ function loadSiteStats($http, site, job) { brozzlerControllers.controller("JobController", ["$scope", "$routeParams", "$http", function($scope, $routeParams, $http) { + $scope.show_yaml = false; // console.log('JobController'); $http.get("/api/config").success(function(data) { $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", diff --git a/webconsole/brozzler-webconsole/static/partials/job.html b/webconsole/brozzler-webconsole/static/partials/job.html index 7919653..c76ac43 100644 --- a/webconsole/brozzler-webconsole/static/partials/job.html +++ b/webconsole/brozzler-webconsole/static/partials/job.html @@ -10,7 +10,12 @@
-

Job {{job.id}} {{job.started}}-{{job.finished}} {{job.status}}

+

+ + Job {{job.id}} {{job.started}}-{{job.finished}}: {{job.status}} +

+
{{job_yaml}}
diff --git a/webconsole/requirements.txt b/webconsole/requirements.txt index 09b9c3f..1255527 100644 --- a/webconsole/requirements.txt +++ b/webconsole/requirements.txt @@ -1,3 +1,4 @@ rethinkstuff>=0.1.5 flask>=0.11 gunicorn +PyYAML