# Path: ssmlib/problem.py
# PROMPT_NONE =           0
# PROMPT_UNMOUNT =        1
# PROMPT_SET_DEFAULT =    2
# PROMPT_IGNORE =         3
# PROMPT_REMOVE =         4
# PROMPT_ADJUST =         5
# PROMPT_USE =            6
# PROMPT_CONTINUE =       7
# PROMPT_CREATE =         8
# PROMPT_MSG = [
#         None,
#         'Unmount',
#         'Set default',
#         'Ignore',
#         'Remove',
#         'Adjust',
#         'Use anyway',
#         'Continue',
#         'Create',
#         ]
# FL_NONE =               0
# FL_MSG_ONLY =           2
# FL_VERBOSE_ONLY =       (4 | FL_MSG_ONLY)
# FL_DEBUG_ONLY =         (8 | FL_MSG_ONLY)
# FL_DEFAULT_NO =         16
# FL_SILENT =             32
# FL_EXIT_ON_NO =         64
# FL_EXIT_ON_YES =        128
# FL_NO_MESSAGE =         256
# FL_FORCE_YES =          512
# FL_FORCE_NO =           1024
# FL_FATAL =              (2048 | FL_NO_MESSAGE)
# class SsmError(Exception):
# class GeneralError(SsmError):
# class ProgrammingError(SsmError):
# class FsMounted(SsmError):
# class BadEnvVariable(SsmError):
# class NotEnoughSpace(SsmError):
# class ResizeMatch(SsmError):
# class FsNotSpecified(SsmError):
# class DeviceUsed(SsmError):
# class NoDevices(SsmError):
# class ToolMissing(SsmError):
# class ToolMissingPrompt(SsmError):
# class CanNotRun(SsmError):
# class CommandFailed(SsmError):
# class UserInterrupted(SsmError):
# class NotSupported(SsmError):
# class ExistingFilesystem(SsmError):
# class NotImplemented(SsmError):
# class WeakPassword(SsmError):
# class ExistingSignature(SsmError):
# class DuplicateTarget(SsmError):
# class ProblemSet(object):
#     def __init__(self, msg, errcode=None):
#     def __str__(self):
#     def __init__(self, msg, errcode=2001):
#     def __init__(self, msg, errcode=2002):
#     def __init__(self, msg, errcode=2003):
#     def __init__(self, msg, errcode=2004):
#     def __init__(self, msg, errcode=2005):
#     def __init__(self, msg, errcode=2006):
#     def __init__(self, msg, errcode=2007):
#     def __init__(self, msg, errcode=2008):
#     def __init__(self, msg, errcode=2009):
#     def __init__(self, msg, errcode=2010):
#     def __init__(self, msg, errcode=2010):
#     def __init__(self, msg, errcode=2011):
#     def __init__(self, msg, errcode=2012, exitcode=-1):
#     def __init__(self, msg, errcode=2013):
#     def __init__(self, msg, errcode=2014):
#     def __init__(self, msg, errcode=2015):
#     def __init__(self, msg, errcode=2016):
#     def __init__(self, msg, errcode=2017):
#     def __init__(self, msg, errcode=2018):
#     def __init__(self, msg, errcode=2019):
#     def __init__(self, options):
#     def set_options(self, options):
#     def init_problem_set(self):
#     def _can_print_message(self, flags):
#     def _read_char(self):
#     def _ask_question(self, flags):
#     def check(self, problem, args):
#     def error(self, args):
#     def info(self, args):
#     def warn(self, args):
#     def not_supported(self, args):


import os
import re
import sys
import stat
import tempfile
import threading
import subprocess
            import fcntl
            import termios
            import struct
from ssmlib import problem
from base64 import encode
        stdout = subprocess.PIPE

    # Convert all parts of cmd into string
    for i, item in enumerate(cmd):
        if not isinstance(item, str):
            cmd[i] = str(item)

    if VERBOSE_VV_FLAG:
        print('executing command: {}'.format(' '.join(cmd)))

    proc = subprocess.Popen(cmd, stdout=stdout,
                            stderr=stderr, stdin=stdin, close_fds=True)

    output, error = proc.communicate(input=stdin_data)

    err_msg = "ERROR exit code {0} for running command: \"{1}\"".format(
              proc.returncode, " ".join(cmd))

    if proc.returncode != 0 and show_cmd:
        if output is not None:
            print(output)
        if error is not None:
            print(error)
        sys.stderr.write(err_msg + '\n')

    if proc.returncode != 0 and not can_fail:
        if output is not None:
            print(output)
        if error is not None:
            print(error)

# Path: ssmlib/problem.py
# PROMPT_NONE =           0
# PROMPT_UNMOUNT =        1
# PROMPT_SET_DEFAULT =    2
# PROMPT_IGNORE =         3
# PROMPT_REMOVE =         4
# PROMPT_ADJUST =         5
# PROMPT_USE =            6
# PROMPT_CONTINUE =       7
# PROMPT_CREATE =         8
# PROMPT_MSG = [
#         None,
#         'Unmount',
#         'Set default',
#         'Ignore',
#         'Remove',
#         'Adjust',
#         'Use anyway',
#         'Continue',
#         'Create',
#         ]
# FL_NONE =               0
# FL_MSG_ONLY =           2
# FL_VERBOSE_ONLY =       (4 | FL_MSG_ONLY)
# FL_DEBUG_ONLY =         (8 | FL_MSG_ONLY)
# FL_DEFAULT_NO =         16
# FL_SILENT =             32
# FL_EXIT_ON_NO =         64
# FL_EXIT_ON_YES =        128
# FL_NO_MESSAGE =         256
# FL_FORCE_YES =          512
# FL_FORCE_NO =           1024
# FL_FATAL =              (2048 | FL_NO_MESSAGE)
# class SsmError(Exception):
# class GeneralError(SsmError):
# class ProgrammingError(SsmError):
# class FsMounted(SsmError):
# class BadEnvVariable(SsmError):
# class NotEnoughSpace(SsmError):
# class ResizeMatch(SsmError):
# class FsNotSpecified(SsmError):
# class DeviceUsed(SsmError):
# class NoDevices(SsmError):
# class ToolMissing(SsmError):
# class ToolMissingPrompt(SsmError):
# class CanNotRun(SsmError):
# class CommandFailed(SsmError):
# class UserInterrupted(SsmError):
# class NotSupported(SsmError):
# class ExistingFilesystem(SsmError):
# class NotImplemented(SsmError):
# class WeakPassword(SsmError):
# class ExistingSignature(SsmError):
# class DuplicateTarget(SsmError):
# class ProblemSet(object):
#     def __init__(self, msg, errcode=None):
#     def __str__(self):
#     def __init__(self, msg, errcode=2001):
#     def __init__(self, msg, errcode=2002):
#     def __init__(self, msg, errcode=2003):
#     def __init__(self, msg, errcode=2004):
#     def __init__(self, msg, errcode=2005):
#     def __init__(self, msg, errcode=2006):
#     def __init__(self, msg, errcode=2007):
#     def __init__(self, msg, errcode=2008):
#     def __init__(self, msg, errcode=2009):
#     def __init__(self, msg, errcode=2010):
#     def __init__(self, msg, errcode=2010):
#     def __init__(self, msg, errcode=2011):
#     def __init__(self, msg, errcode=2012, exitcode=-1):
#     def __init__(self, msg, errcode=2013):
#     def __init__(self, msg, errcode=2014):
#     def __init__(self, msg, errcode=2015):
#     def __init__(self, msg, errcode=2016):
#     def __init__(self, msg, errcode=2017):
#     def __init__(self, msg, errcode=2018):
#     def __init__(self, msg, errcode=2019):
#     def __init__(self, options):
#     def set_options(self, options):
#     def init_problem_set(self):
#     def _can_print_message(self, flags):
#     def _read_char(self):
#     def _ask_question(self, flags):
#     def check(self, problem, args):
#     def error(self, args):
#     def info(self, args):
#     def warn(self, args):
#     def not_supported(self, args):


# Path: ssmlib/misc.py
import os
import re
import sys
import stat
import tempfile
import threading
import subprocess
            import fcntl
            import termios
            import struct
from ssmlib import problem
from base64 import encode

        stdout = subprocess.PIPE

    # Convert all parts of cmd into string
    for i, item in enumerate(cmd):
        if not isinstance(item, str):
            cmd[i] = str(item)

    if VERBOSE_VV_FLAG:
        print('executing command: {}'.format(' '.join(cmd)))

    proc = subprocess.Popen(cmd, stdout=stdout,
                            stderr=stderr, stdin=stdin, close_fds=True)

    output, error = proc.communicate(input=stdin_data)

    err_msg = "ERROR exit code {0} for running command: \"{1}\"".format(
              proc.returncode, " ".join(cmd))

    if proc.returncode != 0 and show_cmd:
        if output is not None:
            print(output)
        if error is not None:
            print(error)
        sys.stderr.write(err_msg + '\n')

    if proc.returncode != 0 and not can_fail:
        if output is not None:
            print(output)
        if error is not None:
            print(error)

        raise problem.CommandFailed(err_msg, exitcode=proc.returncode)