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


Python sh.which方法代碼示例

本文整理匯總了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
                }
            """) 
開發者ID:Mati365,項目名稱:pyWinUSB,代碼行數:35,代碼來源:creator.py

示例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 
開發者ID:ansible-community,項目名稱:molecule,代碼行數:13,代碼來源:test_util.py

示例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 
開發者ID:ansible-community,項目名稱:molecule,代碼行數:13,代碼來源:test_util.py


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