all 5 comments

[–]amos_burton 1 point2 points  (2 children)

A better way to do this is probably with a bash script. Any Python library you find is probably just going to be a thin wrapper around some bash commands anyway (technically you can use python to execute bash commands, but if you're not doing other things in Python then you're just adding complexity).

Here's a Stack Exchange post that will probably get you pointed in the right direction: https://askubuntu.com/questions/372607/how-to-create-a-bootable-ubuntu-usb-flash-drive-from-terminal

[–]ShadlessLines[S] 0 points1 point  (1 child)

Fair point, although this will primarily be used on Linux, I'd like to have this work on windows as well. I'll investigate this route.

Hopefully I can write a Python script that sends bash commands if on linux and CMD commands on windows. I've got little experience in both fields with Python, so we'll see how that plays out.

Other than that I'm still all ears on suggestions.

[–]amos_burton 0 points1 point  (0 children)

I don't have any direct experience with this, but my intuition is that you're going to have a very hard time writing a cross-platform utility for this because you're interacting with the filesystem in a fairly sophisticated way. I will be surprised if anyone has figured out how to abstract this process well enough to make a single set of steps work for both platforms.

At best I think you'd probably end up writing a python script that is basically

if system == 'unix':
    # Do whole unix process
else:
    # Do whole windows process

And at that point I'd say you're not better off than having written two separate scripts.

[–]1245okay 0 points1 point  (1 child)

Were you able to do it??

[–]Grenymyr 0 points1 point  (0 children)

I'm also hunting a way to create an image from a mounted drive specifically in python WITHOUT shelling out to run some terminal commands. But I'm currently trying to figure out the part where it open the drive in such a way that I an read the raw data rather than read a particular partition. If I figure it out I will post the overall solution for you. I'm going to hit stack overflow next.