本文整理汇总了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))
示例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))
示例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))
示例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))
示例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)