示例#1
0
def doImport(argv):
    global config

    from sharedtools import setupUTF
    setupUTF()

    config = RUIANImporterConfig()
    config.loadFromCommandLine(argv, helpStr)
    log.createLogger(getDataDirFullPath() + "Download.log")
    log.logger.info("Importing VFR data to database.")

    osGeoPath = getOSGeoPath()
    if not os.path.exists(osGeoPath):
        print "Error: RUIAN import library %s doesn't exist" % osGeoPath
        print "Download file %s, expand it into RUIANToolbox base directory and run script again." % RUIAN2PG_LIBRARY_ZIP_URL

        sys.exit()

    rebuildAuxiliaryTables = processDownloadedDirectory(getDataDirFullPath())

    if config.buildServicesTables and rebuildAuxiliaryTables:
        from RUIANServices.services.auxiliarytables import buildAll, buildServicesTables
        if config.buildAutocompleteTables:
            buildAll()
        else:
            buildServicesTables()

    from RUIANServices.services.RUIANConnection import saveRUIANVersionDateToday
    saveRUIANVersionDateToday()
示例#2
0
def doImport(argv):
    global config
    
    from sharedtools import setupUTF
    setupUTF()

    config = RUIANImporterConfig()
    config.loadFromCommandLine(argv, helpStr)
    log.createLogger(getDataDirFullPath() + "Download.log")
    log.logger.info("Importing VFR data to database.")

    osGeoPath = getOSGeoPath()
    if not os.path.exists(osGeoPath):
        print "Error: RUIAN import library %s doesn't exist" % osGeoPath
        print "Download file %s, expand it into RUIANToolbox base directory and run script again." % RUIAN2PG_LIBRARY_ZIP_URL

        sys.exit()

    rebuildAuxiliaryTables = processDownloadedDirectory(getDataDirFullPath())

    if config.buildServicesTables and rebuildAuxiliaryTables:
        from RUIANServices.services.auxiliarytables import buildAll, buildServicesTables
        if config.buildAutocompleteTables:
            buildAll()
        else:
            buildServicesTables()

    from RUIANServices.services.RUIANConnection import saveRUIANVersionDateToday
    saveRUIANVersionDateToday()
示例#3
0
            file_size_dl += len(blockBuffer)
            f.write(blockBuffer)
            filePercentageInfo(file_size, file_size_dl)
        f.close()


def printUsageInfo():
    log.logger.info(helpStr)
    sys.exit(1)


if __name__ == '__main__':
    config = RUIANDownloadConfig()
    config.loadFromCommandLine(sys.argv, helpStr)

    log.createLogger(config.dataDir + "Download.log")
    infoFile = RUIANDownloadInfoFile()

    if config.downloadFullDatabase:
        log.clearLogFile()

    log.logger.info("RUIAN Downloader")
    log.logger.info("#############################################")
    log.logger.info("Data directory : %s", config.dataDir)
    log.logger.info("Data directory full path : %s", getDataDirFullPath())
    log.logger.info("Download full database : %s",
                    str(config.downloadFullDatabase))
    if not config.downloadFullDatabase:
        log.logger.info("Last full download  : %s", infoFile.lastFullDownload)
        log.logger.info("Last patch download : %s", infoFile.lastPatchDownload)
    log.logger.info("---------------------------------------------")
示例#4
0
# -*- coding: utf-8 -*-
__author__ = "*****@*****.**"


if __name__ == "__main__":
    import sharedtools.log as log
    log.createLogger("Deploy")

    import argparse
    from updatemode import UPDATE_MODE
    from config import Config
    from directoryprocessor import DirectoryProcessor

    parser = argparse.ArgumentParser(description='Deploy python project.')
    parser.add_argument("--inputDir", type=str, help="Input directory with source project.", default="C:/ms4w/Apache/htdocs/Generalizace/m3")
    parser.add_argument("--outputDir", type=str, help="Output directory.", default="c:/temp/built")
    args = parser.parse_args()

    log.logger.info("Python Deploy Builder")
    processor = DirectoryProcessor(args.inputDir, args.outputDir, Config())
    processor.mode = UPDATE_MODE.OVERWRITE
    processor.deploy()
    processor.printStatistics()
示例#5
0
def runServer(loggerName="RunWorkflowServer",
              port=65423,
              registeredWorkflows=None,
              aDefaultPath=None):
    global workflowItems, defaultPath

    if loggerName:
        import sharedtools.log as log
        logger = log.createLogger(loggerName)
        logger.debug("Configuration file:%s" % config.configFileName)

    if registeredWorkflows:
        if isinstance(registeredWorkflows, list):
            workflowItems = registeredWorkflows
        elif isinstance(registeredWorkflows, WorkflowItem) or isinstance(
                registeredWorkflows, WorkflowSequence):
            workflowItems = [registeredWorkflows]
            defaultPath = "workflows/" + registeredWorkflows.id
    else:
        workflowItems = getRegisteredWorkflows()

    if aDefaultPath:
        defaultPath = aDefaultPath

    import os
    if os.environ.has_key('SERVER_SOFTWARE'):
        import cgi
        import cgitb
        cgitb.enable()

        form = cgi.FieldStorage()
        if os.environ.has_key('PATH_INFO'):
            pathInfo = os.environ['PATH_INFO']
        else:
            pathInfo = ""
        if pathInfo[:1] == "/": pathInfo = pathInfo[1:]

        fullPathList = pathInfo.replace("//", "/")
        fullPathList = fullPathList.split("/")  # REST parametry

        query = {}
        queryList = form.list
        for item in queryList:
            decodedValue = urllib.unquote(item.value)
            try:
                decodedValue = unicode(decodedValue, "utf-8")
            except:
                decodedValue = codecs.decode(decodedValue, "latin-1")
            decodedValue = urllib.unquote(decodedValue)
            query[item.name] = decodedValue

        response = ProcessRequest(fullPathList, query, HTTPResponse(False))

        if response.mimeFormat in [
                "text/html", "text/javascript", "text/plain"
        ]:
            print "Content-Type: " + response.mimeFormat + ";charset=utf-8"  # HTML is following
            print  # blank line, end of headers
            sys.stdout.write(response.htmlData.encode('utf-8'))
        else:
            print "Content-Type: " + "application/octet-stream"  # response.mimeFormat
            print  # blank line, end of headers
            if sys.platform != "win32":
                sys.stdout.write(response.htmlData)
                sys.stdout.flush()
            else:
                import os, msvcrt

                msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
                sys.stdout.write(response.htmlData)
                sys.stdout.flush()
                msvcrt.setmode(sys.stdout.fileno(), os.O_TEXT)

    else:
        app = WorkflowsApplication(urls, globals())
        app.run(port=port)
示例#6
0
<p style="text-align:left">
<table>
    <tr><td><a href="Workflows">Workflows</a></td><td>Registered workflows</td></tr>
</table>
<hr>
<h4>Request Details</h4>
<p>Path: #PATH#</p>
<table>
#QUERY_LINES#
</table>
</p>
"""

import sharedtools.log as log
if __name__ == "__main__":
    logger = log.createLogger("workflows")

from workflow import getRegisteredWorkflows, WorkflowItem
from workflow import buildHTMLPageContent
from workflow.rest import buildFloatingListPage

import sharedtools.config as config

workflowItems = None
defaultPath = "workflows"
__paths = {}


def registerPath(path, requestProcessor):
    global __paths
示例#7
0
            file_size_dl += len(blockBuffer)
            f.write(blockBuffer)
            filePercentageInfo(file_size, file_size_dl)
        f.close()


def printUsageInfo():
    log.logger.info(helpStr)
    sys.exit(1)


if __name__ == '__main__':
    config = RUIANDownloadConfig()
    config.loadFromCommandLine(sys.argv, helpStr)

    log.createLogger(config.dataDir + "Download.log")
    infoFile = RUIANDownloadInfoFile()

    if config.downloadFullDatabase:
        log.clearLogFile()

    log.logger.info("RUIAN Downloader")
    log.logger.info("#############################################")
    log.logger.info("Data directory : %s", config.dataDir)
    log.logger.info("Data directory full path : %s", getDataDirFullPath())
    log.logger.info("Download full database : %s", str(config.downloadFullDatabase))
    if not config.downloadFullDatabase:
        log.logger.info("Last full download  : %s", infoFile.lastFullDownload)
        log.logger.info("Last patch download : %s", infoFile.lastPatchDownload)
    log.logger.info("---------------------------------------------")
示例#8
0
    data = load(open(dataFileName, "r"))
    log.logger.info("%d records loaded." % len(data))
    for situation, id in zip(data, range(len(data))):
        loadFeatures(situation["SourceFeatures"], "context_features",
                     situation["Caption"], id)
        loadFeatures(situation["TargetFeatures"], "cartographic_features",
                     None, id)

    database.execute(
        "insert into m3_persistent_representations.load_statistics (last_update_timestamp) values ('%s');"
        % str(os.path.getmtime(dataFileName)))
    log.logger.closeSection()


def databaseNeeded():
    """Checks whether Permanent cartographic representations database is up to date. If not, loadDatabase procedure is called.
    """
    if not database.schemaExists("m3_persistent_representations") or \
       not database.tableExists("m3_persistent_representations", "load_statistics") or \
       database.firstRowFromSelect("select * from m3_persistent_representations.load_statistics")[0] < str(os.path.getmtime(dataFileName)):
        loadDatabase(True)
    else:
        log.logger.info(
            "Permanent cartographic representations database is up to date.")


# @NO-PRODUCTION CODE
if __name__ == "__main__":
    log.createLogger("dataconnectors.persistentcartographicsituations.loader")

    databaseNeeded()