On Tue, Aug 17, 2010 at 1:19 AM, Jasper Hartline jasper.hartline@gmail.com wrote:
On Mon, Aug 16, 2010 at 7:56 PM, Richard Shaw hobbes1069@gmail.com wrote:
It's probably overkill but I know there's the optparse module for passing arguments and options. Not really necessary since the script requires exactly 3 arguments but it would add somewhat automagically things like --help and --version.
Right, these should be added.
I can help there (when I have time) if it's not something you're familiar with, but I would rather wait for any updates you're already thinking about to make the 'patch' easier.
Is there any difference between os.stat().st_size and os.path.getsize()?
Not one I can think of, they both would require the os module. Maybe there is something better in Python 2.7
I did some research in the python docs and there isn't any difference but it recommended the os.path method unless you're trying to get more than one attribute of a file to prevent multiple stat() calls.
Do we care if one of the argument references is a symbolic link? I think it's just personal preference in coding style but I tend to use more high level functions like os.path.isfile() versus os.stat()
I just threw it together, so little things like that can and need to be changed.
I think it needs to be changed to os.path.getsize(). I tried os.stat() on a directory and as I expected it returned true. Some other checking may also be a good idea, like is it an ISO. I'm not sure how you prove that but checking for a .iso extension would be easy.
It looks like as this is a largely procedural style script that there is some things done twice (once for the 32bit image and once for the 64bit image) which could be generalized in a function.
That is true. I will see if I can do some more hacking on it.. Any patches are welcome.
I'll see what I can do.
[SNIP]
I need to see where I am faouling up because it seems livecd-iso-to-disk is stepping on my partition table from --reset-mbr and --format command.
Take a look at this: http://autopsy.liveprojects.info/repo/SOURCES/c-section/live_generator/insta... Just Edit -> Find in this page -> "kpartx"
That is a way to use dmsetup and kpartx (device mapper) to actually make the loop device have partitions which we are more used to using.
I think my offset into the original file is off in the second loop device setup.
I checked out the link and it obviously uses a lot of shell commands. I think at some point a shell script would be better than a bunch of subprocess calls, however, I think much of it could be mitigated by using modules that allow us to get the same result without the subprocess calls. I haven't had time to check it out, but I saw a reference to pyparted which might allow us to do the 'partitioning' of the lodev natively.
Richard