# Path: elbepack/shellhelper.py
# def do(cmd, allow_fail=False, stdin=None, env_add=None):
#     """do() - Execute cmd in a shell and redirect outputs to logging.
# 
#     Throws a CommandError if cmd failed with allow_Fail=False.
# 
#     --
# 
#     Let's redirect the loggers to current stdout
#     >>> import sys
#     >>> from elbepack.log import open_logging
#     >>> open_logging({"streams":sys.stdout})
# 
#     >>> do("true")
#     [CMD] true
# 
#     >>> do("false", allow_fail=True)
#     [CMD] false
# 
#     >>> do("cat -", stdin=b"ELBE")
#     [CMD] cat -
# 
#     >>> do("cat - && false", stdin=b"ELBE") # doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     elbepack.shellhelper.CommandError: ...
# 
#     >>> do("false") # doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     elbepack.shellhelper.CommandError: ...
#     """
# 
#     new_env = os.environ.copy()
#     if env_add:
#         new_env.update(env_add)
# 
#     if isinstance(stdin, str):
#         stdin = stdin.encode()
# 
#     logging.info(cmd, extra={"context":"[CMD] "})
# 
#     r, w = os.pipe()
# 
#     if stdin is None:
#         p = Popen(cmd, shell=True, stdout=w, stderr=STDOUT, env=new_env)
#     else:
#         p = Popen(cmd, shell=True, stdin=PIPE, stdout=w, stderr=STDOUT, env=new_env)
# 
#     async_logging(r, w, soap, log)
#     p.communicate(input=stdin)
# 
#     if p.returncode and not allow_fail:
#         raise CommandError(cmd, p.returncode)
# 
# def get_command_out(cmd, stdin=None, allow_fail=False, env_add=None):
#     """get_command_out() - Like do() but returns stdout.
# 
#     --
# 
#     Let's quiet the loggers
# 
#     >>> import os
#     >>> from elbepack.log import open_logging
#     >>> open_logging({"files":os.devnull})
# 
#     >>> get_command_out("echo ELBE")
#     b'ELBE\\n'
# 
#     >>> get_command_out("false") # doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     elbepack.shellhelper.CommandError: ...
# 
#     >>> get_command_out("false", allow_fail=True)
#     b''
# 
#     >>> get_command_out("cat -", stdin=b"ELBE", env_add={"TRUE":"true"})
#     b'ELBE'
# 
#     >>> get_command_out("cat -", stdin="ELBE", env_add={"TRUE":"true"})
#     b'ELBE'
#     """
# 
#     new_env = os.environ.copy()
# 
#     if env_add:
#         new_env.update(env_add)
# 
#     if isinstance(stdin, str):
#         stdin = stdin.encode()
# 
#     logging.info(cmd, extra={"context":"[CMD] "})
# 
#     r, w = os.pipe()
# 
#     if stdin is None:
#         p = Popen(cmd, shell=True, stdout=PIPE, stderr=w, env=new_env)
#     else:
#         p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=w, env=new_env)
# 
#     async_logging(r, w, soap, log)
#     stdout, _ = p.communicate(input=stdin)
# 
#     if p.returncode and not allow_fail:
#         raise CommandError(cmd, p.returncode)
# 
#     return stdout
# 
# class CommandError(Exception):
# 
#     def __init__(self, cmd, returncode):
#         super(CommandError, self).__init__(cmd, returncode)
#         self.returncode = returncode
#         self.cmd = cmd
# 
#     def __str__(self):
#         return "Error: %d returned from Command %s" % (
#             self.returncode, self.cmd)


import os
import time
from elbepack.shellhelper import do, get_command_out, CommandError
            self.fstype = entry.text("fs/type")
            self.mkfsopt = entry.text("fs/mkfs", default="")
            self.passno = entry.text("fs/passno", default="0")
            self.tune = entry.text("fs/tune2fs", default=None)

        self.id = str(fsid)

    def get_str(self):
        return "%s %s %s %s 0 %s\n" % (self.source, self.mountpoint,
                                       self.fstype, self.options, self.passno)

    def mountdepth(self):
        h = self.mountpoint
        depth = 0

        while True:
            h, t = os.path.split(h)
            if t == '':
                return depth
            depth += 1

    def get_label_opt(self):
        if self.fstype in ("ext4", "ext3", "ext2", "xfs", "btrfs"):
            return "-L " + self.label
        if self.fstype == "vfat":
            return "-n " + self.label
        return ""

    def tuning(self, loopdev):
        if self.tune:

# Path: elbepack/shellhelper.py
# def do(cmd, allow_fail=False, stdin=None, env_add=None):
#     """do() - Execute cmd in a shell and redirect outputs to logging.
# 
#     Throws a CommandError if cmd failed with allow_Fail=False.
# 
#     --
# 
#     Let's redirect the loggers to current stdout
#     >>> import sys
#     >>> from elbepack.log import open_logging
#     >>> open_logging({"streams":sys.stdout})
# 
#     >>> do("true")
#     [CMD] true
# 
#     >>> do("false", allow_fail=True)
#     [CMD] false
# 
#     >>> do("cat -", stdin=b"ELBE")
#     [CMD] cat -
# 
#     >>> do("cat - && false", stdin=b"ELBE") # doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     elbepack.shellhelper.CommandError: ...
# 
#     >>> do("false") # doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     elbepack.shellhelper.CommandError: ...
#     """
# 
#     new_env = os.environ.copy()
#     if env_add:
#         new_env.update(env_add)
# 
#     if isinstance(stdin, str):
#         stdin = stdin.encode()
# 
#     logging.info(cmd, extra={"context":"[CMD] "})
# 
#     r, w = os.pipe()
# 
#     if stdin is None:
#         p = Popen(cmd, shell=True, stdout=w, stderr=STDOUT, env=new_env)
#     else:
#         p = Popen(cmd, shell=True, stdin=PIPE, stdout=w, stderr=STDOUT, env=new_env)
# 
#     async_logging(r, w, soap, log)
#     p.communicate(input=stdin)
# 
#     if p.returncode and not allow_fail:
#         raise CommandError(cmd, p.returncode)
# 
# def get_command_out(cmd, stdin=None, allow_fail=False, env_add=None):
#     """get_command_out() - Like do() but returns stdout.
# 
#     --
# 
#     Let's quiet the loggers
# 
#     >>> import os
#     >>> from elbepack.log import open_logging
#     >>> open_logging({"files":os.devnull})
# 
#     >>> get_command_out("echo ELBE")
#     b'ELBE\\n'
# 
#     >>> get_command_out("false") # doctest: +ELLIPSIS
#     Traceback (most recent call last):
#     ...
#     elbepack.shellhelper.CommandError: ...
# 
#     >>> get_command_out("false", allow_fail=True)
#     b''
# 
#     >>> get_command_out("cat -", stdin=b"ELBE", env_add={"TRUE":"true"})
#     b'ELBE'
# 
#     >>> get_command_out("cat -", stdin="ELBE", env_add={"TRUE":"true"})
#     b'ELBE'
#     """
# 
#     new_env = os.environ.copy()
# 
#     if env_add:
#         new_env.update(env_add)
# 
#     if isinstance(stdin, str):
#         stdin = stdin.encode()
# 
#     logging.info(cmd, extra={"context":"[CMD] "})
# 
#     r, w = os.pipe()
# 
#     if stdin is None:
#         p = Popen(cmd, shell=True, stdout=PIPE, stderr=w, env=new_env)
#     else:
#         p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=w, env=new_env)
# 
#     async_logging(r, w, soap, log)
#     stdout, _ = p.communicate(input=stdin)
# 
#     if p.returncode and not allow_fail:
#         raise CommandError(cmd, p.returncode)
# 
#     return stdout
# 
# class CommandError(Exception):
# 
#     def __init__(self, cmd, returncode):
#         super(CommandError, self).__init__(cmd, returncode)
#         self.returncode = returncode
#         self.cmd = cmd
# 
#     def __str__(self):
#         return "Error: %d returned from Command %s" % (
#             self.returncode, self.cmd)


# Path: elbepack/fstab.py
import os
import time
from elbepack.shellhelper import do, get_command_out, CommandError

            self.fstype = entry.text("fs/type")
            self.mkfsopt = entry.text("fs/mkfs", default="")
            self.passno = entry.text("fs/passno", default="0")
            self.tune = entry.text("fs/tune2fs", default=None)

        self.id = str(fsid)

    def get_str(self):
        return "%s %s %s %s 0 %s\n" % (self.source, self.mountpoint,
                                       self.fstype, self.options, self.passno)

    def mountdepth(self):
        h = self.mountpoint
        depth = 0

        while True:
            h, t = os.path.split(h)
            if t == '':
                return depth
            depth += 1

    def get_label_opt(self):
        if self.fstype in ("ext4", "ext3", "ext2", "xfs", "btrfs"):
            return "-L " + self.label
        if self.fstype == "vfat":
            return "-n " + self.label
        return ""

    def tuning(self, loopdev):
        if self.tune:

            do('tune2fs %s %s' % (self.tune, loopdev))