How to use the rebasehelper.utils.ProcessHelper.run_subprocess function in rebasehelper

To help you get started, we’ve selected a few rebasehelper 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 rebase-helper / rebase-helper / test / test_utils.py View on Github external
def test_simple_cmd_with_redirected_output_path(self):
            ret = ProcessHelper.run_subprocess(self.ECHO_COMMAND,
                                               output=self.OUT_FILE)
            assert ret == 0
            assert os.path.exists(self.OUT_FILE)
            assert open(self.OUT_FILE).readline().strip('\n') == self.PHRASE
github rebase-helper / rebase-helper / test / test_utils.py View on Github external
def test_simple_cmd_with_input_path_and_redirected_output_path(self):
            with open(self.IN_FILE, 'w') as f:
                f.write(self.PHRASE)

            assert os.path.exists(self.IN_FILE)
            assert open(self.IN_FILE).readline().strip('\n') == self.PHRASE

            ret = ProcessHelper.run_subprocess(self.CAT_COMMAND,
                                               input=self.IN_FILE,
                                               output=self.OUT_FILE)
            assert ret == 0
            assert os.path.exists(self.OUT_FILE)
            assert open(self.OUT_FILE).readline().strip('\n') == self.PHRASE
github rebase-helper / rebase-helper / test / test_utils.py View on Github external
def test_simple_cmd_with_input_fileobject_and_redirected_output_path(self):
            in_buff = StringIO()
            in_buff.write(self.PHRASE)

            assert not os.path.exists(self.IN_FILE)
            in_buff.seek(0)
            assert in_buff.readline().strip('\n') == self.PHRASE

            ret = ProcessHelper.run_subprocess(self.CAT_COMMAND,
                                               input=in_buff,
                                               output=self.OUT_FILE)
            in_buff.close()
            assert ret == 0
            assert os.path.exists(self.OUT_FILE)
            assert open(self.OUT_FILE).readline().strip('\n') == self.PHRASE
github rebase-helper / rebase-helper / test / test_utils.py View on Github external
def test_simple_cmd_with_input_path_and_redirected_output_fileobject(self):
            out_buff = StringIO()
            with open(self.IN_FILE, 'w') as f:
                f.write(self.PHRASE)

            assert os.path.exists(self.IN_FILE)
            assert open(self.IN_FILE).readline().strip('\n') == self.PHRASE

            ret = ProcessHelper.run_subprocess(self.CAT_COMMAND,
                                               input=self.IN_FILE,
                                               output=out_buff)
            assert ret == 0
            assert not os.path.exists(self.OUT_FILE)
            out_buff.seek(0)
            assert out_buff.readline().strip('\n') == self.PHRASE
            out_buff.close()
github rebase-helper / rebase-helper / test / test_utils.py View on Github external
def test_simple_cmd_with_input_fileobject_and_redirected_output_fileobject(self):
            out_buff = StringIO()
            in_buff = StringIO()
            in_buff.write(self.PHRASE)

            assert not os.path.exists(self.IN_FILE)
            in_buff.seek(0)
            assert in_buff.readline().strip('\n') == self.PHRASE

            ret = ProcessHelper.run_subprocess(self.CAT_COMMAND,
                                               input=in_buff,
                                               output=out_buff)
            in_buff.close()
            assert ret == 0
            assert not os.path.exists(self.OUT_FILE)
            out_buff.seek(0)
            assert out_buff.readline().strip('\n') == self.PHRASE
            out_buff.close()
github rebase-helper / rebase-helper / test / test_utils.py View on Github external
def test_simple_cmd(self):
            ret = ProcessHelper.run_subprocess(self.TOUCH_COMMAND)
            assert ret == 0
            assert os.path.exists(self.TEMP_FILE)
github rebase-helper / rebase-helper / rebasehelper / diff_helper.py View on Github external
def run_diff(cls, old, new):
        logger.debug("running diff")

        cmd = [cls.CMD, '--diff', old, new]
        return ProcessHelper.run_subprocess(cmd, output=ProcessHelper.DEV_NULL)
github rebase-helper / rebase-helper / rebasehelper / diff_helper.py View on Github external
def run_mergetool(cls, old_dir, new_dir, failed_files):

        logger.debug("running merge")

        for index, fname in enumerate(failed_files):
            base = os.path.join(old_dir, fname)  # old w/o patch
            remote = os.path.join(old_dir, fname)  # new with patch
            local = os.path.join(new_dir, fname)  # new w/o patch
            merged = os.path.join(new_dir, fname)

            # http://stackoverflow.com/questions/11133290/git-merging-using-meld
            cmd = [cls.CMD, '--diff', base, local, '--diff', base, remote, '--auto-merge', local, base, remote, '--output', merged]

            ProcessHelper.run_subprocess(cmd, output=ProcessHelper.DEV_NULL)

            if len(failed_files) > 1 and index < len(failed_files) - 1:
                if not ConsoleHelper.get_message('Do you want to merge another file'):
                    raise KeyboardInterrupt
github rebase-helper / rebase-helper / rebasehelper / pkgdiff_checker.py View on Github external
def run_check(cls, **kwargs):
        """ Compares  old and new RPMs using pkgdiff """
        versions = ['old', 'new']
        cmd = [cls.CMD]
        for version in versions:
            old = kwargs.get(version, None)
            if old:
                file_name = cls._create_xml(version, input_structure=old)
                cmd.append(file_name)
        cmd.append('-report-path')
        cmd.append(cls.pkg_diff_result_path)
        # TODO Should we return a value??
        ProcessHelper.run_subprocess(cmd, output=ProcessHelper.DEV_NULL)
        return cls.pkg_diff_result_path