bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: python (parted) question


From: Paul Telford
Subject: Re: python (parted) question
Date: Mon, 8 Sep 2003 15:40:47 -0700 (PDT)

[ Please CC replies, I'm not subscribed to either list ]
[ d-python: this is a restatement of my previous question. Hope its ]
[ clearer this time. ]

I posed this question several days ago and received no response.  mdz
(correctly) nudged me with a cluestick by telling me that perhaps I should
be more specific in describing my problem.  So here goes... I'm no python
hacker, so maybe I'm missing something obvious.

I have attached part of a script (python_parted).  It is intended to
partition a disk drive.  I have edited out much of the script before and
after the problem section (such as reading in config files, etc) so that
the size is manageable, if you want the complete script refer to the
'autoinstall' package in Debian unstable.  (I believe the included section
completely describes the problem.)  I have also attached the partition.py
module which is loaded by this script.  All other modules should be
standard... available from either the python or python-parted packages 
in
Debian unstable.

My problem occurs at line 101 of python_parted, that reads:
        drvnewpart = drvdisk.get_partition(drvpartnum)

The get_partition function is defined by the parted module, and always
returns 'None' when I call it.  I have stepped through line-by-line and
every other value appears to be correct up to that point.

get_partition is as follows:

    def get_partition(self, num):
        """Returns the partition numbered num.
        """

        r = _parted.disk_get_partition(self._o, num)
        if r:
            return Partition(self, None, None, None, None, r)
        else:
            return None



and the corresponding C call which accesses libparted:

static PyObject *
disk_get_partition(PyObject *self, PyObject *args)
{
        PyPartedObject *o;
        int num;

        if (!PyArg_ParseTuple(args, "Oi", &o, &num))
                return NULL;

        return PyPartedObject_new("PedPartition",
                                  ped_disk_get_partition((PedDisk *)o->obj,
                                                         num));
}



This same code worked with libparted1.4, and broke at the 1.6 upgrade.  
I'm not sure if the problem is in libparted, python-parted, or user-error.  
I'm perfectly willing to accept the latter, but I hope to find a solution 
anyway.  :)

Is anyone else out there even using python-parted?  There doesn't seem to 
be much info about it...


Thanks,


--
Paul Telford | 1024D/431B38BA | address@hidden | address@hidden
       C903 0E85 9AF5 1B80 6A5F  F169 D7E9 4363 431B 38BA





Attachment: python_parted
Description: Text document

Attachment: partition.py
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]