span8
span4
你好,
我想知道是否有python专家可以帮助我。我试图编写一个python关闭脚本,调用FME服务器,并将一些参数值传递到一个工作空间,以在服务器上运行。
我可以在桌面上成功地做同样的事情——运行一个工作空间,在关闭脚本中收集关于featuresRead、featureswrite、计时等信息,并使用这些记录和报告这些信息的值启动一个新的工作空间。
所以我在测试我是否可以在服务器上完成相同的任务——我可以在服务器上运行工作区作为关闭脚本的一部分,但现在我只是用“Test”填充所有的参数值。
用我创建的关于翻译信息的变量(如fme)替换“test”的正确语法是什么?totalFeaturesRead等等。我已经设法通过桌面来做到这一点,但是当我在服务器上测试时,我无法获得正确的信息来进行日志记录,任何建议都将受到欢迎,因为我正在尝试自己学习python(慢慢地)
谢谢
这是我最后提出的解决方案——可能不是记录关闭信息的最简单方法,但如果有人希望调用FMEServer并从python关闭中传递一些参数,这是我使用的代码。这很有效,我学到了一些东西
#参数#状态= fme。状态错误= fme。failureMessage logFile = fme.logFileName Read= fme.totalFeaturesRead Written= fme.totalFeaturesWritten licence= fme.licensing Time= fme.cpuSysTime memory=fme.memoryUsage maxmemory=fme.peakMemoryUsage FeaturesLogged=fme.numFeaturesLogged Location=FME_MacroValues['FME_MF_DIR'] Workspace=FME_MacroValues['FME_MF_NAME'] Build=FME_MacroValues['FME_BUILD_NUM'] #Logging Call to the Logfile# logger = open(FME_LogFileName,'a') logger.write("http://OSIHFME03/fmejobsubmitter/Samples/pythonlogging.fmw?DestDataset_XLSXW=C%3A%5CFMESERVER_PRIME2%5Cshutdown%5Ctest_write.xlsx&"+"Written="+str(Written)+"ℜad="+str(Read)+"&Workspace="+str(Workspace)+"&Status="+str(status)+"&Build="+str(Build)+"&Time="+str(Time)+"&Error="+str(errorMsg)+"&FeaturesLogged="+str(FeaturesLogged)+"&Location="+str(Location)+"&maxmemory="+str(maxmemory)+"opt_showresult=false&opt_servicemode=sync") logger.close() #Calling workspace on FME Server# url= "http://MyFMEServer/fmejobsubmitter/Samples/pythonlogging.fmw?DestDataset_XLSXW=C%3A%5CFMESERVER_PRIME2%5Cshutdown%5Ctest_write.xlsx&"+"Written="+str(Written)+"ℜad="+str(Read)+"&Workspace="+str(Workspace)+"&Status="+str(status)+"&Build="+str(Build)+"&Time="+str(Time)+"&Error="+str(errorMsg)+"&FeaturesLogged="+str(FeaturesLogged)+"&Location="+str(Location)+"&maxmemory="+str(maxmemory) webbrowser.open(url)
实际上,这里有一个很好的例子,关于如何使用Python在FME服务器上提交作业:
http://playground.fmeserver.com/python-request/
注意,他们使用的是Python 3.4,而不是默认的2.7。
实际上,我一直在考虑开发一个用于与FME服务器交互的开源Python库。我们的想法是要有一个接口,你可以像这样写代码
myserver = FMEServer(主机='http://myfmeserver') myserver。get_token(username='admin', password='123', duration=1, scale='days') my_params={'myparameter1': 'paramvalue1', 'myparameter2', 'param2'} job_id = myserver.submit_job('my_repo', 'myworkspace.fmw', params=my_params) status = myserver.get_job_status(job_id)
对这样的东西有兴趣吗?
你认为最重要的功能是什么?
为什么不简单地使用FMEServerJobSubmitter转换器呢?
如果您需要在所有撰写者终止后运行它,可以考虑用特性撰写者替换撰写者,将所有摘要发送到聚合器(以减少为一个单一特性),然后使用FMEServerJobSubmitter。
如果您确实需要使用Python,请考虑使用REST API而不是jobsubmitter,(我认为)这样更简单。我也推荐使用优秀的请求模块。
更多信息请看这里:http://playground.fmeserver.com/using-the-rest-api/jobs/
©2019安全亚搏在线软件公司法律