plainbox:vendor:extcmd: don't SIGKILL stuff on windows

On windows, signal.kill(9) raises ValueError thus terribly breaking all
subsequent thread termination code. To prevent this two checks are made:
- if signal.SIGKILL doesn't exist we don't try to SIGKILL anything
- if the process exits gracefully we don't try to terminate it again

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:setup.py: make lxml dependency optional

This patch makes lxml dependency optional by removing it from
install_requires= section in setup.py and also by marking the affected
xml/html exporters as an optional add-on via the extras_require=
mechanics.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:color: add windows support via colorama

This patch adds rough support for Windows via colorama. If colorama is
installed then it is used to translate ANSI color sequences to
appropriate windows console commands. If colorama is not available then
windows just gets no color support at all.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:logging: change error.log to problem.log

This patch makes the error log file somewhat more useful by also
including warnings in it.  Often (porting to windows now) some problems
are only showing up as warnings but are a sign of a bigger issue. It is
useful to collect those.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:session:state: add hacky windows support

This patch adds a pretty hacky windows support (something that can be
fixed by extending the local device code but that is currently
incomplete) by making sure we don't return any of the POSIX-specific
execution controllers.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:session:storage: add windows support

This patch extends the generic save/load methods to handle windows on
python3.3 or newer. Windows-specific code is similar to the existing
python3.2 code (where we don't use the *at() family of functions) with
the notable difference of using binary mode and using os.replace()
instead of os.rename() which annoyingly enough doesn't allow us to
replace an existing file (but os.replace() does)

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:session:storage: improve save/load code

This patch applies some improvements made in the Windows-specific
version of the code to Unix variants of those methods.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:ctrl: make POSIX-specific imports optional

This patch makes plainbox.impl.ctrl importable on windows that lacks the
posix and grp modules. It still doesn't all us to use any of the
execution controllers on Windows but at least moves towards that option.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:ctrl: allow os.symlink() to fail on Windows

This patch allows Windows to vocally ignore all os.symlink() calls that
make up the construction of the execution environment (aka symlink
nest). This is not a good solution but it allows jobs that don't need
custom commands to work okay.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:ctrl: add support for user jobs on Windows

This patch adds support for running simple shell jobs on Windows.
Running as another user is not supported. Only jobs that advertise
windows support (by having the win32 flag set) can be started on
Windows.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:runner: add hacky windows support

This patch adds a pretty hacky windows support. It should be cleaned up
once all the execution controllers come from the device object and never
have to be guessed by all the code around.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:runner: fail gracefully on windows

This patch changes the JobRunner to fail gracefully by returning the
OUTCOME_NOT_SUPPORTED result when none of the execution controllers is
capable of running the requested job.

This change affects a private method that is unfortunately called by two
other places, the oldcli module in checkbox-ng (deprecated, will be
removed soon) and the script command that should be soon rewritten on
top of SessionManager alone. None of those places handle LookupError
that can be raised when the current device cannot execute a given job.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:commands:run: allow SessionPeekHelper.peek() to fail

This patch fixes a possible crash in 'plainbox run' that might happen if
the session data is corrupted in a way that would cause problems for the
peek machinery. This can happen if the gzip stream is damaged, for
example.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:providers:stubbox: add win.pxu

This patch adds a windows-specific unit file which defines a simple
"pass" style shell job that is suitable for running on Windows.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
plainbox:device: fix _discover_windows()

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