本文整理汇总了Python中sh.which方法的典型用法代码示例。如果您正苦于以下问题:Python sh.which方法的具体用法?Python sh.which怎么用?Python sh.which使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sh
的用法示例。
在下文中一共展示了sh.which方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_bootable
# 需要导入模块: import sh [as 别名]
# 或者: from sh import which [as 别名]
def make_bootable(self):
""" Tworzenie dysku bootowalnego
"""
# self.uuid = re.search("UUID=\"(\w*)\"", str(sh.blkid(self.device + "1"))).group(1)
# print("Device UUID:", self.uuid)
# W niektórych wersjach windows katalog ten jest z drukowanej
def try_move(old_file, new_file):
try: sh.mv(old_file, new_file)
except:
print("File {} already exists, nothing to move".format(new_file))
self.boot_folder = self.destination_mount + "/boot"
try_move(self.destination_mount + "/BOOT", self.boot_folder)
try_move(self.destination_mount + "/BOOTMGR", self.destination_mount + "/bootmgr")
# Instalownie bootloadera
# grub-install --target=i386-pc --boot-directory="/<USB_mount_folder>/boot" /dev/sdX
installer = sh.Command(sh.which("grub-install")
or sh.which("grub2-install"))
installer(self.device, target="i386-pc", skip_fs_probe=True, force=True, boot_directory=self.destination_mount + "/boot")
# Tworzenie konfiguracji GRUBa
with open( "{}/{}/grub.cfg".format( self.boot_folder, "grub2" if str(installer).find("grub2") != -1 else "grub")
, "wt"
) as config:
config.write("""
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
menuentry 'Install Windows' {
ntldr /bootmgr
}
""")
示例2: test_run_command_with_debug
# 需要导入模块: import sh [as 别名]
# 或者: from sh import which [as 别名]
def test_run_command_with_debug(mocker, patched_print_debug):
cmd = sh.ls.bake(_env={"ANSIBLE_FOO": "foo", "MOLECULE_BAR": "bar"})
util.run_command(cmd, debug=True)
x = [
mocker.call("ANSIBLE ENVIRONMENT", "---\nANSIBLE_FOO: foo\n"),
mocker.call("MOLECULE ENVIRONMENT", "---\nMOLECULE_BAR: bar\n"),
mocker.call("SHELL REPLAY", "ANSIBLE_FOO=foo MOLECULE_BAR=bar"),
mocker.call("COMMAND", sh.which("ls")),
]
assert x == patched_print_debug.mock_calls
示例3: test_run_command_with_debug_handles_no_env
# 需要导入模块: import sh [as 别名]
# 或者: from sh import which [as 别名]
def test_run_command_with_debug_handles_no_env(mocker, patched_print_debug):
cmd = sh.ls.bake()
util.run_command(cmd, debug=True)
x = [
mocker.call("ANSIBLE ENVIRONMENT", "--- {}\n"),
mocker.call("MOLECULE ENVIRONMENT", "--- {}\n"),
mocker.call("SHELL REPLAY", ""),
mocker.call("COMMAND", sh.which("ls")),
]
assert x == patched_print_debug.mock_calls