MCPcopy Index your code
hub / github.com/cirosantilli/linux-kernel-module-cheat / print_cmd

Method print_cmd

shell_helpers.py:117–138  ·  view source on GitHub ↗

Print cmd_to_string to stdout. Optionally save the command to cmd_file file, and add extra_env environment variables to the command generated. If cmd contains at least one LF, newlines are only added on LF. Otherwise, newlines are added automatically after

(self, cmd, cwd=None, cmd_file=None, extra_env=None, extra_paths=None)

Source from the content-addressed store, hash-verified

115 )
116
117 def print_cmd(self, cmd, cwd=None, cmd_file=None, extra_env=None, extra_paths=None):
118 '''
119 Print cmd_to_string to stdout.
120
121 Optionally save the command to cmd_file file, and add extra_env
122 environment variables to the command generated.
123
124 If cmd contains at least one LF, newlines are only added on LF.
125 Otherwise, newlines are added automatically after every word.
126 '''
127 if type(cmd) is str:
128 cmd_string = cmd
129 else:
130 cmd_string = self.cmd_to_string(cmd, cwd=cwd, extra_env=extra_env, extra_paths=extra_paths)
131 if not self.quiet:
132 self._print_thread_safe('+ ' + cmd_string)
133 if cmd_file is not None:
134 with open(cmd_file, 'w') as f:
135 f.write('#!/usr/bin/env bash\n')
136 f.write(cmd_string)
137 st = os.stat(cmd_file)
138 os.chmod(cmd_file, st.st_mode | stat.S_IXUSR)
139
140 def run_cmd(
141 self,

Callers 6

cpMethod · 0.95
run_cmdMethod · 0.95
rmrfMethod · 0.95
write_configsMethod · 0.95
write_string_to_fileMethod · 0.95
__call__Method · 0.80

Calls 2

cmd_to_stringMethod · 0.95
_print_thread_safeMethod · 0.95

Tested by

no test coverage detected