Пример #1
0
def buildDownloadBatch(fileListFileName, fileNames):
    assert isinstance(fileListFileName, basestring)
    assert os.path.exists(fileListFileName)
    assert isinstance(fileNames, list)

    path = os.path.dirname(fileListFileName)
    os4GeoPath = getOSGeoPath()

    (VFRlogFileName, VFRerrFileName) = buildhtmllog.getLogFileNames(fileListFileName)
    commands = "cd %s\n" % path
    overwriteCommand = "--o"
    for fileName in fileNames:

        vfrCommand = "vfr2pg --file %s --dbname %s --user %s --passwd %s %s" % (extractFileName(fileName), config.dbname, config.user, config.password, overwriteCommand)

        if RUNS_ON_WINDOWS:
            importCmd = "call %s %s" % (os4GeoPath, vfrCommand)
        else:
            importCmd = "%s%s  2>>%s 3>>%s" % (os4GeoPath, vfrCommand, VFRlogFileName, VFRerrFileName)

        if config.layers != "": importCmd += " --layer " + config.layers

        log.logger.debug(importCmd)
        commands += importCmd + "\n"
        overwriteCommand = "--append"

        commandFileName = createCommandFile(path + os.sep + "Import", commands)

    return (commandFileName, VFRlogFileName, VFRerrFileName)
Пример #2
0
def buildDownloadBatch(fileListFileName, fileNames):
    assert isinstance(fileListFileName, basestring)
    assert os.path.exists(fileListFileName)
    assert isinstance(fileNames, list)

    path = os.path.dirname(fileListFileName)
    os4GeoPath = getOSGeoPath()

    (VFRlogFileName,
     VFRerrFileName) = buildhtmllog.getLogFileNames(fileListFileName)
    commands = "cd %s\n" % path
    overwriteCommand = "--o"
    for fileName in fileNames:

        vfrCommand = "vfr2pg --file %s --dbname %s --user %s --passwd %s %s" % (
            extractFileName(fileName), config.dbname, config.user,
            config.password, overwriteCommand)

        if RUNS_ON_WINDOWS:
            importCmd = "call %s %s" % (os4GeoPath, vfrCommand)
        else:
            importCmd = "%s%s  2>>%s 3>>%s" % (os4GeoPath, vfrCommand,
                                               VFRlogFileName, VFRerrFileName)

        if config.layers != "": importCmd += " --layer " + config.layers

        log.logger.debug(importCmd)
        commands += importCmd + "\n"
        overwriteCommand = "--append"

        commandFileName = createCommandFile(path + os.sep + "Import", commands)

    return (commandFileName, VFRlogFileName, VFRerrFileName)
Пример #3
0
def updateDatabase(updateFileList):
    assert isinstance(updateFileList, list)

    def removeDataFiles():
        dataPath = pathWithLastSlash(os.path.split(updateFileList)[0])
        inFile = open(updateFileList, "r")
        try:
            for line in inFile:
                fileName = os.path.basename(line)
                if os.path.exists(dataPath + fileName):
                    os.remove(dataPath + fileName)
        finally:
            inFile.close()
        pass

    log.logger.info("Importing update data from " + updateFileList)

    (startDate, endDate, type) = extractDatesAndType(updateFileList)
    log.logger.info("\tPočáteční datum:" + startDate)
    log.logger.info("\tKonečné datum:" + endDate)
    log.logger.info("\tTyp dat:" + type)

    os4GeoPath = joinPaths(os.path.dirname(__file__), config.os4GeoPath)
    if sys.platform.lower().startswith('win'):
        os4GeoPath = os4GeoPath + " "
    os4GeoPath = os4GeoPath + "vfr2pg"

    (VFRlogFileName,
     VFRerrFileName) = buildhtmllog.getLogFileNames(updateFileList)

    params = ' '.join([
        os4GeoPath, "--dbname", config.dbname, "--user ", config.user,
        "--passwd ", config.password, "--date", startDate + ":" + endDate,
        "--type", type
    ])

    if config.layers != "":
        params += " --layer " + config.layers

    if RUNS_ON_WINDOWS:
        params += " >%s 2>%s" % (VFRlogFileName, VFRerrFileName)
    else:
        params += " 2>%s 3>%s" % (VFRlogFileName, VFRerrFileName)

    commands = "cd " + os.path.dirname(os.path.abspath(updateFileList)) + "\n"
    commands += params + "\n"
    batchFileName = createCommandFile(
        os.path.dirname(os.path.abspath(updateFileList)) + os.sep + "Import",
        commands)

    call(batchFileName)
    os.remove(batchFileName)
    removeDataFiles()

    renameFile(updateFileList, "__")
    log.logger.info("Import update data done.")
Пример #4
0
def updateDatabase(updateFileList):
    assert isinstance(updateFileList, list)

    def removeDataFiles():
        dataPath = pathWithLastSlash(os.path.split(updateFileList)[0])
        inFile = open(updateFileList, "r")
        try:
            for line in inFile:
                fileName = os.path.basename(line)
                if os.path.exists(dataPath + fileName):
                    os.remove(dataPath + fileName)
        finally:
            inFile.close()
        pass

    log.logger.info("Importing update data from " + updateFileList)

    (startDate, endDate, type) = extractDatesAndType(updateFileList)
    log.logger.info("\tPočáteční datum:" + startDate)
    log.logger.info("\tKonečné datum:" + endDate)
    log.logger.info("\tTyp dat:" + type)

    os4GeoPath = joinPaths(os.path.dirname(__file__), config.os4GeoPath)
    if sys.platform.lower().startswith('win'):
        os4GeoPath = os4GeoPath + " "
    os4GeoPath = os4GeoPath + "vfr2pg"

    (VFRlogFileName, VFRerrFileName) = buildhtmllog.getLogFileNames(updateFileList)

    params = ' '.join([os4GeoPath,
                "--dbname", config.dbname,
                "--user ", config.user,
                "--passwd ", config.password,
                "--date", startDate + ":" + endDate,
                "--type", type])

    if config.layers != "":
        params += " --layer " + config.layers

    if RUNS_ON_WINDOWS:
        params += " >%s 2>%s" % (VFRlogFileName, VFRerrFileName)
    else:
        params += " 2>%s 3>%s" % (VFRlogFileName, VFRerrFileName)

    commands = "cd " + os.path.dirname(os.path.abspath(updateFileList)) + "\n"
    commands += params + "\n"
    batchFileName = createCommandFile(os.path.dirname(os.path.abspath(updateFileList)) + os.sep + "Import" , commands)

    call(batchFileName)
    os.remove(batchFileName)
    removeDataFiles()

    renameFile(updateFileList, "__")
    log.logger.info("Import update data done.")
Пример #5
0
def updateDatabase(updateFileList):

    def removeDataFiles():
        dataPath = pathWithLastSlash(os.path.split(updateFileList)[0])
        inFile = open(updateFileList, "r")
        try:
            for line in inFile:
                fileName = os.path.basename(line)
                if os.path.exists(dataPath + fileName):
                    os.remove(dataPath + fileName)
        finally:
            inFile.close()
        pass

    logger.info("Importing update data from " + updateFileList)

    (startDate, endDate, type) = extractDatesAndType(updateFileList)
    logger.info("\tPočáteční datum:" + startDate)
    logger.info("\tKonečné datum:" + endDate)
    logger.info("\tTyp dat:" + type)

    os4GeoPath = joinPaths(os.path.dirname(__file__), config.os4GeoPath)

    (VFRlogFileName, VFRerrFileName) = buildhtmllog.getLogFileNames(updateFileList)

    params = ' '.join([os4GeoPath, "vfr2pg",
                "--dbname", config.dbname,
                "--user ", config.user,
                "--passwd ", config.password,
                "--date", startDate + ":" + endDate,
                "--type", type])
    if config.layers != "": params += " --layer " + config.layers
    params += " >%s 2>%s" % (VFRlogFileName, VFRerrFileName)

    batchFileName = os.path.dirname(os.path.abspath(updateFileList)) + os.sep + "Import.bat"
    file = open(batchFileName, "w")
    file.write("cd " + os.path.dirname(os.path.abspath(updateFileList)) + "\n")
    file.write(params)
    file.close()

    call(batchFileName)
    os.remove(batchFileName)
    removeDataFiles()

    renameFile(updateFileList, "__")
    logger.info("Import update data done.")
    pass
Пример #6
0
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