def update_check_script(self, updates, author=None):
     """
     The function updates check script with license file
     and with API functions like check_rpm_to and check_applies_to
     """
     script_type = FileHelper.get_script_type(self.check_script_path)
     if author is None:
         author = "<empty_line>"
     generated_section, functions = ModuleHelper.generate_common_stuff(
         settings.license % author, updates, script_type)
     lines = FileHelper.get_file_content(self.check_script_path, "rb",
                                         method=True)
     if not [x for x in lines if re.search(r'#END GENERATED SECTION', x)]:
         raise MissingHeaderCheckScriptError(self.check_script_path)
     for func in functions:
         lines = [x for x in lines if func not in x.strip()]
     output_text = ""
     for line in lines:
         if '#END GENERATED SECTION' in line:
             new_line = '\n'.join(generated_section)
             new_line = new_line.replace('<empty_line>',
                                         '').replace('<new_line>', '')
             output_text += new_line + '\n'
         output_text += line
     FileHelper.write_to_file(self.check_script_path, "wb", output_text)
 def update_check_script(self, updates, author=None):
     """
     The function updates check script with license file
     and with API functions like check_rpm_to and check_applies_to
     """
     script_type = FileHelper.get_script_type(self.full_path_name)
     if author is None:
         author = "<empty_line>"
     generated_section, functions = ModuleHelper.generate_common_stuff(settings.license % author,
                                                                       updates,
                                                                       script_type)
     lines = FileHelper.get_file_content(self.full_path_name, "rb", method=True)
     if not [x for x in lines if re.search(r'#END GENERATED SECTION', x)]:
         MessageHelper.print_error_msg("#END GENERATED SECTION is missing in check_script %s" % self.full_path_name)
         raise MissingHeaderCheckScriptError
     for func in functions:
         lines = [x for x in lines if func not in x.strip()]
     output_text = ""
     for line in lines:
         if '#END GENERATED SECTION' in line:
             new_line = '\n'.join(generated_section)
             new_line = new_line.replace('<empty_line>', '').replace('<new_line>', '')
             output_text += new_line+'\n'
             if 'check_applies' in updates:
                 component = updates['check_applies']
             else:
                 component = "distribution"
             if script_type == "sh":
                 output_text += 'COMPONENT="'+component+'"\n'
             else:
                 output_text += 'set_component("'+component+'")\n'
         output_text += line
     FileHelper.write_to_file(self.full_path_name, "wb", output_text)
예제 #3
0
 def update_check_script(self, updates, author=None):
     """
     The function updates check script with license file
     and with API functions like check_rpm_to and check_applies_to
     """
     script_type = FileHelper.get_script_type(self.check_script_path)
     if author is None:
         author = "<empty_line>"
     generated_section, functions = ModuleHelper.generate_common_stuff(
         settings.license % author, updates, script_type)
     lines = FileHelper.get_file_content(self.check_script_path,
                                         "rb",
                                         method=True)
     if not [x for x in lines if re.search(r'#END GENERATED SECTION', x)]:
         raise MissingHeaderCheckScriptError(self.check_script_path)
     for func in functions:
         lines = [x for x in lines if func not in x.strip()]
     output_text = ""
     for line in lines:
         if '#END GENERATED SECTION' in line:
             new_line = '\n'.join(generated_section)
             new_line = new_line.replace('<empty_line>',
                                         '').replace('<new_line>', '')
             output_text += new_line + '\n'
         output_text += line
     FileHelper.write_to_file(self.check_script_path, "wb", output_text)
예제 #4
0
 def solution_modification(self, key):
     """Function handles a solution text or scripts"""
     fix_tag = []
     for k in key['solution'].split(','):
         self.mh.check_scripts('solution')
         script_type = FileHelper.get_script_type(self.mh.get_full_path_name_solution())
         if script_type == "txt":
             fix_tag.append(xml_tags.FIX_TEXT)
         else:
             fix_tag.append(xml_tags.FIX)
         if 'solution_type' in key:
             solution_type = key['solution_type']
         else:
             solution_type = "text"
         self.update_values_list(fix_tag, "{solution_text}", solution_type)
         self.update_values_list(fix_tag, "{solution}", k.strip())
         self.update_values_list(fix_tag, "{script_type}", script_type)
     self.update_values_list(self.rule, '{fix}', ''.join(fix_tag))
예제 #5
0
 def solution_modification(self, key):
     """Function handles a solution text or scripts"""
     fix_tag = []
     for k in key['solution'].split(','):
         self.mh.check_scripts('solution')
         script_type = FileHelper.get_script_type(
             self.mh.get_full_path_name_solution())
         if script_type == "txt":
             fix_tag.append(xml_tags.FIX_TEXT)
         else:
             fix_tag.append(xml_tags.FIX)
         if 'solution_type' in key:
             solution_type = key['solution_type']
         else:
             solution_type = "text"
         self.update_values_list(fix_tag, "{solution_text}", solution_type)
         self.update_values_list(fix_tag, "{solution}", k.strip())
         self.update_values_list(fix_tag, "{script_type}", script_type)
     self.update_values_list(self.rule, '{fix}', ''.join(fix_tag))
예제 #6
0
 def update_check_script(self, updates, author=None):
     """
     The function updates check script with license file
     and with API functions like check_rpm_to and check_applies_to
     """
     script_type = FileHelper.get_script_type(self.full_path_name)
     if author is None:
         author = "<empty_line>"
     generated_section, functions = ModuleHelper.generate_common_stuff(
         settings.license % author, updates, script_type)
     lines = FileHelper.get_file_content(self.full_path_name,
                                         "rb",
                                         method=True)
     if not [x for x in lines if re.search(r'#END GENERATED SECTION', x)]:
         MessageHelper.print_error_msg(
             "#END GENERATED SECTION is missing in check_script %s" %
             self.full_path_name)
         raise MissingHeaderCheckScriptError
     for func in functions:
         lines = [x for x in lines if func not in x.strip()]
     output_text = ""
     for line in lines:
         if '#END GENERATED SECTION' in line:
             new_line = '\n'.join(generated_section)
             new_line = new_line.replace('<empty_line>',
                                         '').replace('<new_line>', '')
             output_text += new_line + '\n'
             if 'check_applies' in updates:
                 component = updates['check_applies']
             else:
                 component = "distribution"
             if script_type == "sh":
                 output_text += 'COMPONENT="' + component + '"\n'
             else:
                 output_text += 'set_component("' + component + '")\n'
         output_text += line
     FileHelper.write_to_file(self.full_path_name, "wb", output_text)