MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / CMD_helper

Class CMD_helper

deps/memkind/src/test/python_framework/cmd_helper.py:30–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28import subprocess
29
30class CMD_helper(object):
31
32 def execute_cmd(self, command, sudo=False):
33 if sudo:
34 command = "sudo {0}".format(command)
35 #Initialize temp file for stdout. Will be removed when closed.
36 outfile = tempfile.SpooledTemporaryFile()
37 try:
38 #Invoke process
39 p = subprocess.Popen(command, stdout=outfile, stderr=subprocess.STDOUT, shell=True)
40 p.communicate()
41 #Read stdout from file
42 outfile.seek(0)
43 stdout = outfile.read()
44 except:
45 raise
46 finally:
47 #Make sure the file is closed
48 outfile.close()
49 retcode = p.returncode
50 return stdout, retcode
51
52 def get_command_path(self, binary):
53 """Get the path to the binary."""
54 path = os.path.dirname(os.path.abspath(__file__))
55 return os.path.join(path, binary)

Callers 4

Test_autohbwClass · 0.90
Test_hbw_detectionClass · 0.90
Huge_page_organizerClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected