當前位置: 首頁>>代碼示例>>Python>>正文


Python Command.execute方法代碼示例

本文整理匯總了Python中rpg.command.Command.execute方法的典型用法代碼示例。如果您正苦於以下問題:Python Command.execute方法的具體用法?Python Command.execute怎麽用?Python Command.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rpg.command.Command的用法示例。


在下文中一共展示了Command.execute方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: copy_dir

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import execute [as 別名]
    def copy_dir(self, path, ex_dir):
        """ Copies directory tree and adds command to
            prep macro """

        prep = Command("cp -rf " + path + " " + ex_dir)
        prep.execute()
        self.prep.append(str(prep))
開發者ID:Shootervm,項目名稱:rpg,代碼行數:9,代碼來源:source_loader.py

示例2: create_archive

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import execute [as 別名]
 def create_archive(self):
     """ Creates archive (archvie_path) from Source folder """
     self.spec.Source = self.spec.Name + "-" + self.spec.Version + ".tar.gz"
     _tar = Command("tar zcf " + str(self.archive_path) +
                    " -C " + str(self.extracted_dir) +
                    " . --transform='s/^\./" +
                    self.spec.Name + "-" + self.spec.Version + "/g'")
     _tar.execute()
     logging.debug(str(_tar))
開發者ID:FLuptak,項目名稱:rpg,代碼行數:11,代碼來源:__init__.py

示例3: test_command_execute_from

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import execute [as 別名]
    def test_command_execute_from(self):
        cmd = Command("pwd\ncd c 2>/dev/null\npwd")
        output = cmd.execute(self.test_project_dir)
        path = path_to_str(self.test_project_dir.resolve())
        expected = "%s\n%s/c\n" % (path, path)
        self.assertEqual(expected, output)

        # doesn't add 'cd work_dir' during execute to command lines
        cur_dir = Path('.')
        with self.assertRaises(subprocess.CalledProcessError) as ctx:
            cmd.execute(cur_dir)
        expected = "Command '['/bin/sh', '-c', 'cd %s "\
                   "&& pwd && cd c 2>/dev/null && pwd']' "\
                   "returned non-zero exit status 1"\
                   % path_to_str(cur_dir.resolve())
        self.assertEqual(expected, str(ctx.exception))
開發者ID:LukasSlouka,項目名稱:rpg,代碼行數:18,代碼來源:test_command.py

示例4: extract

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import execute [as 別名]
    def extract(self, arch, extract, compr):
        """ Extracts files from archive """

        prep = Command()
        if compr[0] == "tar":
            tar_compr = ""
            if compr[1] == "xz":
                tar_compr = "J"
            elif compr[1] == "gz":
                tar_compr = "z"
            elif compr[1] == "bz2":
                tar_compr = "j"
            elif compr[1] == "lz":
                tar_compr = "--lzip "
            elif compr[1] == "xz":
                tar_compr = "z"
            elif compr[1] == "lzma":
                tar_compr = "--lzma "
            else:
                raise SystemExit("Internal error: Unknown compression \
                    method: " + compr)
            prep.append("tar " + tar_compr + "xf " +
                        arch + " -C " + extract)
        elif compr[0] == "tgz":
            prep.append("tar xzf " + arch + " -C " + extract)
        elif compr[0] == "tbz2":
            prep.append("tar xjf " + arch + " -C " + extract)
        elif compr[0] == "zip":
            prep.append("unzip " + arch + " -d " + extract)
        elif compr[0] == "rar":
            prep.append("unrar x " + arch + " " + extract)
        elif compr[0] == "7z":
            prep.append("7z x " + arch + " -o " + extract)
        else:
            raise SystemExit("Internal error: Unknown compression \
                method: " + compr[0] + "." + compr[1])
        prep.execute()
        self.prep.append(str(prep))
開發者ID:Shootervm,項目名稱:rpg,代碼行數:40,代碼來源:source_loader.py

示例5: test_execute

# 需要導入模塊: from rpg.command import Command [as 別名]
# 或者: from rpg.command.Command import execute [as 別名]
 def test_execute(self):
     cmd = Command("echo bla")
     output = cmd.execute()
     self.assertEqual("bla\n", output)
開發者ID:regeciovad,項目名稱:rpg,代碼行數:6,代碼來源:test_command.py


注:本文中的rpg.command.Command.execute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。