def compute(self): """ compute() -> None Use BatchDisplayCellEvent to display a serie of SVG files """ if self.hasInputFromPort("File"): fileValue = self.getInputFromPort("File") else: fileValue = None if fileValue: batchDisplayEvent = BatchDisplayCellEvent() # FIXME: Will this work? there should be no # self.currentVersion in the module (there is a # self.version) batchDisplayEvent.vistrail = (self.vistrailName, self.currentVersion) f = open(fileValue.name, 'r') for line in f.read().split('\n'): comps = line.split('|') if len(comps)==2: e = DisplayCellEvent() e.sheetReference = StandardSingleCellSheetReference() e.sheetReference.sheetName = comps[1] e.cellType = SVGCellWidget F = File() from os.path import abspath, basename, dirname F.name = (dirname(abspath(fileValue.name))+ '/'+basename(comps[0])) e.inputPorts = (F,) batchDisplayEvent.displayEvents.append(e) f.close() spreadsheetController.postEventToSpreadsheet(batchDisplayEvent)
def run_figure(self, code_str, graphics_dev, width, height, excluded_inputs=set(['source'])): fname = self.interpreter.filePool.create_file(prefix='vtr', suffix='.' + graphics_dev) r_temp_files.append(fname) robjects.r[graphics_dev](file=fname, width=width, height=height) self.run_code(code_str, use_input=True, excluded_inputs=excluded_inputs) robjects.r['dev.off']() image_file = File() image_file.name = fname image_file.upToDate = True self.setResult('imageFile', image_file)
def set_result(self, path): persistent_path = File() persistent_path.name = path persistent_path.setResult('value', self) persistent_path.upToDate = True self.setResult("value", persistent_path)