大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

python调用staf自动化框架的方法-创新互联

1、配置环境

创新互联长期为上千多家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为根河企业提供专业的成都网站设计、成都做网站、外贸网站建设根河网站改版等技术服务。拥有10余年丰富建站经验和众多成功案例,为您定制开发。

支持python2和python3

On Linux, Solaris, or FreeBSD, add the /usr/local/staf/lib directory to your PYTHONPATH, assuming you installed STAF to directory /usr/local/staf. For example:

export PYTHONPATH=/usr/local/staf/lib:$PYTHONPATH

On Mac OS X, add the /Library/staf/lib directory to your PYTHONPATH, assuming you installed STAF to directory /Library/staf. For example:

On Windows, add the C:\STAF\bin directory to your PYTHONPATH, assuming you installed STAF to directory C:\STAF. For example:

set PYTHONPATH=C:\STAF\bin;%PYTHONPATH%

2、python代码

 from PySTAF import STAFHandle
 from PySTAF import STAFException
 import sys

 try:
  handle = STAFHandle("MyTest")
 except STAFException, e:
  print "Error registering with STAF, RC: %d" % e.rc
  sys.exit(e.rc)

 #判断本地staf服务是否正常,结果是PONG代表服务正常
 result = handle.submit("local", "ping", "ping")
 if (result.rc != 0):
  print "Error submitting request, RC: %d, Result: %s" % (result.rc, result.result)

 result = handle.submit("local", "var", "resolve string {STAF/Config/OS/Name}")
 if (result.rc != 0):
  print "Error submitting request, RC: %d, Result: %s" % (result.rc, result.result)
 else:
  print "OS Name: %s" % result.result
 #执行命令,要执行远程,把local替换远程ip,如打开notepad
 result = handle.submit("local", "PROCESS", "start command notepad")
 print "Error submitting request, RC: %d, Result: %s" % (result.rc, result.result)
 #执行完记得注销handle
 rc = handle.unregister()

新闻名称:python调用staf自动化框架的方法-创新互联
URL分享:http://dzwzjz.com/article/dcccsi.html
在线咨询
服务热线
服务热线:028-86922220
TOP