Beispiel #1
0
def execute_plan(plan, index=None, verbose=False):
    if verbose:
        from console import setup_handlers
        setup_handlers()

    progress_cmds = set([EXTRACT, RM_EXTRACTED, LINK, UNLINK])
    prefix = config.root_dir
    i = None
    for cmd, arg in cmds_from_plan(plan):
        if i is not None and cmd in progress_cmds:
            i += 1
            getLogger('progress.update').info((name_dist(arg), i))

        if cmd == PREFIX:
            prefix = arg
        elif cmd == PRINT:
            getLogger('print').info(arg)
        elif cmd == FETCH:
            fetch(index, arg)
        elif cmd == PROGRESS:
            i = 0
            maxval = int(arg)
            getLogger('progress.start').info(maxval)
        elif cmd == EXTRACT:
            install.extract(config.pkgs_dir, arg)
        elif cmd == RM_EXTRACTED:
            install.rm_extracted(config.pkgs_dir, arg)
        elif cmd == RM_FETCHED:
            install.rm_fetched(config.pkgs_dir, arg)
        elif cmd == LINK:
            install.link(config.pkgs_dir, prefix, arg)
        elif cmd == UNLINK:
            install.unlink(prefix, arg)
        else:
            raise Exception("Did not expect command: %r" % cmd)

        if i is not None and cmd in progress_cmds and maxval == i:
            i = None
            getLogger('progress.stop').info(None)
Beispiel #2
0
pacman_packages = ["xmonad", "xmonad-contrib", "xorg-xmessage"]


if __name__ == "__main__":
    if os.getuid() != 0:
        sys.exit("This script needs to be run as root.")

    print("Xmonad install script.")
    print("")

    if platform.linux_distribution()[0] == "arch":
        install.pacman(pacman_packages)
    else:
        install.apt(apt_packages)
        print("")
        install.cabal(cabal_packages)
    print("")

    print("Creating symlinks...")
    print("")
    for fs, fd, d in files:
        basename = os.path.basename(fs)
        src = os.path.join("/home/sergey/.mcf/.xmonad", fs)
        dest = os.path.join(fd, basename) if basename else fd
        install.link(src, dest, d)
    print("")

    print("Installation ALMOST completed.")
    print("You will need to install xmonad panel manually:")
    print("      $", os.path.join(os.path.split(sys.argv[0])[0], "install-xmonad-panel.py"))