예제 #1
0
    def setUp(self):
        self.addCleanup(self.removeTempDevice)

        self._fileSystemType = {}
        ty = _ped.file_system_type_get_next()
        self._fileSystemType[ty.name] = ty

        while True:
            try:
                ty = _ped.file_system_type_get_next(ty)
                self._fileSystemType[ty.name] = ty
            except (IndexError, TypeError, _ped.UnknownTypeException):
                break

        self.temp_prefix = "temp-device-"
        (
            self.fd,
            self.path,
        ) = tempfile.mkstemp(prefix=self.temp_prefix)
        self.f = os.fdopen(self.fd)
        self.f.seek(140000)
        os.write(self.fd, b"0")
        self.f.close()

        os.system("mke2fs -F -q %s" % (self.path, ))

        self._device = _ped.device_get(self.path)
        self._geometry = _ped.Geometry(self._device, 0,
                                       self._device.length - 1)
예제 #2
0
    def setUp(self):
        self._fileSystemType = {}
        type = _ped.file_system_type_get_next()
        self._fileSystemType[type.name] = type

        while True:
            try:
                type = _ped.file_system_type_get_next(type)
                self._fileSystemType[type.name] = type
            except:
                break

        (
            fd,
            self.path,
        ) = tempfile.mkstemp(prefix="temp-device-")
        f = os.fdopen(fd)
        f.seek(140000)
        os.write(fd, b"0")
        f.close()

        os.system("/sbin/mke2fs -F -q %s" % (self.path, ))

        self._device = _ped.device_get(self.path)
        self._geometry = _ped.Geometry(self._device, 0,
                                       self._device.length - 1)
예제 #3
0
    def setUp(self):
        self.addCleanup(self.removeTempDevice)

        self._fileSystemType = {}
        ty = _ped.file_system_type_get_next()
        self._fileSystemType[ty.name] = ty

        while True:
            try:
                ty = _ped.file_system_type_get_next(ty)
                self._fileSystemType[ty.name] = ty
            except (IndexError, TypeError, _ped.UnknownTypeException):
                break

        self.temp_prefix = "temp-device-"
        (self.fd, self.path,) = tempfile.mkstemp(prefix=self.temp_prefix)
        self.f = os.fdopen(self.fd)
        self.f.seek(140000)
        os.write(self.fd, b"0")
        self.f.close()

        os.system("mke2fs -F -q %s" % (self.path,))

        self._device = _ped.device_get(self.path)
        self._geometry = _ped.Geometry(self._device, 0, self._device.length - 1)
예제 #4
0
    def runTest(self):
        # Try getting the device we just made.
        self.assertIsInstance(_ped.device_get(self.path), _ped.Device)

        # Try getting a device that doesn't exist.
        self.assertRaises(_ped.IOException, _ped.device_get, "/blah/whatever")
        self.assertRaises(_ped.IOException, _ped.device_get, "")
        self.assertRaises(_ped.DeviceException, _ped.device_get, None)
예제 #5
0
    def runTest(self):
        # Try getting the device we just made.
        self.assertIsInstance(_ped.device_get(self.path), _ped.Device)

        # Try getting a device that doesn't exist.
        self.assertRaises(_ped.IOException, _ped.device_get, "/blah/whatever")
        self.assertRaises(_ped.IOException, _ped.device_get, "")
        self.assertRaises(_ped.DeviceException, _ped.device_get, None)
예제 #6
0
    def __init__(self, path=None, PedDevice=None):
        """Create a new Device object based on the specified path or the
           already existing _ped.Device object.  You must provide either a
           path (e.g., "/dev/sda") or an existing _ped.Device object, but
           not both."""

        if PedDevice:
            self.__device = PedDevice
        elif path is not None:
            self.__device = _ped.device_get(path)
        else:
            raise parted.DeviceException("no path or PedDevice specified")
예제 #7
0
    def setUp(self):
        self._fileSystemType = {}
        type = _ped.file_system_type_get_next()
        self._fileSystemType[type.name] = type

        while True:
            try:
                type = _ped.file_system_type_get_next(type)
                self._fileSystemType[type.name] = type
            except:
                break

        (fd, self.path,) = tempfile.mkstemp(prefix="temp-device-")
        f = os.fdopen(fd)
        f.seek(140000)
        os.write(fd, b"0")
        f.close()

        os.system("/sbin/mke2fs -F -q %s" % (self.path,))

        self._device = _ped.device_get(self.path)
        self._geometry = _ped.Geometry(self._device, 0, self._device.length - 1)
예제 #8
0
 def setUp(self):
     RequiresDeviceNode.setUp(self)
     self._device = _ped.device_get(self.path)
     self.device = parted.getDevice(self.path)
예제 #9
0
 def setUp(self):
     RequiresDeviceNode.setUp(self)
     self._device = _ped.device_get(self.path)
     self.device = parted.getDevice(self.path)