Exemplo n.º 1
0
 def __init__(self):
     self._description = ""
     self._label = ""
     self._alias = ""
     self.logger = None
     self._isRunningAsTool = True
     arcpy.LoadSettings(getConfigValue("pathtoenvsettings"))
     arcpy.env.scratchWorkspace = getConfigValue("scratchws")
Exemplo n.º 2
0
def createEmlSubset(workDir, pathToEML):
    """ Run XSL transformation on EML with emlSubset.xsl to generate emlSubset.xml.
        Also, make workingData object with packageId, spatial type,
        and push it into newly created XML. Returns a tubple with the packageId and the number of spatialType nodes found.
    """
    pathToStylesheets = getConfigValue("pathtostylesheets")
    stylesheet = pathToStylesheets + os.sep + "emlSubset.xsl"
    outputXMLtree = runTransformation(xslPath=stylesheet, inputXMLPath=pathToEML)
    workingData = {
        "packageId": None,
        "spatialType": None,
        "entityName": None,
        "entityDesc": None,
        "dataEntityNum": 0,
        "contact": None,
    }
    top = outputXMLtree.getroot()
    pId = top.get("packageId")
    workingData["packageId"] = pId
    spTypeHit = outputXMLtree.xpath("//*[local-name()='spatialRaster' or local-name()='spatialVector']")
    workingData["dataEntityNum"] = len(spTypeHit)
    contactHit = outputXMLtree.xpath("//electronicMailAddress")
    if len(contactHit) > 0:
        email = contactHit[0].text
        workingData["contact"] = email
    ##    if len(spTypeHit) == 1:
    ##        spType = spTypeHit[0].tag
    ##        workingData["spatialType"] = spType
    ##        entNameNode = outputXMLtree.xpath("//" + spType + "/entityName")[0]
    ##        workingData["entityName"] = entNameNode.text
    ##        entDescNode = outputXMLtree.xpath("//" + spType + "/entityDescription")[0]
    ##        workingData["entityDesc"] = entDescNode.text
    outputXMLtree.write(workDir + os.sep + "emlSubset.xml", xml_declaration="yes")
    writeWorkingDataToXML(workDir, workingData)
    return (workingData["packageId"], workingData["dataEntityNum"])
Exemplo n.º 3
0
def createDictFromEmlSubset(workDir):
    """ Run XSL transformation on emlSubset.xml with emlSubsetToSupp.xsl to generate emlSupp.xml """
    pathToStylesheets = getConfigValue("pathtostylesheets")
    stylesheet = pathToStylesheets + os.sep + "emlSubsetToDataFields.xsl"
    inputXML = workDir + os.sep + "emlSubset.xml"
    outputXMLtree = runTransformation(xslPath=stylesheet, inputXMLPath=inputXML)
    obj = eval(str(outputXMLtree))
    return obj
Exemplo n.º 4
0
def createSuppXML(workDir):
    """ Run XSL transformation on emlSubset.xml with emlSubsetToSupp.xsl to generate emlSupp.xml """
    pathToStylesheets = getConfigValue("pathtostylesheets")
    stylesheet = pathToStylesheets + os.sep + "emlSubsetToSupp.xsl"
    inputXML = workDir + os.sep + "emlSubset.xml"
    outputXMLtree = runTransformation(xslPath=stylesheet, inputXMLPath=inputXML)
    # fill in today as date of pub within the new reference node
    outputXMLtree.xpath("//aggrInfo/aggrDSName/date/pubDate")[0].text = str(datetime.date.today())
    outputXMLtree.write(workDir + os.sep + "emlSupp.xml", xml_declaration="yes")
    del outputXMLtree
Exemplo n.º 5
0
def refresh_map_service(parameters):
    print "************"
    tool = lno_geonis_wf.RefreshMapService()
    tool._isRunningAsTool = False
    params = tool.getParameterInfo()
    params[0].value = True
    params[1].value = parameters['logfile']
    if parameters['site'] not in ('*', 'all'):
        tool.calledFromScript = parameters['site']
    elif parameters['site'] in ('*', 'all'):
        tool.calledFromScript = [
            s.split('-')[-1] for s in urlopen(
                getConfigValue('pastaurl') + '/package/eml'
            ).read().split('\n') if s.startswith('knb-lter-')
        ]
    #tool.sendReport = True
    tool.execute(params, [])