From afe7b8523c7dbf3c446bd7f5b8fbd512aa9bbf52 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 21 Dec 2017 04:32:16 +0100 Subject: [PATCH 01/10] Move autotest to autopilot/ directory --- .gitignore | 2 +- README.md | 2 +- slides/{ => autopilot}/autotest.py | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename slides/{ => autopilot}/autotest.py (100%) diff --git a/.gitignore b/.gitignore index a1168d57..0e2459d4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ prepare-vms/ips.pdf prepare-vms/settings.yaml prepare-vms/tags slides/*.yml.html -slides/state.yaml +slides/autopilot/state.yaml diff --git a/README.md b/README.md index 79b5c754..59eeb0d2 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ because they have a few things in common: (and updated) identically between different decks; - a [build system](slides/) generating HTML slides from Markdown source files; -- a [semi-automated test harness](slides/autotest.py) to check +- a [semi-automated test harness](slides/autopilot/) to check that the exercises and examples provided work properly; - a [PhantomJS script](slides/slidechecker.js) to check that the slides look good and don't have formatting issues; diff --git a/slides/autotest.py b/slides/autopilot/autotest.py similarity index 100% rename from slides/autotest.py rename to slides/autopilot/autotest.py From bc2eb53bb2b243d9e83f6227c3ac2139e2d4e522 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 21 Dec 2017 04:33:35 +0100 Subject: [PATCH 02/10] Python 3 compatibility --- slides/autopilot/autotest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slides/autopilot/autotest.py b/slides/autopilot/autotest.py index 71bb990d..30995dc0 100755 --- a/slides/autopilot/autotest.py +++ b/slides/autopilot/autotest.py @@ -199,7 +199,7 @@ def send_keys(data): subprocess.check_call(["tmux", "send-keys", data]) def capture_pane(): - return subprocess.check_output(["tmux", "capture-pane", "-p"]) + return subprocess.check_output(["tmux", "capture-pane", "-p"]).decode('utf-8') setup_tmux_and_ssh() From 270c36b29ae4a2b78f7e3e76676e21bc65edcccc Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 21 Dec 2017 04:43:42 +0100 Subject: [PATCH 03/10] Add pub/sub server and CLI remote --- .gitignore | 1 + slides/autopilot/gotoslide.js | 13 + slides/autopilot/package-lock.json | 603 +++++++++++++++++++++++++++++ slides/autopilot/package.json | 8 + slides/autopilot/server.js | 38 ++ 5 files changed, 663 insertions(+) create mode 100755 slides/autopilot/gotoslide.js create mode 100644 slides/autopilot/package-lock.json create mode 100644 slides/autopilot/package.json create mode 100755 slides/autopilot/server.js diff --git a/.gitignore b/.gitignore index 0e2459d4..6bdc5ba7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ prepare-vms/settings.yaml prepare-vms/tags slides/*.yml.html slides/autopilot/state.yaml +node_modules diff --git a/slides/autopilot/gotoslide.js b/slides/autopilot/gotoslide.js new file mode 100755 index 00000000..79d11178 --- /dev/null +++ b/slides/autopilot/gotoslide.js @@ -0,0 +1,13 @@ +#!/usr/bin/env node + +/* Expects a slide number as first argument. + * Will connect to the local pub/sub server, + * and issue a "go to slide X" command, which + * will be sent to all connected browsers. + */ + +var io = require('socket.io-client'); +var socket = io('http://localhost:3000'); +socket.emit('slide change', process.argv[2], function () { + socket.close(); +}); diff --git a/slides/autopilot/package-lock.json b/slides/autopilot/package-lock.json new file mode 100644 index 00000000..a709ddbe --- /dev/null +++ b/slides/autopilot/package-lock.json @@ -0,0 +1,603 @@ +{ + "name": "container-training-pub-sub-server", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "accepts": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", + "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", + "requires": { + "mime-types": "2.1.17", + "negotiator": "0.6.1" + } + }, + "after": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", + "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=" + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "arraybuffer.slice": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz", + "integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco=" + }, + "async-limiter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", + "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" + }, + "backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=" + }, + "base64-arraybuffer": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", + "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=" + }, + "base64id": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", + "integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY=" + }, + "better-assert": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", + "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", + "requires": { + "callsite": "1.0.0" + } + }, + "blob": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", + "integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=" + }, + "body-parser": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "1.0.4", + "debug": "2.6.9", + "depd": "1.1.1", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "on-finished": "2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "1.6.15" + } + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "callsite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", + "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=" + }, + "component-bind": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", + "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=" + }, + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" + }, + "component-inherit": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", + "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" + }, + "engine.io": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.1.4.tgz", + "integrity": "sha1-PQIRtwpVLOhB/8fahiezAamkFi4=", + "requires": { + "accepts": "1.3.3", + "base64id": "1.0.0", + "cookie": "0.3.1", + "debug": "2.6.9", + "engine.io-parser": "2.1.1", + "uws": "0.14.5", + "ws": "3.3.3" + }, + "dependencies": { + "accepts": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", + "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=", + "requires": { + "mime-types": "2.1.17", + "negotiator": "0.6.1" + } + } + } + }, + "engine.io-client": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.1.4.tgz", + "integrity": "sha1-T88TcLRxY70s6b4nM5ckMDUNTqE=", + "requires": { + "component-emitter": "1.2.1", + "component-inherit": "0.0.3", + "debug": "2.6.9", + "engine.io-parser": "2.1.1", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "ws": "3.3.3", + "xmlhttprequest-ssl": "1.5.4", + "yeast": "0.1.2" + } + }, + "engine.io-parser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.1.tgz", + "integrity": "sha1-4Ps/DgRi9/WLt3waUun1p+JuRmg=", + "requires": { + "after": "0.8.2", + "arraybuffer.slice": "0.0.6", + "base64-arraybuffer": "0.1.5", + "blob": "0.0.4", + "has-binary2": "1.0.2" + } + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.16.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.2.tgz", + "integrity": "sha1-41xt/i1kt9ygpc1PIXgb4ymeB2w=", + "requires": { + "accepts": "1.3.4", + "array-flatten": "1.1.1", + "body-parser": "1.18.2", + "content-disposition": "0.5.2", + "content-type": "1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "1.1.1", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "etag": "1.8.1", + "finalhandler": "1.1.0", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "1.1.2", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "2.0.2", + "qs": "6.5.1", + "range-parser": "1.2.0", + "safe-buffer": "5.1.1", + "send": "0.16.1", + "serve-static": "1.13.1", + "setprototypeof": "1.1.0", + "statuses": "1.3.1", + "type-is": "1.6.15", + "utils-merge": "1.0.1", + "vary": "1.1.2" + } + }, + "finalhandler": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", + "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", + "requires": { + "debug": "2.6.9", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "statuses": "1.3.1", + "unpipe": "1.0.0" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "has-binary2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.2.tgz", + "integrity": "sha1-6D26SfC5vk0CbSc2U1DZ8D9Uvpg=", + "requires": { + "isarray": "2.0.1" + } + }, + "has-cors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", + "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=" + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": "1.3.1" + }, + "dependencies": { + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + } + } + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" + }, + "indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=" + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.5.2.tgz", + "integrity": "sha1-1LUFvemUaYfM8PxY2QEP+WB+P6A=" + }, + "isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", + "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" + }, + "mime-types": { + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", + "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "requires": { + "mime-db": "1.30.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "object-component": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", + "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "parseqs": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", + "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", + "requires": { + "better-assert": "1.0.2" + } + }, + "parseuri": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", + "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", + "requires": { + "better-assert": "1.0.2" + } + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "proxy-addr": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz", + "integrity": "sha1-ZXFQT0e7mI7IGAJT+F3X4UlSvew=", + "requires": { + "forwarded": "0.1.2", + "ipaddr.js": "1.5.2" + } + }, + "qs": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "send": { + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", + "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==", + "requires": { + "debug": "2.6.9", + "depd": "1.1.1", + "destroy": "1.0.4", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "etag": "1.8.1", + "fresh": "0.5.2", + "http-errors": "1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "2.3.0", + "range-parser": "1.2.0", + "statuses": "1.3.1" + } + }, + "serve-static": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.1.tgz", + "integrity": "sha512-hSMUZrsPa/I09VYFJwa627JJkNs0NrfL1Uzuup+GqHfToR2KcsXFymXSV90hoyw3M+msjFuQly+YzIH/q0MGlQ==", + "requires": { + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "parseurl": "1.3.2", + "send": "0.16.1" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "socket.io": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.0.4.tgz", + "integrity": "sha1-waRZDO/4fs8TxyZS8Eb3FrKeYBQ=", + "requires": { + "debug": "2.6.9", + "engine.io": "3.1.4", + "socket.io-adapter": "1.1.1", + "socket.io-client": "2.0.4", + "socket.io-parser": "3.1.2" + } + }, + "socket.io-adapter": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz", + "integrity": "sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs=" + }, + "socket.io-client": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.0.4.tgz", + "integrity": "sha1-CRilUkBtxeVAs4Dc2Xr8SmQzL44=", + "requires": { + "backo2": "1.0.2", + "base64-arraybuffer": "0.1.5", + "component-bind": "1.0.0", + "component-emitter": "1.2.1", + "debug": "2.6.9", + "engine.io-client": "3.1.4", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "object-component": "0.0.3", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "socket.io-parser": "3.1.2", + "to-array": "0.1.4" + } + }, + "socket.io-parser": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.1.2.tgz", + "integrity": "sha1-28IoIVH8T6675Aru3Ady66YZ9/I=", + "requires": { + "component-emitter": "1.2.1", + "debug": "2.6.9", + "has-binary2": "1.0.2", + "isarray": "2.0.1" + } + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" + }, + "to-array": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", + "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=" + }, + "type-is": { + "version": "1.6.15", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.17" + } + }, + "ultron": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", + "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "uws": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/uws/-/uws-0.14.5.tgz", + "integrity": "sha1-Z6rzPEaypYel9mZtAPdpEyjxSdw=", + "optional": true + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, + "ws": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", + "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", + "requires": { + "async-limiter": "1.0.0", + "safe-buffer": "5.1.1", + "ultron": "1.1.1" + } + }, + "xmlhttprequest-ssl": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.4.tgz", + "integrity": "sha1-BPVgkVcks4kIhxXMDteBPpZ3v1c=" + }, + "yeast": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", + "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" + } + } +} diff --git a/slides/autopilot/package.json b/slides/autopilot/package.json new file mode 100644 index 00000000..b7832ea2 --- /dev/null +++ b/slides/autopilot/package.json @@ -0,0 +1,8 @@ +{ + "name": "container-training-pub-sub-server", + "version": "0.0.1", + "dependencies": { + "express": "^4.16.2", + "socket.io": "^2.0.4" + } +} diff --git a/slides/autopilot/server.js b/slides/autopilot/server.js new file mode 100755 index 00000000..d4e7a923 --- /dev/null +++ b/slides/autopilot/server.js @@ -0,0 +1,38 @@ +#!/usr/bin/env node + +/* This is a very simple pub/sub server, allowing to + * remote control browsers displaying the slides. + * The browsers connect to this pub/sub server using + * Socket.IO, and the server tells them which slides + * to display. + * + * The server can be controlled with a little CLI, + * or by one of the browsers. + */ + +var express = require('express'); +var app = express(); +var http = require('http').Server(app); +var io = require('socket.io')(http); + +app.get('/', function(req, res){ + res.send('container.training autopilot pub/sub server'); +}); + +/* Serve slides etc. from the parent directory */ +app.use(express.static('..')); + +io.on('connection', function(socket){ + console.log('a client connected'); + socket.on('slide change', function(n, ack){ + console.log('slide change: ' + n); + socket.broadcast.emit('slide change', n); + if (typeof ack === 'function') { + ack(); + } + }); +}); + +http.listen(3000, function(){ + console.log('listening on *:3000'); +}); From ec7b46b7792ae1725f84b8767da1d4b027870268 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 21 Dec 2017 04:51:49 +0100 Subject: [PATCH 04/10] Add remote.js to workshop template and pub/sub server --- slides/autopilot/remote.js | 21 +++++++++++++++++++++ slides/autopilot/server.js | 5 ++++- slides/workshop.html | 11 +++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 slides/autopilot/remote.js diff --git a/slides/autopilot/remote.js b/slides/autopilot/remote.js new file mode 100644 index 00000000..c0bfa81d --- /dev/null +++ b/slides/autopilot/remote.js @@ -0,0 +1,21 @@ +/* This snippet is loaded from the workshop HTML file. + * It sets up callbacks to synchronize the local slide + * number with the remote pub/sub server. + */ + +var socket = io(); +var leader = true; + +slideshow.on('showSlide', function (slide) { + if (leader) { + var n = slide.getSlideIndex()+1; + socket.emit('slide change', n); + } +}); + +socket.on('slide change', function (n) { + leader = false; + slideshow.gotoSlide(n); + leader = true; +}); + diff --git a/slides/autopilot/server.js b/slides/autopilot/server.js index d4e7a923..dc89edfc 100755 --- a/slides/autopilot/server.js +++ b/slides/autopilot/server.js @@ -19,7 +19,10 @@ app.get('/', function(req, res){ res.send('container.training autopilot pub/sub server'); }); -/* Serve slides etc. from the parent directory */ +/* Serve remote.js from the current directory */ +app.use(express.static('.')); + +/* Serve slides etc. from current and the parent directory */ app.use(express.static('..')); io.on('connection', function(socket){ diff --git a/slides/workshop.html b/slides/workshop.html index 1800ecd1..ffb378ce 100644 --- a/slides/workshop.html +++ b/slides/workshop.html @@ -31,5 +31,16 @@ excludedClasses: [@@EXCLUDE@@] }); + + + + + From 718031565e0e0b92fa37afb7e84719e605a629a6 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 21 Dec 2017 05:29:45 +0100 Subject: [PATCH 05/10] Exit gracefully if server is not running instead of waiting forever --- slides/autopilot/gotoslide.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/slides/autopilot/gotoslide.js b/slides/autopilot/gotoslide.js index 79d11178..4728b2d1 100755 --- a/slides/autopilot/gotoslide.js +++ b/slides/autopilot/gotoslide.js @@ -8,6 +8,10 @@ var io = require('socket.io-client'); var socket = io('http://localhost:3000'); -socket.emit('slide change', process.argv[2], function () { - socket.close(); +socket.on('connect_error', function(){ + console.log('connection error'); + socket.close(); +}); +socket.emit('slide change', process.argv[2], function(){ + socket.close(); }); From 720989e829a673aae3e88832ab98563aa5e39b4e Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 21 Dec 2017 05:29:59 +0100 Subject: [PATCH 06/10] Add remote control of slide deck --- slides/autopilot/autotest.py | 82 +++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 10 deletions(-) diff --git a/slides/autopilot/autotest.py b/slides/autopilot/autotest.py index 30995dc0..6db08426 100755 --- a/slides/autopilot/autotest.py +++ b/slides/autopilot/autotest.py @@ -43,9 +43,6 @@ class State(object): next_step=self.next_step), f, default_flow_style=False) -state = State() - - def hrule(): return "="*int(subprocess.check_output(["tput", "cols"])) @@ -99,6 +96,54 @@ class Slide(object): def debug(self): logging.debug("\n{}\n{}\n{}".format(hrule(), self.content, hrule())) +# Synchronize slides in a remote browser +class Remote(object): + + def __init__(self): + self.slide_on_screen = 0 + + # Directly go to a specific slide + def goto(self, slide_number): + subprocess.check_call(["./gotoslide.js", str(slide_number)]) + self.slide_on_screen = slide_number + focus_slides() + + # Offer the opportunity to go step by step to the given slide + def catchup(self, slide_number): + if self.slide_on_screen > slide_number: + return self.goto(slide_number) + while self.slide_on_screen < slide_number: + if state.interactive: + print("Catching up on slide: {} -> {}" + .format(self.slide_on_screen, slide_number)) + print("z Zoom to target slide") + print("n/➡️/⎵ Next slide") + print("p/⬅️ Previous slide") + command = click.getchar() + else: + command = "z" + if command == "z": + self.goto(slide_number) + elif command in ("n", "\x1b[C", " "): + self.goto(self.slide_on_screen+1) + elif command in ("p", "\x1b[D"): + self.goto(self.slide_on_screen-1) + + +def focus_slides(): + subprocess.check_call(["i3-msg", "workspace", "3"]) + subprocess.check_call(["i3-msg", "workspace", "1"]) + time.sleep(1) + +def focus_terminal(): + subprocess.check_call(["i3-msg", "workspace", "2"]) + subprocess.check_call(["i3-msg", "workspace", "1"]) + time.sleep(1) + + +remote = Remote() +state = State() + def ansi(code): return lambda s: "\x1b[{}m{}\x1b[0m".format(code, s) @@ -171,7 +216,20 @@ def setup_tmux_and_ssh(): slides = [] content = open(sys.argv[1]).read() + +# OK, this part is definitely hackish, and will break if the +# excludedClasses parameter is not on a single line. +excluded_classes = re.findall("excludedClasses: (\[.*\])", content) +excluded_classes = set(eval(excluded_classes[0])) + for slide in re.split("\n---?\n", content): + slide_classes = re.findall("class: (.*)", slide) + if slide_classes: + slide_classes = slide_classes[0].split(",") + slide_classes = [c.strip() for c in slide_classes] + if excluded_classes & set(slide_classes): + logging.info("Skipping excluded slide.") + continue slides.append(Slide(slide)) actions = [] @@ -225,17 +283,20 @@ while state.next_step < len(actions): # Remove extra spaces (we don't want them in the terminal) and carriage returns data = data.strip() + # Synchronize the remote slides + remote.catchup(slide.number) + print(hrule()) print(slide.content.replace(snippet.content, ansi(7)(snippet.content))) print(hrule()) if state.interactive: print("simulate_type:{} verify_status:{}".format(state.simulate_type, state.verify_status)) print("[{}/{}] Shall we execute that snippet above?".format(state.next_step, len(actions))) - print("y/⏎/→ Execute snippet") + print("y/⏎ Execute snippet") print("p/← Previous snippet") - print("s Skip snippet") - print("t Toggle typist simulation") - print("v Toggle verification of exit status") + print("n/→ Next snippet") + print("s Simulate keystrokes") + print("v Validate exit status") print("g Go to a specific snippet") print("q Quit") print("c Continue non-interactively until next error") @@ -249,11 +310,11 @@ while state.next_step < len(actions): logging.info("Stripping ` from snippet.") data = data.replace('`', '') - if command == "s": + if command in ("n", "\x1b[C"): state.next_step += 1 elif command in ("p", "\x1b[D"): state.next_step -= 1 - elif command == "t": + elif command == "s": state.simulate_type = not state.simulate_type elif command == "v": state.verify_status = not state.verify_status @@ -264,7 +325,8 @@ while state.next_step < len(actions): elif command == "c": # continue until next timeout state.interactive = False - elif command in ("y", "\r", " ", "\x1b[C"): + elif command in ("y", "\r", " "): + focus_terminal() logging.info("Running with method {}: {}".format(method, data)) if method == "keys": send_keys(data) From 2aced95c861a3a623f1848f5212b7dc6f331f6fe Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 21 Dec 2017 05:40:35 +0100 Subject: [PATCH 07/10] Improve UX for remote control --- slides/autopilot/autotest.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/slides/autopilot/autotest.py b/slides/autopilot/autotest.py index 6db08426..ceab14e7 100755 --- a/slides/autopilot/autotest.py +++ b/slides/autopilot/autotest.py @@ -116,18 +116,21 @@ class Remote(object): if state.interactive: print("Catching up on slide: {} -> {}" .format(self.slide_on_screen, slide_number)) - print("z Zoom to target slide") - print("n/➡️/⎵ Next slide") - print("p/⬅️ Previous slide") + print("z/⏎ Zoom to target slide") + print("n/→/⎵ Next slide") + print("p/← Previous slide") + print("q Abort remote control") command = click.getchar() else: command = "z" - if command == "z": + if command in ("z", "\r"): self.goto(slide_number) elif command in ("n", "\x1b[C", " "): self.goto(self.slide_on_screen+1) elif command in ("p", "\x1b[D"): self.goto(self.slide_on_screen-1) + elif command == "q": + return def focus_slides(): @@ -292,7 +295,7 @@ while state.next_step < len(actions): if state.interactive: print("simulate_type:{} verify_status:{}".format(state.simulate_type, state.verify_status)) print("[{}/{}] Shall we execute that snippet above?".format(state.next_step, len(actions))) - print("y/⏎ Execute snippet") + print("y/⎵/⏎ Execute snippet") print("p/← Previous snippet") print("n/→ Next snippet") print("s Simulate keystrokes") @@ -320,6 +323,9 @@ while state.next_step < len(actions): state.verify_status = not state.verify_status elif command == "g": state.next_step = click.prompt("Enter snippet number", type=int) + # Special case: if we go to snippet 0, also reset the slides deck + if state.next_step == 0: + remote.goto(1) elif command == "q": break elif command == "c": From badb73a4133ed8dd49a16afdfc40ae3dab8cdae4 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 21 Dec 2017 05:45:38 +0100 Subject: [PATCH 08/10] Slower pace for virtual typist --- slides/autopilot/autotest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/slides/autopilot/autotest.py b/slides/autopilot/autotest.py index ceab14e7..152d83d5 100755 --- a/slides/autopilot/autotest.py +++ b/slides/autopilot/autotest.py @@ -254,8 +254,12 @@ def send_keys(data): for key in data: if key == ";": key = "\\;" + if key == "\n": + time.sleep(1) subprocess.check_call(["tmux", "send-keys", key]) - time.sleep(0.1*random.random()) + time.sleep(0.2*random.random()) + if key == "\n": + time.sleep(1) else: subprocess.check_call(["tmux", "send-keys", data]) From ef5e8f00f8caa67dd327649b27bcd0c6de84de04 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 21 Dec 2017 05:46:57 +0100 Subject: [PATCH 09/10] Add script to remember myself of how to customize tmux status bar --- slides/autopilot/tmux-style.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 slides/autopilot/tmux-style.sh diff --git a/slides/autopilot/tmux-style.sh b/slides/autopilot/tmux-style.sh new file mode 100755 index 00000000..5bb65130 --- /dev/null +++ b/slides/autopilot/tmux-style.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# This removes the clock (and other extraneous stuff) from the +# tmux status bar, and it gives it a non-default color. +tmux set-option -g status-left "" +tmux set-option -g status-right "" +tmux set-option -g status-style bg=cyan + From 2a138102fccb1f672294ac11db32c58ceb2c0db8 Mon Sep 17 00:00:00 2001 From: Jerome Petazzoni Date: Thu, 21 Dec 2017 05:53:24 +0100 Subject: [PATCH 10/10] Add client address in pub/sub server --- slides/autopilot/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slides/autopilot/server.js b/slides/autopilot/server.js index dc89edfc..6186dd2d 100755 --- a/slides/autopilot/server.js +++ b/slides/autopilot/server.js @@ -26,7 +26,7 @@ app.use(express.static('.')); app.use(express.static('..')); io.on('connection', function(socket){ - console.log('a client connected'); + console.log('a client connected: ' + socket.handshake.address); socket.on('slide change', function(n, ack){ console.log('slide change: ' + n); socket.broadcast.emit('slide change', n);