How to use the kas.libkas.run_cmd function in kas

To help you get started, we’ve selected a few kas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github siemens / kas / tests / test_refspec.py View on Github external
"""
    tdir = str(tmpdir.mkdir('test_refspec_switch'))
    shutil.rmtree(tdir, ignore_errors=True)
    shutil.copytree('tests/test_refspec', tdir)
    os.chdir(tdir)

    kas.kas(['shell', 'test.yml', '-c', 'true'])
    (rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas',
                           fail=False, liveupdate=False)
    assert rc != 0
    assert output.strip() == ''
    (rc, output) = run_cmd(['git', 'rev-parse', '-q', 'HEAD'], cwd='kas',
                           fail=False, liveupdate=False)
    assert rc == 0
    assert output.strip() == '907816a5c4094b59a36aec12226e71c461c05b77'
    (rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas2',
                           fail=False, liveupdate=False)
    assert rc == 0
    assert output.strip() == 'refs/heads/master'

    kas.kas(['shell', 'test2.yml', '-c', 'true'])
    (rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas',
                           fail=False, liveupdate=False)
    assert rc == 0
    assert output.strip() == 'refs/heads/master'
    (rc, output) = run_cmd(['git', 'symbolic-ref', '-q', 'HEAD'], cwd='kas2',
                           fail=False, liveupdate=False)
    assert rc != 0
    assert output.strip() == ''
    (rc, output) = run_cmd(['git', 'rev-parse', '-q', 'HEAD'], cwd='kas2',
                           fail=False, liveupdate=False)
    assert rc == 0
github siemens / kas / kas / build.py View on Github external
def execute(self, ctx):
        """
            Executes the bitbake build command.
        """
        # Start bitbake build of image
        bitbake = find_program(ctx.environ['PATH'], 'bitbake')
        cmd = [bitbake, '-k', '-c', ctx.config.get_bitbake_task()] \
            + self.extra_bitbake_args + ctx.config.get_bitbake_targets()
        if sys.stdout.isatty():
            logging.info('%s$ %s', ctx.build_dir, ' '.join(cmd))
            ret = subprocess.call(cmd, env=ctx.environ, cwd=ctx.build_dir)
            if ret != 0:
                logging.error('Command returned non-zero exit status %d', ret)
                sys.exit(ret)
        else:
            run_cmd(cmd, cwd=ctx.build_dir)
github siemens / kas / kas / repos.py View on Github external
def checkout(self):
        """
            Checks out the correct revision of the repo.
        """
        if self.operations_disabled or self.refspec is None:
            return

        if not get_context().force_checkout:
            # Check if repos is dirty
            (_, output) = run_cmd(self.is_dirty_cmd(),
                                  cwd=self.path,
                                  fail=False)
            if output:
                logging.warning('Repo %s is dirty - no checkout', self.name)
                return

        (_, output) = run_cmd(self.resolve_branch_cmd(),
                              cwd=self.path, fail=False)
        if output:
            desired_ref = output.strip()
            branch = True
        else:
            desired_ref = self.refspec
            branch = False

        run_cmd(self.checkout_cmd(desired_ref, branch), cwd=self.path)
github siemens / kas / kas / repos.py View on Github external
cwd=self.path,
                                  fail=False)
            if output:
                logging.warning('Repo %s is dirty - no checkout', self.name)
                return

        (_, output) = run_cmd(self.resolve_branch_cmd(),
                              cwd=self.path, fail=False)
        if output:
            desired_ref = output.strip()
            branch = True
        else:
            desired_ref = self.refspec
            branch = False

        run_cmd(self.checkout_cmd(desired_ref, branch), cwd=self.path)
github siemens / kas / kas / repos.py View on Github external
"""
            Checks out the correct revision of the repo.
        """
        if self.operations_disabled or self.refspec is None:
            return

        if not get_context().force_checkout:
            # Check if repos is dirty
            (_, output) = run_cmd(self.is_dirty_cmd(),
                                  cwd=self.path,
                                  fail=False)
            if output:
                logging.warning('Repo %s is dirty - no checkout', self.name)
                return

        (_, output) = run_cmd(self.resolve_branch_cmd(),
                              cwd=self.path, fail=False)
        if output:
            desired_ref = output.strip()
            branch = True
        else:
            desired_ref = self.refspec
            branch = False

        run_cmd(self.checkout_cmd(desired_ref, branch), cwd=self.path)
github siemens / kas / kas / repos.py View on Github external
def get_root_path(path, fallback=True):
        """
            Checks if path is under version control and returns its root path.
        """
        (ret, output) = run_cmd(['git', 'rev-parse', '--show-toplevel'],
                                cwd=path, fail=False, liveupdate=False)
        if ret == 0:
            return output.strip()

        (ret, output) = run_cmd(['hg', 'root'],
                                cwd=path, fail=False, liveupdate=False)
        if ret == 0:
            return output.strip()

        return path if fallback else None
github siemens / kas / kas / repos.py View on Github external
def get_root_path(path, fallback=True):
        """
            Checks if path is under version control and returns its root path.
        """
        (ret, output) = run_cmd(['git', 'rev-parse', '--show-toplevel'],
                                cwd=path, fail=False, liveupdate=False)
        if ret == 0:
            return output.strip()

        (ret, output) = run_cmd(['hg', 'root'],
                                cwd=path, fail=False, liveupdate=False)
        if ret == 0:
            return output.strip()

        return path if fallback else None