def HashFile(theFile,simplename,o_result):
    if os.path.exists(theFile):
        if os.path.isfile(theFile):
            try:
                f=open(theFile,'rb')
            except __HOLE__:
                log.warning("open failed :"+theFile)
                return
            else:
                try:
                    rd = f.read()
                except IOError:
                    f.close()
                    log.warning("read failed:"+theFile)
                    return

                else:
                    theFileStats=os.stat(theFile)
                    (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)=os.stat(theFile)
                    log.info("Processing File: "+theFile)
                    fileSize = str(size)
                    modifiedTIme= time.ctime(mtime)
                    accessTime = time.ctime(atime)
                    createdTime = time.ctime(ctime)
                    ownerID = str(uid)
                    groupID = str(gid)
                    fileMode = bin(mode)

                    if gl_args.md5:
                        hashout = hashlib.md5()
                        hashout.update(rd)
                        hexmd5 = hashout.hexdigest()
                        hashValue = hexmd5.upper()
                    elif gl_args.sha256:
                        hashout = hashlib.sha256()
                        hashout.update(rd)
                        hexsha256 = hashout.hexdigest()
                        hashValue = hexsha256.upper()
                    elif gl_args.sha512:
                        hashout = hashlib.sha512()
                        hashout.update(rd)
                        hexsha512 = hashout.hexdigest()
                        hashValue = hexsha512.upper()
                    else:
                        log.error("hash not Selected")

                    f.close()
                    o_result.writeCSVrow(simplename,theFile,fileSize,modifiedTIme,accessTime,createdTime,hashValue,ownerID,groupID,mode)
                    return True

        else:
            log.warning("cannot read the file :"+theFile)
            return False
    else:
        log.warning("not a file"+theFile)
        return False
dataset/ETHPy150Open girishramnani/hacking-tools/file_hasher/_pfish_tools.py/HashFile