Esempio n. 1
0
    def _apply_overlay(src, dst, olist):
        tmp = TempFile("fsdelta-olist-")
        for fpath in olist:
            print >> tmp, fpath.lstrip('/')
        tmp.close()

        utils.apply_overlay(src, dst, tmp.path)
Esempio n. 2
0
def parun(commands, minheight=DEFAULT_MINHEIGHT, daemon=False, session_name=None):
    if (termcap_get_lines() - len(commands)) / len(commands) >= minheight:
        split = True
    else:
        split = False

    stdin = None
    if not os.isatty(sys.stdin.fileno()):
        stdin = TempFile()
        stdin.write(sys.stdin.read())
        stdin.close()

    # screen wants stdin to be connected to a tty
    os.dup2(sys.stderr.fileno(), sys.stdin.fileno())

    screens = fmt_screens(commands, stdin)
    if split:
        screenrc = "split\nfocus\n".join([ screen + "\n" for screen in screens ])
    else:
        screenrc = "\n".join(screens) + "\n" + "windowlist -b" + "\n"

    screenrc_tmp = TempFile()
    screenrc_tmp.write(screenrc)
    screenrc_tmp.close()

    args = ["-c", screenrc_tmp.path]
    if daemon:
        args += [ "-dm" ]

    if session_name:
        args += [ "-S", session_name ]

    executil.system("screen", *args)
    if daemon:
        time.sleep(1)
Esempio n. 3
0
    def _apply_overlay(src, dst, olist):
        tmp = TempFile("fsdelta-olist-")
        for fpath in olist:
            print >> tmp, fpath.lstrip('/')
        tmp.close()

        apply_overlay(src, dst, tmp.path)
Esempio n. 4
0
    def __init__(self):
        TempFile.__init__(self, prefix='key_')
        os.remove(self.path)

        executil.getoutput("ssh-keygen -N '' -f %s" % self.path)
        os.remove(self.path + ".pub")

        PrivateKey.__init__(self, self.path)
Esempio n. 5
0
    def __init__(self):
        TempFile.__init__(self, prefix='key_')
        os.remove(self.path)

        executil.getoutput("ssh-keygen -N '' -f %s" % self.path)
        os.remove(self.path + ".pub")

        PrivateKey.__init__(self, self.path)
    def _get_dirindex(path_dirindex_conf, path_rootfs):
        paths = dirindex.read_paths(file(path_dirindex_conf))
        paths = [re.sub(r'^(-?)', '\\1' + path_rootfs, path) for path in paths]

        tmp = TempFile()
        dirindex.create(tmp.path, paths)

        filtered = [
            re.sub(r'^' + path_rootfs, '', line)
            for line in file(tmp.path).readlines()
        ]
        return "".join(filtered)