# Path: acpype/utils.py
# def _getoutput(cmd):
#     """
#     To simulate commands.getoutput
#     shell=True is necessary despite security issues
#     """
#     out = sub.Popen(cmd, shell=True, stderr=sub.STDOUT, stdout=sub.PIPE).communicate()[0][:-1]
#     return out.decode()


import fnmatch
import os
import sys
from acpype.utils import _getoutput

allTotal = len(ccpCodes) * 2
jobsOK = []  # list of Mols that have at least a PDB or IDEAL clean: [[both],[pdb,ideal]]
totalTxt = ""
for group in groupResults:
    header, subHead, dummy, lista = group
    if "Mols clean" == subHead:
        jobsOK = lista
    subTot = printResults(lista, subHead, header)
    if not subTot:
        continue
    totalTxt += "+ %i " % subTot
totalTxt = totalTxt[2:]
sumVal = eval(totalTxt)
print(f"{totalTxt}= {sumVal}")

# print results

# print 'execTime', execTime

# print 'jobsOK', jobsOK

if atomicDetailed:
    print("\n>>> Detailed report per atom <<<\n")

    if ET1:
        print("=>Mols have duplicated coordinates")
        for molLabel in ET1:
            mol, structure = molLabel.split("_")
            cmd = f"grep -e '^ATOM' {mol}/*{structure}.out"

# Path: acpype/utils.py
# def _getoutput(cmd):
#     """
#     To simulate commands.getoutput
#     shell=True is necessary despite security issues
#     """
#     out = sub.Popen(cmd, shell=True, stderr=sub.STDOUT, stdout=sub.PIPE).communicate()[0][:-1]
#     return out.decode()


# Path: scripts/analyse_test_acpype_db_ligands.py
import fnmatch
import os
import sys
from acpype.utils import _getoutput


allTotal = len(ccpCodes) * 2
jobsOK = []  # list of Mols that have at least a PDB or IDEAL clean: [[both],[pdb,ideal]]
totalTxt = ""
for group in groupResults:
    header, subHead, dummy, lista = group
    if "Mols clean" == subHead:
        jobsOK = lista
    subTot = printResults(lista, subHead, header)
    if not subTot:
        continue
    totalTxt += "+ %i " % subTot
totalTxt = totalTxt[2:]
sumVal = eval(totalTxt)
print(f"{totalTxt}= {sumVal}")

# print results

# print 'execTime', execTime

# print 'jobsOK', jobsOK

if atomicDetailed:
    print("\n>>> Detailed report per atom <<<\n")

    if ET1:
        print("=>Mols have duplicated coordinates")
        for molLabel in ET1:
            mol, structure = molLabel.split("_")
            cmd = f"grep -e '^ATOM' {mol}/*{structure}.out"

            out = _getoutput(cmd)