如何使用IronPython将使用Spotfire使用者修改过的分析保存到库中?

时间:2019-03-18 12:25:57

标签: spotfire

是否可以通过调用某些API来以编程方式保存在Spotfire的Web Player(即 Spotfire Consumer )中打开的分析文件,或者由UI(Web Player)处理的分析文件?我正在使用Spotfire 10.1版

例如,我可以这样做: enter image description here

...以代码形式(例如使用Web API)

1 个答案:

答案 0 :(得分:1)

感谢您的澄清!

以下IronPython代码将保存分析。您会发现一个限制,但是,在保存到Web Player中时,必须将右上角的下拉菜单必须设置为“查看”(在10.0中)。重申一下:您不能使用此代码在Web Player中保存当前处于“编辑”模式的文档。

from Spotfire.Dxp.Application import DocumentSaveSettings
from Spotfire.Dxp.Framework.Library import LibraryManager, LibraryItemType, LibraryItemMetadataSettings
from Spotfire.Dxp.Framework.ApplicationModel import ApplicationThread

def save_to_library(app, path, filename, meta, settings):
  def f():
    app.SaveAs(path, filename, meta, settings)
  return f

# path info
lib_path = "/path/to/file"
filename = "My Analysis"

# reference the LibraryManager
lm = Application.GetService[LibraryManager]()

# determine if the path exists
success, lib_folder = lm.TryGetItem(lib_path, LibraryItemType.Folder)

if success:
  # save the file
  Application.GetService[ApplicationThread]().InvokeAsynchronously(save_to_library(Application, lib_folder, filename, LibraryItemMetadataSettings(), DocumentSaveSettings()))
else:
  print "folder " + lib_path + " does not exist in the Library"

基于this article from the TIBCO Wiki的代码。