Open dickermoshe opened 1 year ago
I'd like to have that skip feature too for _pswindows.py#{L994:L1010}, Would something like the following work?
@wrap_exceptions
def open_files(self):
if self.pid in (0, 4):
return []
ret = set()
# Filenames come in in native format like:
# "\Device\HarddiskVolume1\Windows\systemew\file.txt"
# Convert the first part in the corresponding drive letter
# (e.g. "C:\") by using Windows's QueryDosDevice()
raw_file_names = cext.proc_open_files(self.pid)
for _file in raw_file_names:
_file = convert_dos_path(_file)
try:
if isfile_strict(_file):
if not PY3:
_file = py2_strencode(_file)
ntuple = _common.popenfile(_file, -1)
ret.add(ntuple)
except PermissionError:
continue
return list(ret)
Summary
Description
Using
psutil
without admin rights will cause manypsutil.AccessDenied
exceptions to be thrown. I've been using theopen_files()
without admin rights, everything goes perfectly, until the running program had a file open where the process does not have read rights, or cant access for another reason.The current logic for the
open_files()
is to crash ifos.stat(path)
crashes on one of the opened files. It would make more sense to skip files that crash and at least returns the ones that pass.In this case, running as admin does not help, the directory fails a
os.stat(path)
even with admin rights.The
C:\\$Extend\\$Deleted\\
directory always will raise aPermissionError
, even when running with admin rights.BUG: Any Process that has an open file in
C:\\$Extend\\$Deleted\\
will crash on aopen_files()
. FEATURE REQUEST: Add askip
parameter to theopen_files()
function to skip inaccessible files.Traceback