from subprocess import PIPE
import subprocess
result = subprocess.run(['ps','-C','gedit','-o','pid='], stdout=PIPE)
h=str(int(result.stdout))
print (str(h))
presult = subprocess.run(['lsof','-p',str(h)], stdout=PIPE)
#print (repr(str(presult.stdout)))
##    print (str(line))
filename='/home/dewachen/Documents/mining.txt'
if filename in str(presult.stdout):
    print ('trouve')
##def has_handle(fpath):
##    for proc in psutil.process_iter():
##        try:
##            print (str(proc))
##            for item in proc.open_files():
##                print (str(item.path))
##                if fpath == item.path:
##                    return proc
##        except Exception:
##            pass
##
##    return 0
##x=has_handle(filename)
##print (str(x))
