def __init__(self, filename): assert isinstance(filename, str) ui.debug("parsing " + filename) with ui.ident: self.filename = filename self.name = self.__get_module_name(filename) self.tokens = lexer.parse(filename) self.__parse() variables.add(self.name, "$__path", os.path.dirname(filename)) variables.add_empty(self.name, "$__null")
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"]) # Tell the sceneGraphWidget about the new groups for key in self.dag.nodeGroupDict: self.graphicsScene.addExistingGroupBox(key, self.dag.nodeGroupDict[key]) # Variable substitutions self.clearVariableDictionary() for v in snapshot["DAG"]["VARIABLE_SUBSTITIONS"]: 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 variables.names(): variables.add('WORKFLOW_DIR') 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(variables.variableSubstitutions) return True
def __init__(self, filename): assert isinstance(filename, str) ui.debug("parsing " + filename) with ui.ident: self.filename = filename self.name = self.__get_module_name(filename) self.tokens = lexer.parse(filename) self.__parse() variables.add( self.name, "$__path", os.path.dirname(filename)) variables.add_empty( self.name, "$__null")
def __parse_set_or_append(self, it, append): token = it.next() if token == lexer.Token.VARIABLE: variable_name = token.content else: ui.parse_error(token) second_add = False while True: token = it.next() variable = self._token_to_variable(token) if variable: if append or second_add: variables.append(self.name, variable_name, variable) else: variables.add(self.name, variable_name, variable) second_add = True elif token == lexer.Token.NEWLINE: break else: ui.parse_error(token)
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 variables.add('DEPENDS_DIR') 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 variables.add('NODE_PATH') if not os.environ.get('DEPENDS_NODE_PATH'): variables.setx('NODE_PATH', os.path.join(variables.value('DEPENDS_DIR'), 'nodes'), readOnly=True) else: variables.setx('NODE_PATH', os.environ.get('DEPENDS_NODE_PATH'), readOnly=True) # ...And a path that points to where the File Dialogs come from variables.add('FILE_DIALOG_PATH') if not os.environ.get('DEPENDS_FILE_DIALOG_PATH'): variables.setx('FILE_DIALOG_PATH', os.path.join(variables.value('DEPENDS_DIR'), 'file_dialogs'), readOnly=True) else: variables.setx('FILE_DIALOG_PATH', os.environ.get('DEPENDS_FILE_DIALOG_PATH'), readOnly=True)
def initialize(project_name, deps): try: tmp = initialize.run_once raise Exception( alertstr( str(initialize) + ''' called twice. This should never happen.''')) except AttributeError: initialize.run_once = True optimization.init() env = SCons.Environment.Environment(ENV={'PATH': os.environ['PATH']}) try: env.Append(ENV={'LD_LIBRARY_PATH': os.environ['LD_LIBRARY_PATH']}) except: pass env.EnsurePythonVersion(2, 2) env.EnsureSConsVersion(1, 0) add_methods(env) if project_name: env['projectName'] = project_name else: env['projectName'] = False env['platformName'] = platform_string.platform_string(env) variables.set_config_file(env) variables.add(env) stylize.init(env) for tool in env['tools']: env.Tool(tool) if len(deps): dependency.add_variables(env, deps) env['verbose'] = int(env['verbose']) env['vars'].Save(env['configFile'], env) format.generate_help_text(env) format.cmd_output(env) variables.load(env) optimization.set_flags(env) set_install_targets(env) env.VariantDir(env['buildObjDir'], '.', duplicate=0) env['JAVACHDIR'] = True if env['verbose'] in [1, 2]: msg = infostr('evaluating targets') SCons.Script.Progress([ ' - ' + msg + '\r', ' \\ ' + msg + '\r', ' | ' + msg + '\r', ' / ' + msg + '\r' ], interval=1) proc = Popen('which gcc', env=os.environ, shell=True, stdout=PIPE, stderr=PIPE) gccpath = proc.communicate()[0].split('\n')[0] if os.path.normpath(gccpath[:8]) != os.path.normpath('/usr/lib'): gccrpath = os.path.split(gccpath)[0].replace('bin', 'lib') if env['alignbits'] in ['native', '64']: gccrpath += '64' env.AppendUnique(RPATH=[gccrpath]) return env