def Main(): cgiEnv = lib_common.CgiEnv() filNam = cgiEnv.GetId() #filNam = filNam.replace("\\","/") sys.stderr.write("filNam=%s\n" % filNam ) filNode = lib_common.gUriGen.FileUri(filNam ) grph = cgiEnv.GetGraph() info = CIM_DataFile.GetInfoStat(filNam) # st_mode: protection bits. # st_ino: inode number. # st_dev: device. CIM_DataFile.AddDevice(grph,filNode,info) CIM_DataFile.AddStatNode( grph, filNode, info ) CIM_DataFile.AddMagic( grph, filNode, filNam ) # st_nlink: number of hard links. CIM_DataFile.AffFileOwner(grph, filNode, filNam) # Displays the file and the parent directories/ currFilNam = filNam currNode = filNode while True: dirPath = os.path.dirname( currFilNam ) if dirPath == currFilNam: break if dirPath == "": break dirNode = lib_common.gUriGen.DirectoryUri( dirPath ) grph.add( ( dirNode, pc.property_directory, currNode ) ) sys.stderr.write("dirPath=%s\n" % dirPath) statPath = os.stat(dirPath) CIM_DataFile.AddStatNode( grph, dirNode, statPath ) CIM_DataFile.AddFileProperties(grph,currNode,currFilNam) currFilNam = dirPath currNode = dirNode # If windows, print more information: DLL version etc... # http://stackoverflow.com/questions/580924/python-windows-file-version-attribute # cgiEnv.OutCgiRdf() # cgiEnv.OutCgiRdf("LAYOUT_TWOPI") cgiEnv.OutCgiRdf("LAYOUT_RECT_RL")
def Main(): cgiEnv = lib_common.ScriptEnvironment() file_name = cgiEnv.GetId() logging.debug("file_name=%s", file_name) file_node = lib_uris.gUriGen.FileUri(file_name) grph = cgiEnv.GetGraph() info = CIM_DataFile.GetInfoStat(file_name) # st_mode: protection bits. # st_ino: inode number. # st_dev: device. CIM_DataFile.AddDevice(grph, file_node, info) CIM_DataFile.AddStatNode(grph, file_node, info) CIM_DataFile.AddMagic(grph, file_node, file_name) # st_nlink: number of hard links. CIM_DataFile.AffFileOwner(grph, file_node, file_name) # Displays the file and the parent directories. current_file_name = file_name current_node = file_node while True: dir_path = os.path.dirname(current_file_name) if dir_path == current_file_name: break if dir_path == "": break dir_node = lib_uris.gUriGen.DirectoryUri(dir_path) grph.add((dir_node, pc.property_directory, current_node)) logging.debug("file_stat.py dir_path=%s", dir_path) stat_path = os.stat(dir_path) CIM_DataFile.AddStatNode(grph, dir_node, stat_path) CIM_DataFile.AddFileProperties(grph, current_node, current_file_name) current_file_name = dir_path current_node = dir_node # If windows, print more information: DLL version etc... # http://stackoverflow.com/questions/580924/python-windows-file-version-attribute cgiEnv.OutCgiRdf("LAYOUT_RECT_RL")