Ejemplo n.º 1
0
def configureTemplate(settings, template_filename, keywords):

    import jinja2, os, inspect
    from jinja2 import Environment, FileSystemLoader, StrictUndefined

    template_path = settings.repo_path + "/html"

    env = Environment(loader=FileSystemLoader(template_path), \
                                     undefined = StrictUndefined)

    #addGlobalJinjaFunction(GetComponentLink)

    try:
        creator = env.get_template(template_filename)

    except jinja2.exceptions.TemplateError as e:
        unrecoverableError("Failed creating jinja creator\n" + str(e))

    try:
        replacedContent = creator.render(keywords)
    except (jinja2.exceptions.TemplateError) as e:
        unrecoverableError("Failed rendering jinja template \'" + \
           template_filename + "\'\n" + str(e))

    return replacedContent  #.encode('utf8')
Ejemplo n.º 2
0
 def __init__(self, settings, filename):
    
    import os.path
    
    self.settings = settings
    self.filename = filename
    
    if not self.filename:
       unrecoverableError("No binary filename defined")
       
    if not os.path.isfile(self.filename):
       unrecoverableError("Unable to find filename {filename}".format(filename = filename))
    
    self.symbols = {}
    
    self.parseSymbols()
Ejemplo n.º 3
0
 def considerCommandLineArgs(self, cmd_line_args):
    
    for parameter in self.parameters:
       
       if parameter.no_cmd_line:
          continue
       
       if hasattr(cmd_line_args, parameter.name):
          value = getattr(cmd_line_args, parameter.name)
          
          if value != parameter.default:
             setattr(self, parameter.name, value)
             
    if len(cmd_line_args.binaries) == 0:
       pass               
    elif len(cmd_line_args.binaries) == 2:
       if self.old_binary_filename:
          unrecoverableError("Old binary filename redundantly defined")
          
       else:
          self.old_binary_filename = cmd_line_args.binaries[0]
          
       if self.new_binary_filename:
          unrecoverableError("Old binary filename redundantly defined")
          
       else:
          self.new_binary_filename = cmd_line_args.binaries[1]
    else:
       unrecoverableError("Please specify either none or two binaries")
Ejemplo n.º 4
0
 def readDriverFile(self):
    
    import yaml
    
    my_yaml = None
    with open(self.driver_file, 'r') as stream:
       try:
          my_yaml = yaml.load(stream)
       except yaml.YAMLError as exc:
          unrecoverableError(exc)
       
    for parameter in self.parameters:
       
       if parameter.name in my_yaml.keys():
          
          setattr(self, parameter.name, my_yaml[parameter.name])
       
    # Read binary pairs
    
    if "binary_pairs" in my_yaml.keys():
       
       bin_pair_id = 1
       
       for data_set in my_yaml["binary_pairs"]:
          
          short_name = data_set.get("short_name")
          if not short_name:
             unrecoverableError("No short_name defined for binary pair " + str(bin_pair_id))
             
          old_binary = data_set.get("old_binary")
          if not old_binary:
             unrecoverableError("No old_binary defined for binary pair " + str(bin_pair_id))
             
          new_binary = data_set.get("new_binary")
          if not new_binary:
             unrecoverableError("No new_binary defined for binary pair " + str(bin_pair_id))
          
          bp = BinaryPairSettings(short_name, \
                                  old_binary, \
                                  new_binary)
             
          self.mass_report_members.append(bp)
          
          bin_pair_id += 1
Ejemplo n.º 5
0
    def validateSettings(self):
        if not self.settings.old_binary_filename:
            unrecoverableError("No old binary filename defined")

        if not self.settings.new_binary_filename:
            unrecoverableError("No new binary filename defined")
Ejemplo n.º 6
0
   def validateAndInitSettings(self):
            
      if self.old_binary_filename and not os.path.isfile(self.old_binary_filename):
         unrecoverableError("Old binary \'%s\' is not a file or cannot be found" % (self.old_binary_filename))
         
      if self.new_binary_filename and not os.path.isfile(self.new_binary_filename):
         unrecoverableError("New binary \'%s\' is not a file or cannot be found" % (self.new_binary_filename))

      self.objdump_command = self.bin_dir + "/" + self.bin_prefix + "objdump"
      self.nm_command = self.bin_dir + "/" + self.bin_prefix + "nm"
      self.size_command = self.bin_dir + "/" + self.bin_prefix + "size"
      
      if (not os.path.isfile(self.objdump_command)) or (not os.access(self.objdump_command, os.X_OK)):
         unrecoverableError("objdump command \'%s\' is either not a file or not executable" % (self.objdump_command))
         
      if (not os.path.isfile(self.nm_command)) or (not os.access(self.nm_command, os.X_OK)):
         unrecoverableError("nm command \'%s\' is either not a file or not executable" % (self.nm_command))
               
      if (not os.path.isfile(self.size_command)) or (not os.access(self.size_command, os.X_OK)):
         unrecoverableError("size command \'%s\' is either not a file or not executable" % (self.size_command))
         
      if self.old_info_file:
         if os.path.isfile(self.old_info_file):
            with open(self.old_info_file, "r") as f:
               self.old_binary_info = f.read()
         else:
            unrecoverableError("Unable to find old info file \'%s\'" % (self.old_info_file))
      else:
         self.old_binary_info = ""
         
      if self.new_info_file:
         if os.path.isfile(self.new_info_file):
            with open(self.new_info_file, "r") as f:
               self.new_binary_info = f.read()
         else:
            unrecoverableError("Unable to find new info file \'%s\'" % (self.new_info_file))
      else:
         self.new_binary_info = ""     
         
      if not self.old_alias: 
         self.old_alias = self.old_binary_filename
      
      if not self.new_alias:
         self.new_alias = self.new_binary_filename