我如何使用 IronPython 将我使用 Spotfire Consumer 修改的分析保存回库中?
How can I use IronPython to save an analysis which I have modified using the Spotfire Consumer back to the library?
是否可以通过调用一些 API 以编程方式保存在 Spotfire 的网络播放器(即 Spotfire Consumer)中打开的分析文件,或者全部处理通过 UI(网络播放器)?我正在使用 Spotfire 版本 10.1
例如,我可以这样做吗:
...在代码中(例如使用 Web API)
感谢您的澄清!
以下IronPython 代码将保存分析。但是,在 Web Player 中保存时,您会发现一个限制,即右上角的下拉列表 必须 设置为 "Viewing"(在 10.0 中)。重申一下:您不能使用此代码在网络播放器中保存当前处于 "Editing" 模式的文档。
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"
是否可以通过调用一些 API 以编程方式保存在 Spotfire 的网络播放器(即 Spotfire Consumer)中打开的分析文件,或者全部处理通过 UI(网络播放器)?我正在使用 Spotfire 版本 10.1
例如,我可以这样做吗:
...在代码中(例如使用 Web API)
感谢您的澄清!
以下IronPython 代码将保存分析。但是,在 Web Player 中保存时,您会发现一个限制,即右上角的下拉列表 必须 设置为 "Viewing"(在 10.0 中)。重申一下:您不能使用此代码在网络播放器中保存当前处于 "Editing" 模式的文档。
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"