PYTSK无法检索文件类型

2024-10-01 00:14:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试从windows VHD获取所有文件。 在文件项上调用.info.info.meta.type时,它并不总是起作用并抛出错误。有没有办法检索这些文件?你知道吗

filesystemObject = pytsk3.FS_Info(imagehandle, offset=(partition.start * metric.block_size))
except:
    print "Partition has no supported file system"
    continue
print "File System Type Dectected ", filesystemObject.info.ftype
directoryObject = filesystemObject.open_dir(path=dirPath)
 for entryObject in directoryObject:
    if (not hasattr(entryObject, "info") or
            not hasattr(entryObject.info, "name") or
            not hasattr(entryObject.info.name, "name") or
            entryObject.info.name.name in [".", ".."]):
        continue

    try:
        f_type = entryObject.info.meta.type

    except:
        print "Cannot retrieve type of", entryObject.info.name.name
        metric.total_files += 1
        metric.failed_files += 1
        continue

回溯:

> Traceback (most recent call last):   File "/Users/paulledwith/PycharmProjects/FYP/Server.py", line 352, in <module>
    directoryRecurse(directoryObject, [])   File "/Users/paulledwith/PycharmProjects/FYP/Server.py", line 185, in directoryRecurse
    directoryRecurse(sub_directory, parentPath)   File "/Users/paulledwith/PycharmProjects/FYP/Server.py", line 185, in directoryRecurse
    directoryRecurse(sub_directory, parentPath)   File "/Users/paulledwith/PycharmProjects/FYP/Server.py", line 185, in directoryRecurse
    directoryRecurse(sub_directory, parentPath)   File "/Users/paulledwith/PycharmProjects/FYP/Server.py", line 172, in directoryRecurse
    print entryObject.info.meta.size AttributeError: 'NoneType' object has no attribute 'size'

这确实检索到了我正在处理的5gb VHD上大约90%的文件,但90%相当于0。你知道吗


Tags: 文件nameinpyinfoservertypeline