Python sh.which() Examples
The following are 3
code examples of sh.which().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sh
, or try the search function
.
Example #1
Source File: creator.py From pyWinUSB with MIT License | 5 votes |
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 } """)
Example #2
Source File: test_util.py From molecule with MIT License | 5 votes |
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
Example #3
Source File: test_util.py From molecule with MIT License | 5 votes |
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