本文整理汇总了Python中options.Options.enablePerm方法的典型用法代码示例。如果您正苦于以下问题:Python Options.enablePerm方法的具体用法?Python Options.enablePerm怎么用?Python Options.enablePerm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类options.Options
的用法示例。
在下文中一共展示了Options.enablePerm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from options import Options [as 别名]
# 或者: from options.Options import enablePerm [as 别名]
#.........这里部分代码省略.........
grub_config_file = self.grubDir / "grub.cfg"
if self.grubConf not in grub_config_file.text():
grub_config_file.write_text("### BEGIN GrubEnhancer Config ###\n" + self.grubConf + "### END GrubEnhancer Config ###\n", append=True)
# Écriture des fonctions GRUB
greffons = self.grubDir / "greffons"
if not greffons.isdir():
greffons.mkdir()
fonctionsFile = greffons / "fonctions_iso.cfg"
self.grubFonctionsFile.copy(fonctionsFile)
# Création des Loopback et du Custom
custom = self.grubDir / "custom.cfg"
custom_content = [self.customIncipit]
temporary = False
for entry in entries:
# Récupération des paramètres
name = entry.text()
if name == "<New>":
continue
iso_location = path(entry.getIsoLocation())
print(iso_location)
loopback_content = entry.getLoopbackContent()
loopback_location = path(iso_location.replace('.iso', '.loopback.cfg'))
mountpoint = path(entry.getMountPoint())
permanent = entry.getPermanent()
# Création d'un lien si espaces
if " " in iso_location:
# Création d'un lien pour l'iso
full_iso_location = mountpoint / iso_location[1:]
symlink_iso = mountpoint / iso_location.basename()
try:
full_iso_location.link(symlink_iso)
except FileExistsError: pass
iso_location = symlink_iso.replace(mountpoint, "", 1)
# Création du Loopback
print(iso_location, loopback_location, mountpoint, sep=" : ")
if loopback_content:
full_loopback_location = mountpoint / loopback_location[1:] # On vire toujours le premier /
full_loopback_location.write_text(loopback_content)
if " " in loopback_location:
# Création d'un lien pour le loopback
symlink_loopback = mountpoint / loopback_location.basename()
try:
full_loopback_location.link(symlink_loopback)
except FileExistsError: pass
loopback_location = symlink_loopback.replace(mountpoint, "", 1)
# Création d'une ligne du Custom
if permanent:
if loopback_content:
custom_line = '\tsubmenu "' + name + '" {iso_boot "' + iso_location + '" "' + loopback_location + '"} #' + mountpoint + '\n'
else:
custom_line = '\tsubmenu "' + name + '" {iso_boot "' + iso_location + '"} #' + mountpoint + '\n'
else:
if loopback_content:
custom_line = 'amorce_iso "{}" "{}" #{}\n'.format(iso_location, loopback_location, mountpoint)
else:
custom_line = 'amorce_iso "{}" #{}\n'.format(iso_location, mountpoint)
temporary = True
custom_content.append(custom_line)
# Création du Custom
custom.write_lines(custom_content)
# Mise à jour de l'environement de GRUB
if temporary:
question = QMessageBox(self)
question.setText("Votre configuration contient une entrée temporaire.")
question.setInformativeText("Voulez-vous l'activer ?")
question.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
question.setDefaultButton(QMessageBox.Yes)
answer = question.exec_()
if answer == QMessageBox.Yes:
subprocess.call(["grub-editenv", self.grubDir / "grubenv", "set", "amorceiso=true"])
# Affichage d'un message de confirmation
msg = "Vos modifications ont bien été prises en compte."
info = QMessageBox(self)
info.setWindowTitle("GrubEnhancer")
info.setText(msg)
info.exec_()
def loadGrubDir(self):
self.customEditor.setGrubRep(self.grubDir)
forbiddenFilesystem = ("btrfs", "cpiofs", "newc","odc",
"romfs", "squash4", "tarfs", "zfs")
forbiddenDeviceName = ("/dev/mapper", "/dev/dm", "/dev/md")
filesystem = subprocess.check_output(["grub-probe", "--target=fs", self.grubDir]).decode().split()[0]
disque = subprocess.check_output(["grub-probe", "--target=disk", self.grubDir]).decode().split()[0]
if filesystem in forbiddenFilesystem or disque.startswith(forbiddenDeviceName):
self.options.disablePerm()
else:
self.options.enablePerm()
@pyqtSlot()
def chooseAnotherGrubDir(self):
choices = GrubList(parent=self)
grubDir = choices.selectGrubRep()
if grubDir:
self.grubDir = path(grubDir)
self.loadGrubDir()