# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #名称:Master.py #目的:# #作者:琼Desormeaux (Consortech) # #创建:11-02-2019 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -进口fme进口fmeobjects进口arcpy进口__main__导入操作系统导入shutil xml.etree进口。ElementTree作为ET导入xml.dom。minidom as DOM import subprocess from subprocess import PIPE def RunPython32bit(feature): function = feature.getAttribute("function") if function == "CreateServiceDefinition": command = PrepareCreateServiceDefinition(feature) elif function == "UploadServiceDefinition": command = PrepareUploadServiceDefinition(feature) python = __main__.FME_MacroValues['PYTHON_PATH'] pythonScripts = __main__.FME_MacroValues['FOLDER_PYTHON_SCRIPTS'] cmd = [python, "%s\\ArcGIS_Tools.py" % pythonScripts] cmd += command fmeobjects.FMELogFile().logMessageString("Launching external tool: %s" % cmd) process = subprocess.Popen(cmd, shell=False, stdout=PIPE, stderr=PIPE) stdout, stderr = process.communicate() if stdout != None: fmeobjects.FMELogFile().logMessageString("Output messages from subprocess:") for line in stdout.strip().split("\n"): fmeobjects.FMELogFile().logMessageString(line) if stderr != None and len(stderr) > 0: #print "stderr = %s" % str(stderr) fmeobjects.FMELogFile().logMessageString("Output errors from subprocess:") for line in stderr.strip().split("\n"): fmeobjects.FMELogFile().logMessageString(line) raise Exception("An error occured during the subprocess's execution.") #rc = process.wait() #print "Result of rc: %s" % str(rc) def PrepareCreateServiceDefinition(feature): command = ["CreateServiceDefinition", feature.getAttribute("locator_path"), feature.getAttribute("sddraft_path"), feature.getAttribute("sd_path"), feature.getAttribute("service_name"), feature.getAttribute("gis_server_connection_file"), feature.getAttribute("max_result_size")] return command def PrepareUploadServiceDefinition(feature): command = ["UploadServiceDefinition", feature.getAttribute("sd_path"), feature.getAttribute("gis_server_connection_file")] return command