AttributeError:“名称空间”对象没有属性“ reportPath”

时间:2020-09-13 18:08:11

标签: python parsing

我不断得到:AttributeError:“名称空间”对象没有属性“ reportPath”

我不明白为什么,我什至无法遵循此代码,因为我一直在法医书中使用此预先编写的代码。

def WalkPath():
processCount = 0
errorCount = 0

oCVS = _CSVWriter(gl_args.reportPath + 'fileSystemReport.csv', gl_hashType)

# Create a loop that process all the files starting at the rootPath,
# all sub-directories will also be processed

log.info('Root Path: ' + gl_args.rootPath)

for root, dirs, files in os.walk(gl_args.rootPath):
        # for each file obtain the filename and call the HashFile Functionfor file in files:
    fname = os.path.join(root, file)
    result = HashFile(fname, file, oCVS)

    # if hashing was successful, then increment the ProcessCount
    if result is True:
        processCount += 1

    # if not successful, the increment the ErrorCount
    else:
        errorCount += 1

oCVS.writerClose()

return(processCount)

在此处定义reportPath:

def ParseCommandLine(): parser = argparse.ArgumentParser(“ Python文件系统哈希... p-fish”) parser.add_argument('-v','-verbose',help ='允许显示进度消息',action ='store_true')

# setup a group where the selection is mutually exclusive and required

group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--md5', help='specifies MD5 algorithm', action='store_true')
group.add_argument('--sha256', help='specifies SHA256 algorithm', action='store_true')
group.add_argument('--sha512', help='specifies SHA512 algorithm', action='store_true')

parser.add_argument('--d', '--rootPath', type=ValidateDirectory, required=True, help='specify the root path for hashing')
parser.add_argument('--r', '--reportPath', type=ValidateDirectoryWritable, required=True, help='specify the path for reports and logs will be written')

# creates a global object to hold the validated arguments, these will be available
# to all the functions within the _pfish.py module

global gl_args
global gl_hashType

gl_args = parser.parse_args()

if gl_args.md5:
    gl_hashType = "MD5"
elif gl_args.sha256:
    gl_hashType = "SHA256"
elif gl_args.sha512:
    gl_hashType = "SHA512"
else:
    gl_hashType = "Unknown"
    logging.error("Unknown Hash Type Specified")


DisplayMessage("Command line processed: Successfully")

return

0 个答案:

没有答案