Make io_log hold raw bytes, not decoded text

This is a fairly large patch. It shuffles some stuff around to make
JobResult.io_log entries .data hold a bytes object instead of a string
object.

The rationale for that is that we cannot reliably expect all scripts to
output something we can express as text in all cases. This is particularly
true in the wake of supporting attachments.

There are some large side effects, the session module now _expects_ each
job_result to be valid UTF-8. All errors are silently converted to
supplementary characters (and most likely, won't parse as valid rfc822
records anymore but this is properly supported)

The exporter subsystem was changed to save all data as base64 encoded
strings. This makes the exported data 'correct' as in not loosing
information.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
"[r=roadmr][bug=][author=zkrynicki] automatic merge by tarmac"
runner: drop unused import

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: track time in _IOLogBuilder.on_begin()

Each io record stores a relative time delta versus the previous record.
The initial message should really store the time since the start of
command, not the time since that particular class was instantiated

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: rename _IOLogBuilder to CommandIOLogBuilder

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: add tests for CommandIOLogBuilder

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: rename CommandOutputLogger to FallbackCommandOutputPrinter

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: add tests for FallbackCommandOuptutPrinter

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: add CommandOutputWriter

This class is intended to replace the usage of Redirect() in the JobRunner
code below. The particular semantics make it easier to handle teardown
in case of errors. It also opens the log files at the appropriate moment.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: add tests for CommandOutputWriter

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: improve delegate docstrings

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: add comment on future job api

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: use CommandOutputWriter instead of Redirect

Previously we've used Redirect to create verbatim log files on disk.
This was somewhat ugly for clean-up/termination point of view as stuff
might fail and open files would be left around until recycled by the
python garbage collector.

The CommandOutputWriter is a little smarter, opening the file only when
the command actually starts executing

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: small tweaks to how we setup extcmd plumbing

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
runner: tweak command startup/finish logging

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
"[r=sylvain-pineau,roadmr][bug=][author=zkrynicki] automatic merge by tarmac"
Launchpad automatic translations update.
runner: Fix delegate construction

Something got borked earlier and passed through testing (borked jenkins
setup, now fixed). Sorry about that

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Fix test-in-vagrant.sh integration tests

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Drop raring support from vagrant tools

Rarring does not work with virtualbox yet (guest stuff does not build
at all). Vagrant up hangs forever without this

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>