in src/neuron-gatherinfo/neuron-gatherinfo.py [0:0]
def dump_miscinfo(*, outdir, verbose):
''' function to dump miscellaneous information, including:
- system info (uname -a)
- package info (??? list of packages installed)
- neuron-ls
- neuron-top
Args:
outdir : output directory
verbose : flag to indicate if verbose messages need to be displayed
Output:
Creates various reports in the outdir location
Returns:
'''
osver = get_os_version()
if osver == 'Ubuntu':
pkgcmds = ["apt list | egrep '^aws'",
"pip list | egrep '^neuron|^numpy|^tensor|^scipy'"]
else:
pkgcmds = ["rpm -qa | egrep '^aws|^neuron|^numpy|^tensor|^scipy'"]
cmds = EXTERNAL_CMDS + pkgcmds
for cmd in cmds:
cmdname = cmd.split(' ')[0] # get just the command name for creating the file
cmdfile = os.path.join(outdir, "report-{}.txt".format(cmdname))
with open(cmdfile, "w") as fdout:
if verbose:
print("Running cmd: {} and capturing output in file: {}".format(cmd, cmdfile))
try:
res = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, universal_newlines=True,
shell=True)
stdout, stderr = res.communicate()
if stderr is not None:
fdout.write("Error in executing cmd: {}\nError: {}\n".format(cmd, str(stderr)))
else:
fdout.write("Output from executing cmd: {}\n\n{}\n".format(cmd, str(stdout)))
except (OSError, ValueError) as err:
fdout.write("Error in executing cmd: {}\nError: {}\n".format(cmd, err))