Esempio n. 1
0
    def link(self):
        """Link this file from source to destination"""

        if self.path_source is not None:
            full_source_path = os.path.join(
                os.path.expandvars(self.path_source), self.name)
            full_destination_path = os.path.join(
                os.path.expandvars(self.path_destination), self.name)

            try:
                if self.sudo:
                    spawn.process(
                        f'ln -sfv "{full_source_path}" "{full_destination_path}"',
                        sudo=True,
                    )
                else:
                    os.symlink(full_source_path, full_destination_path)
            except FileExistsError:
                message.error(
                    "Can't symlink, file already exists at destination. Attempting fix."
                )
                os.remove(full_destination_path)
                message.info(f"Removed: '{full_destination_path}'")
                os.symlink(full_source_path, full_destination_path)
            finally:
                message.info(
                    f"Symlink created: '{full_source_path}' <--> '{full_destination_path}'"
                )
        else:
            message.error(
                f"'{self.name}' has no source from which to create a link from."
            )
Esempio n. 2
0
    def configure(self):
        """Run commands to configure the package
        Afterwards, move configuration files in place.
        """

        if len(self.post_install_commands) > 0:
            message.normal(
                f"Running commands to configure {self.display_name}")

        for _file in self.files:
            _file.configure()

        for command in self.post_install_commands:
            spawn.process(os.path.expandvars(command))
Esempio n. 3
0
    def copy(self):
        """Copy this file from source to destination"""

        if self.path_source is not None:
            full_source_path = os.path.join(
                os.path.expandvars(self.path_source), self.name)

            if self.sudo:
                spawn.process(
                    f'cp -v -- "{full_source_path}" "{self.path_destination}"',
                    sudo=True,
                )
            else:
                message.info(
                    f"Copied: '{full_source_path}' --> '{self.path_destination}'"
                )
                shutil.copy(full_source_path, self.path_destination)
        else:
            message.error(
                f"'{self.name}' has no source from which to copy from.")
Esempio n. 4
0
def sync(args=""):
    """Sync repos and install packages"""

    spawn.process(f"{config.aur_helper} --noconfirm -Sua {args}")
    log.write("Synced AUR packages")
Esempio n. 5
0
def install(args):
    """Install packages, no sync"""

    if len(args) > 0:
        spawn.process(f"{config.aur_helper} --noconfirm -S {args}")
        log.write(f"(AUR) Installed: {args}")
Esempio n. 6
0
def install(args):
    """Install packages"""

    if len(args) > 0:
        spawn.process(f"pip install {args}")
        log.write(f"(PIP) Installed: {args}")
Esempio n. 7
0
def sync(args=""):
    """Sync repos and install packages"""

    spawn.process(f"pacman --noconfirm -Syu {args}", sudo=True)
    log.write("Synced all repos with pacman.sync()")
Esempio n. 8
0
def install(args):
    """Install packages, no sync"""

    if len(args) > 0:
        spawn.process(f"pacman --noconfirm --needed -S {args}", sudo=True)
        log.write(f"(PACMAN) Installed: {args}")
Esempio n. 9
0
def test_failure():
    """Test a failure"""
    config.seconds_to_wait_on_fail = 0
    result = spawn.process(COMMAND_FAIL)

    assert result.args == ["echo"]
Esempio n. 10
0
def test_capture():
    """Test output capture"""
    result = spawn.process(COMMAND, capture=True)

    assert result == " ".join(COMMAND.split()[2:])
Esempio n. 11
0
def test_success():
    """Normal execution with normal command"""
    result = spawn.process(COMMAND)

    assert isinstance(result, CompletedProcess)
    assert result.args == COMMAND.split()