def setupStartupVariables(self): """ Each program starts with a set of workflow variables that are defined by where the program is executed from and potentially a set of environment variables. """ # The current session gets a "binary directory" variable depends_variables.add('DEPENDS_DIR') depends_variables.setx('DEPENDS_DIR', os.path.dirname(os.path.realpath(__file__)), readOnly=True) # ...And a path that points to where the nodes are loaded from depends_variables.add('NODE_PATH') if not os.environ.get('DEPENDS_NODE_PATH'): depends_variables.setx('NODE_PATH', os.path.join(depends_variables.value('DEPENDS_DIR'), 'nodes'), readOnly=True) else: depends_variables.setx('NODE_PATH', os.environ.get('DEPENDS_NODE_PATH'), readOnly=True)
def open(self, filename): """ Loads a snapshot, in the form of a json, file off disk and applies the values it pulls to the currently active dependency graph. Cleans up the UI accordingly. """ if not os.path.exists(filename): return False # Load the snapshot off disk with open(filename, 'rb') as fp: snapshot = json.loads(fp.read()) # Apply the data to the in-flight Dag self.dag.restoreSnapshot(snapshot["DAG"]) # Initialize the objects inside the graphWidget & restore the scene self.graphicsScene.restoreSnapshot(snapshot["DAG"]) # Variable substitutions self.clearVariableDictionary() for v in snapshot["DAG"]["VARIABLE_SUBSTITIONS"]: depends_variables.variableSubstitutions[v["NAME"]] = (v["VALUE"], False) # The current session gets a variable representing the location of the current workflow if 'WORKFLOW_DIR' not in depends_variables.names(): depends_variables.add('WORKFLOW_DIR') depends_variables.setx('WORKFLOW_DIR', os.path.dirname(filename), readOnly=True) # Additional meta-data loading if "RELOAD_PLUGINS_FILENAME_TEMP" in snapshot: filename = snapshot["RELOAD_PLUGINS_FILENAME_TEMP"] # UI tidies self.undoStack.clear() self.undoStack.setClean() self.workingFilename = filename self.setWindowTitle("Depends (%s)" % self.workingFilename) self.variableWidget.rebuild(depends_variables.variableSubstitutions) self.addRecentItem(filename) self.rebuildRecentMenu() return True
def setupStartupVariables(self): """ Each program starts with a set of workflow variables that are defined by where the program is executed from and potentially a set of environment variables. """ # The current session gets a "binary directory" variable depends_variables.add('DEPENDS_DIR') depends_variables.setx('DEPENDS_DIR', os.path.dirname(os.path.realpath(__file__)), readOnly=True) # ...And a path that points to where the nodes are loaded from depends_variables.add('NODE_PATH') if not os.environ.get('DEPENDS_NODE_PATH'): depends_variables.setx('NODE_PATH', os.path.join( depends_variables.value('DEPENDS_DIR'), 'nodes'), readOnly=True) else: depends_variables.setx('NODE_PATH', os.environ.get('DEPENDS_NODE_PATH'), readOnly=True)