def saveTableFromWidget(display, path): if path is None or len(path) <= 0: raise Exception("Invalid or empty file name") path = FileUtil.workspacePathToSysPath(path) if path is None: raise Exception("Save Error", "Invalid file name or path") table_scan = getTableFromWidget(display) table_scan.save(path) # Force a workspace refresh on the new file ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(Path(path)).refreshLocal(0, None)
def saveTableFromWidget(display, path): if path is None or len(path) <= 0: raise Exception("Invalid or empty file name") path = FileUtil.workspacePathToSysPath(path) if path is None: raise Exception("Save Error", "Invalid file name or path") table_scan = getTableFromWidget(display) table_scan.save(path) # Force a workspace refresh on the new file ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( Path(path)).refreshLocal(0, None)
def getTableFromPath(path): path = FileUtil.workspacePathToSysPath(path) if path: return loadTableScan(path) else: raise Exception("No file to load")
from org.csstudio.opibuilder.scriptUtil import PVUtil, FileUtil from org.csstudio.opibuilder.util import ResourceUtil from java.lang import System opiPath = display.getModel().getOpiFilePath() isWorkspaceFile = ResourceUtil.isExistingWorkspaceFile(opiPath) opiFolderPath = ResourceUtil.buildAbsolutePath(display.getModel(), ResourceUtil.getPathFromString("./")).toString() if isWorkspaceFile: opiFolderPath = FileUtil.workspacePathToSysPath(opiFolderPath) System.setProperty("shellScript2.dir", opiFolderPath)
from org.csstudio.opibuilder.scriptUtil import PVUtil, DataUtil, FileUtil, ConsoleUtil #import os.path try: file = FileUtil.openFileDialog(False) # Open file dialog #file_name = os.path.basename(file) # Get file name widget.setPropertyValue("label", file) # Set file name as widget label except: pass
from org.csstudio.opibuilder.scriptUtil import PVUtil, DataUtil, FileUtil, ConsoleUtil ## Get Orbit Widgets Information graph_orbit_x = display.getWidget("Graph Orbit X") graph_orbit_y = display.getWidget("Graph Orbit Y") orbit_x_pv = graph_orbit_x.getPV() orbit_y_pv = graph_orbit_y.getPV() ## Save File try: try: orbit_x = PVUtil.getDoubleArray(orbit_x_pv) orbit_y = PVUtil.getDoubleArray(orbit_y_pv) orbit_xy = orbit_x + orbit_y except: ConsoleUtil.writeError("Graphics PV must be defined. Choose a register first.") raise file = FileUtil.saveFileDialog(False) widget.setPropertyValue("label", file) orbit_xy_data = open(file, "w") for data in orbit_xy: orbit_xy_data.write("%s\n" % data) orbit_xy_data.close() except: pass
from org.csstudio.opibuilder.scriptUtil import PVUtil from org.csstudio.opibuilder.scriptUtil import FileUtil import os opifilepath = display.getModel().getOpiFilePath().toString() workspacepath = FileUtil.workspacePathToSysPath("/") path = workspacepath + opifilepath path = path[::-1] pathsplit = path.split("/",1) folder = pathsplit[1] configfilepath = folder[::-1] configfile = configfilepath + "/cbhv_config.txt" test = os.path.isfile(configfile) print test
return (d) # read in file to create test screens for fin = str(PVUtil.getString(pvs[1]))[1:] # read in go button to initiate screen creation go = PVUtil.getDouble(pvs[0]) == 1 # flag used to include PV in rules list if macros are used macroFlag = False check = PVUtil.getDouble(pvs[3]) == 1 if go and fin != '': fin = str(FileUtil.workspacePathToSysPath(fin)) # performs PV check if selected if check: # read in and parse OPI file for relevant info tree = ET.parse(fin) root = tree.getroot() relevant = [ 'x', 'y', 'height', 'width', 'pv_name', 'text', 'widget_type' ] screenProps = {} widgets = [] macros = {} for child in root: if child.tag in relevant: if child.tag == 'background_color' or child.tag == 'foreground_color':
from org.csstudio.opibuilder.scriptUtil import PVUtil, FileUtil from org.csstudio.opibuilder.util import ResourceUtil from java.lang import System opiPath = display.getModel().getOpiFilePath() isWorkspaceFile = ResourceUtil.isExistingWorkspaceFile(opiPath) opiFolderPath = ResourceUtil.buildAbsolutePath( display.getModel(), ResourceUtil.getPathFromString("./")).toString() if isWorkspaceFile: opiFolderPath = FileUtil.workspacePathToSysPath(opiFolderPath) System.setProperty("shellScript2.dir", opiFolderPath)
from org.csstudio.opibuilder.scriptUtil import PVUtil, ScriptUtil, FileUtil,\ ConsoleUtil import csv from array import zeros, array from java.lang import String from java.util import Arrays from java.lang.reflect import Array table = display.getWidget("ScanTable1").getTable() inWorkspace=display.getWidget("inWorkspace").getValue() path = FileUtil.openFileDialog(inWorkspace) if path != None and path.endswith('csv'): if inWorkspace: path = FileUtil.workspacePathToSysPath(path) reader = csv.reader(open(path)) lineList=[] for row in reader: lineList.append(row) content = Array.newInstance(String, len(lineList), len(row)) for r in range(len(lineList)): for c in range(len(row)): content[r][c] = lineList[r][c] table.setContent(content)
from org.csstudio.opibuilder.scriptUtil import PVUtil, FileUtil from java.lang import System sysPath = FileUtil.workspacePathToSysPath( "/BOY Examples/Miscellaneous/ExecuteShellScript") System.setProperty("shellScript.dir", sysPath)
from org.csstudio.opibuilder.scriptUtil import PVUtil, ScriptUtil, FileUtil,\ ConsoleUtil import csv from array import zeros, array from java.lang import String from java.util import Arrays from java.lang.reflect import Array from string import join table = display.getWidget("ScanTable1").getTable() inWorkspace=display.getWidget("inWorkspace").getValue() path = FileUtil.openFileDialog(inWorkspace) if path != None and path.endswith('csv'): content=table.getContent() lineList=[] for row in content: rowList=[] for s in row: rowList.append(s) lineList.append(join(rowList, ',')) text = join(lineList, '\n') FileUtil.writeTextFile(path, inWorkspace, text, False)
from org.csstudio.opibuilder.scriptUtil import PVUtil, ScriptUtil, FileUtil,\ ConsoleUtil import csv from array import zeros, array from java.lang import String from java.util import Arrays from java.lang.reflect import Array table = display.getWidget("ScanTable1").getTable() inWorkspace = display.getWidget("inWorkspace").getValue() path = FileUtil.openFileDialog(inWorkspace) if path != None and path.endswith('csv'): if inWorkspace: path = FileUtil.workspacePathToSysPath(path) reader = csv.reader(open(path)) lineList = [] for row in reader: lineList.append(row) content = Array.newInstance(String, len(lineList), len(row)) for r in range(len(lineList)): for c in range(len(row)): content[r][c] = lineList[r][c] table.setContent(content)
from org.csstudio.opibuilder.scriptUtil import PVUtil, FileUtil from java.lang import System sysPath = FileUtil.workspacePathToSysPath("/BOY Examples/Miscellaneous/ExecuteShellScript") System.setProperty("shellScript.dir", sysPath)