Ejemplo n.º 1
0
 def GuppyMap(self):
     """ Creates the device map """
     gmkdevmap = self.config["grub/grub-mkdevicemap"]
     if not os.path.exists(gmkdevmap):
         # grub-2.00 and above does not have mkdevicemap - so skip it if we don't see it.
         return
     cmdobj = None
     if self.testing:
         cmdstr = "{gm} --no-floppy --device-map=/dev/null".format(
             gm=gmkdevmap)
         cmdobj = Popen(cmdstr,
                        bufsize=-1,
                        stdout=PIPE,
                        stderr=STDOUT,
                        shell=True)
     else:
         cmdobj = Popen([gmkdevmap, "--no-floppy"],
                        bufsize=-1,
                        stdout=PIPE,
                        stderr=STDOUT,
                        shell=False)
     output = cmdobj.communicate()
     if cmdobj.poll() != 0:
         raise ExtensionError("{cmd}\n{out}".format(cmd=gmkdevmap,
                                                    out=output[0].decode()))
Ejemplo n.º 2
0
 def grubProbe(self):
     gprobe = "/usr/sbin/grub-probe"
     if not os.path.exists(gprobe):
         gprobe = "/sbin/grub-probe"
     if not os.path.exists(gprobe):
         raise ExtensionError("couldn't find grub-probe")
     return gprobe
Ejemplo n.º 3
0
 def BtrfsSubvol(self):
     cmdobj = Popen("btrfs subvol list /",
                    bufsize=-1,
                    stdout=PIPE,
                    stderr=PIPE,
                    shell=False)
     output = cmdobj.communicate()[0].decode()
     retval = cmdobj.poll()
     if retval != 0:
         raise ExtensionError("btrfs command failed: %s" % output)
     return output.split()[6]
Ejemplo n.º 4
0
	def Guppy(self, argstring, fatal=True):
		""" Probes a device """
		gprobe = self.grubProbe()
		cmd = shlex.split("{gcmd} {args}".format(gcmd=gprobe, args=argstring))
		cmdobj = Popen(cmd, bufsize=-1, stdout=PIPE, stderr=PIPE, shell=False)
		output = cmdobj.communicate()
		retval = cmdobj.poll()
		if fatal and retval != 0:
			raise ExtensionError("{cmd} {args}\n{out}".format(cmd=gprobe, args=argstring, out=output[0].decode()))
		else:
			return retval, output[0].decode().strip("\n")
Ejemplo n.º 5
0
	def Guppy(self,argstring, fatal=True):
		gprobe = "/usr/sbin/grub-probe"
		if not os.path.exists(gprobe):
			gprobe = "/sbin/grub-probe"
		if not os.path.exists(gprobe):
			raise ExtensionError("couldn't find grub-probe")
		cmd = shlex.split("{gcmd} {args}".format(gcmd = gprobe, args = argstring))
		cmdobj = Popen(cmd, bufsize = -1, stdout = PIPE, stderr = STDOUT, shell = False)
		output = cmdobj.communicate()
		if cmdobj.poll() != 0:
			print("ERROR calling {cmd} {args}, Output was:\n{out}".format(cmd = gprobe, args = argstring, out = output[0].decode()))
			return None
		else:
			return output[0].decode().strip("\n")