예제 #1
0
 def set_splash(self, active, image_name):
     """Set the name of the currently active Grub splash
     active = boolean, whether the grub splash should be shown
     """
     self.default_image = image_name
     self.show_splash = active
     image_name = image_name + ".xpm.gz"
     text = "\n#A splash image for the menu\n"
     if self.__get_line_number("splashimage") != -1:
         image_name = utils.fix_filename_spaces(image_name)
         if active:
             text = "splashimage=" + self.groot + self.splashdir
         else:
             text = "#splashimage=" + self.groot + self.splashdir
         self.__change_config("splashimage", None, text + image_name + "\n")
     else:
         for splash_file in os.listdir(self.mounted_splashdir):
             if image_name == splash_file:
                 image_name = utils.fix_filename_spaces(image_name)
                 if active:
                     text = text + "splashimage=" + \
                            self.groot + self.splashdir
                 else:
                     text = text + "#splashimage=" + \
                            self.groot + self.splashdir
                 self.__change_config("color", "\n", "\n" + 
                                      text + image_name + "\n")
예제 #2
0
 def set_splash(self, active, image_name):
     """Set the name of the currently active Grub splash
     active = boolean, whether the grub splash should be shown
     """
     self.default_image = image_name
     self.show_splash = active
     image_name = image_name + ".xpm.gz"
     text = "\n#A splash image for the menu\n"
     if self.__get_line_number("splashimage") != -1:
         image_name = utils.fix_filename_spaces(image_name)
         if active:
             text = "splashimage=" + self.groot + self.splashdir
         else:
             text = "#splashimage=" + self.groot + self.splashdir
         self.__change_config("splashimage", None, text + image_name + "\n")
     else:
         for splash_file in os.listdir(self.mounted_splashdir):
             if image_name == splash_file:
                 image_name = utils.fix_filename_spaces(image_name)
                 if active:
                     text = text + "splashimage=" + \
                            self.groot + self.splashdir
                 else:
                     text = text + "#splashimage=" + \
                            self.groot + self.splashdir
                 self.__change_config("color", "\n",
                                      "\n" + text + image_name + "\n")
예제 #3
0
 def add_image(self, filename):
     """Convert filename to correct format and add as a splashimage
     Return False if the image format is not supported.
     True if it was added successfully.
     Note that any spaces in the filename itself(not in the path) will be 
     removed since Grub does not appear to support them at this time.
     """
     pathless = filename[filename.rfind("/") + 1:]
     pathless = pathless.replace(' ', '')
     fixed_filename = utils.fix_filename_spaces(filename)
     end = filename.rfind(".")
     if not end == -1:
         if filename[end:] == ".gz":
             end = filename[:-3].rfind(".")
         if filename[end:] == ".xpm.gz":
             shutil.copy(filename, self.mounted_splashdir + pathless)
             self.__check_themes()
         elif filename[end:] == ".xpm":
             os.system("gzip -c " + fixed_filename + " > " + 
                       self.mounted_splashdir + pathless + ".gz")
             self.__check_themes()
         elif self.convert_exist and os.system('file ' + fixed_filename + 
                        ' | grep -oE "image|bitmap"') == 0:
             end = pathless.rfind(".")
             os.system("convert " + fixed_filename +
                       " -resize 640x480 -colors 14 " +
                       pathless[:end] + ".xpm")
             os.system("gzip -c " + pathless[:end] + ".xpm" + " > " +
                       self.mounted_splashdir + pathless[:end] + ".xpm.gz")
             os.system("rm -f " + pathless[:end] + ".xpm")
             self.__check_themes()
         else:
             return False
         return True
예제 #4
0
 def add_image(self, filename):
     """Convert filename to correct format and add as a splashimage
     Return False if the image format is not supported.
     True if it was added successfully.
     Note that any spaces in the filename itself(not in the path) will be 
     removed since Grub does not appear to support them at this time.
     """
     pathless = filename[filename.rfind("/") + 1:]
     pathless = pathless.replace(' ', '')
     fixed_filename = utils.fix_filename_spaces(filename)
     end = filename.rfind(".")
     if not end == -1:
         if filename[end:] == ".gz":
             end = filename[:-3].rfind(".")
         if filename[end:] == ".xpm.gz":
             shutil.copy(filename, self.mounted_splashdir + pathless)
             self.__check_themes()
         elif filename[end:] == ".xpm":
             os.system("gzip -c " + fixed_filename + " > " +
                       self.mounted_splashdir + pathless + ".gz")
             self.__check_themes()
         elif self.convert_exist and os.system(
                 'file ' + fixed_filename +
                 ' | grep -oE "image|bitmap"') == 0:
             end = pathless.rfind(".")
             os.system("convert " + fixed_filename +
                       " -resize 640x480 -colors 14 " + pathless[:end] +
                       ".xpm")
             os.system("gzip -c " + pathless[:end] + ".xpm" + " > " +
                       self.mounted_splashdir + pathless[:end] + ".xpm.gz")
             os.system("rm -f " + pathless[:end] + ".xpm")
             self.__check_themes()
         else:
             return False
         return True