def generate_indicators(self): self.filepaths = {} for name, (projconfig, batchname, visname, datasourcename, year) in self.indicators.items(): op = OpusProject() op.open(os.path.join(PROJECTCONFIGBASE, projconfig)) bp = BatchProcessor(op) visualizationsconf = get_batch_configuration(project=op, batch_name=batchname, vis_name=visname) bp.set_data(visualizations=visualizationsconf, source_data_name=datasourcename, years=[year, year]) bp.run() visualizations = bp.get_visualizations() # visualizations in batch assert len(visualizations) == 1 vistype, visualizations = visualizations[0] # indicators in visualization assert len(visualizations) == 1 self.filepaths[name] = visualizations[0].get_file_path()
def __init__(self, gui_configuration = None): QMainWindow.__init__(self) self.setupUi(self) # Bind the application global instance for to this window set_opusgui_instance(self) self.thread().setPriority(QThread.HighestPriority) self.tabWidget = QTabWidget(self.splitter) self.splitter.setSizes([400, 500]) # Create a log window self.log_tab = LogWidget(self.tabWidget) self.log_tab.start_stdout_capture() # Initialize empty project self.project = OpusProject() # Read database connection names settings_directory = os.path.join(os.environ['OPUS_HOME'], 'settings') db_con_file = os.path.join(settings_directory, 'database_server_configurations.xml') db_config_node = ElementTree(file=db_con_file).getroot() self.db_connection_names = [node.tag for node in db_config_node if node.tag != Comment and node.get('hidden') != "True" and node.tag != 'xml_version'] # Application default configuration self.gui_config = gui_configuration # Bind actions self._setup_actions() # Manager collection -- initialized by openProject() self.managers = {} # # Delay before hiding the splash screen # time.sleep(1) # self.gui_config.splash_screen.hide() # Restoring application geometry from last shut down settings = QSettings() self.restoreGeometry(settings.value("Geometry").toByteArray()) self.updateFontSize() self.setFocus() # Variable library self.variable_library = None # Load the latest project file if that flag is set in GUI configuration if self.gui_config.load_latest_on_start: self.openProject(self.gui_config.latest_project_filename or '') ###T: removing these until they serve a purpose self.menuUtilities.removeAction(self.actPythonView) #self.menuUtilities.removeAction(self.actionLog_View) self.menuUtilities.removeAction(self.actEditorView) self.connect(self, SIGNAL('variables_updated'), self.update_saved_state) self.update_saved_state()
def _open(self, fn): fn = os.path.join(self.testdatapath, fn) p = OpusProject() ok, msg = p.open(fn) if not ok: print msg self.assertTrue(p.is_open(), 'Project file could not be opened') return p
def _load_project(self, filename): ''' Load the project from the given filename and return it. None is returned if the project could not be loaded. ''' try: project = OpusProject() flag, message = project.open(filename) if flag is not True: raise Exception(message) return project except Exception, ex: self._show_error('There was a problem loading the specified project template<br/>' + 'The error was:<br/>'+ '<strong>' + str(ex) + '</strong>')
def on_buttonBox_accepted(self): ''' User accepted the values in the dialog ''' # convert values from QString to Python strings project_name = str(self.le_project_name.text()) project_filename = str(self.le_project_filename.text()) project_description = str(self.le_project_description.text()) # validate required fields if len(project_filename) == 0: self.le_project_filename.setFocus() self._show_error('Please specify where to save the new project') return if len(project_name) == 0: self.le_project_name.setFocus() self._show_error('Please give the project a descriptive name') return # fetch user entered data to set the template node text values self._apply_widget_data_to_template_nodes() # create a new empty project and merge the templated nodes into it new_project = OpusProject() new_project.load_minimal_project() # manually create and set project name and project parent self._set_project_details(new_project, project_name, self.parent_project_filename, project_description) # merge in user node settings merge_templated_nodes_with_project(self.template_nodes, new_project) # try to save the project to the location given by the user flag, message = new_project.save(project_filename) if flag is not True: self._show_error(message) return # set the expected response attribute self.new_project_filename = project_filename print('Saved new project to {0}'.format(project_filename)) self.accept()
try: import wingdbstub except: pass option_group = MakeIndicatorsOptionGroup() parser = option_group.parser (options, args) = parser.parse_args() if not (options.xml_configuration and options.indicator_batch and ( options.cache_directory or options.run_name) and options.years ): parser.print_help() sys.exit(0) from opus_gui.results_manager.run.batch_processor import BatchProcessor project = OpusProject() project.open(options.xml_configuration) bp = BatchProcessor(project) visualizations = get_batch_configuration(project = project, batch_name = options.indicator_batch) bp.set_data(visualizations=visualizations, source_data_name = options.run_name, cache_directory = options.cache_directory, years = eval(options.years), ) bp.errorCallback = lambda x: x ## bp.finishedCallback = lambda x: x ## hack to work around BatchProcessor bp.run()