def deleteFilesInLists(path, fileLists, extension): path = pathWithLastSlash(path) for fileList in fileLists: listFile = open(fileList, "r") i = 0 for line in listFile: i += 1 fileName = path + line.rstrip() + extension if os.path.exists(fileName): os.remove(fileName) logger.debug(str(i), ":", fileName) listFile.close() os.remove(fileList) pass
def buildDownloadBatch(fileListFileName, fileNames): path = os.path.dirname(fileListFileName) os4GeoPath = joinPaths(os.path.dirname(__file__), config.os4GeoPath) result = path + os.sep + "Import.bat" file = open(result, "w") file.write("cd %s\n" % path) overwriteCommand = "--o" for fileName in fileNames: (VFRlogFileName, VFRerrFileName) = buildhtmllog.getLogFileNames(fileListFileName) importCmd = "call %s vfr2pg --file %s --dbname %s --user %s --passwd %s %s" % (os4GeoPath, fileName, config.dbname, config.user, config.password, overwriteCommand) if config.layers != "": importCmd += " --layer " + config.layers importCmd += " >%s 2>%s\n" % (VFRlogFileName, VFRerrFileName) logger.debug(importCmd) file.write(importCmd) overwriteCommand = "--append" file.close() return result