Exemple #1
0
 def kh_loadCommandFile(self, arg0, tokens, ref):
     fname = utils.strip_parentheses(reconstruct_line(tokens).strip())
     # fname is given relative to current working directory
     fname_expanded = self.env.replace(fname)
     self.kh_shell_command('<', tokens, ref)
     try:
         obj = CommandFile(self, fname_expanded, ref, self.env, self.symbols)
         self.includedCommandFile_list.append(obj)
     except FileNotFound, _exc:
         msg = 'File not found: ' + fname_expanded
         utils.detailedExceptionLog(msg)
         return
Exemple #2
0
 def kh_epicsEnvSet(self, arg0, tokens, ref):
     '''symbol assignment'''
     if len(tokens) == 7:
         var = tokens[2]['tokStr']
         value = tokens[4]['tokStr']
     else:
         text = utils.strip_parentheses(reconstruct_line(tokens).strip())
         parts = text.split(',')
         if len(parts) == 1:
             parts = text.split(' ')
         if len(parts) != 2:
             raise UnhandledTokenPattern('epicsEnvSet'+text)
         var, value = parts
     self.env.set(utils.strip_quotes( var ), utils.strip_quotes( value ), self, ref)
     self.kh_shell_command(arg0, tokens, ref)
Exemple #3
0
 def kh_dbLoadTemplate(self, arg0, tokens, ref):
     # TODO: Can one template call another?
     local_macros = macros.Macros(**self.env.db)
     args = utils.strip_parentheses(reconstruct_line(tokens).strip()).split(',')
     if len(args) in (1, 2):
         tfile = os.path.join(os.getcwd(), utils.strip_quotes(args[0]))
     if len(args) == 2:
         # such as in 8idi:  dbLoadTemplate("aiRegister.substitutions", top)
         # This is an ERROR.  The IOC should be corrected.
         '''from the EPICS documentation regarding dbLoadTemplate():
         
         dbLoadTemplate(char *subfile, char *substitutions)
         
         This IOC command reads a template substitutions file which 
         provides instructions for loading database instance files 
         and gives values for the $(xxx) macros they may contain. 
         This command performs those substitutions while loading the 
         database instances requested.
         
         The subfile parameter gives the name of the template substitution file to be used. 
         The optional substitutions parameter may contain additional global macro values, 
         which can be overridden by values given within the substitution file.
         '''
         path = self.symbols.get(utils.strip_quotes(args[1]).strip(), None)
         if isinstance(path, macros.KVpair):
             alternative = os.path.join(path.value, tfile)
             if os.path.exists(alternative):
                 tfile = alternative
         else:
             msg = 'problem parsing: ' + arg0 + reconstruct_line(tokens).strip()
             utils.logMessage(msg, utils.LOGGING_DETAIL__IMPORTANT)
     obj = template.Template(tfile, ref, **local_macros.db)
     self.template_list.append(obj)
     self.database_list += obj.database_list
     self.kh_shell_command(arg0, tokens, ref)
     for k, v in obj.getPVs():
         self.pv_dict[k] = v