(re)mounting a bootloader device drive, via python

173 views Asked by At

I am attempting to install a bootloader onto a device. The device is designed to connect as a flash/USB drive and accept the bootloader via file copy. I have to create software in Python to automate this process.

The (Manual) testing process I have used is as follows:

  1. Plug in the USB connection.
  2. check for a mock file indicating device is ready.
  3. copy over the bootloader (drag and drop)
  4. wait for device to unmount and remount itself.
  5. check for a mock file indicating success or fail/error.

When automating this in Python, during or after step 3 I find the device does not remount, and 'disappears' from the system.

In Linux the device connection appears busy for 30 seconds, then unmounts and the device file under /dev disappears completely.

In Windows7 I tried the 'mountvol' command, but the device unmounts immediately and disappears, the volume description in 'mountvol /l' also disappears.

Also I have been trying with the subprocess.Popen and subprocess.call methods, and the os.spawn*** and os.system methods. Only os.system works on both Win7 and Linux, while Popen, spawnlp and call will report 'file not found' in windows. my process is:

args = ("copy", bootloader_filepath, destination_drive)
p = Popen(args, stdout=PIPE)
output = p.communicate()

after executing line 3, I get the reported error mentioned above.

I want to find a way to tell the OS to rescan for drives, then recognise the correct drive for the bootloader, preferably in Windows7. I need to know what command line utilities and python modules I can use to do this, possibly something in os module I haven't encountered yet?

Also I want to understand how to properly (or at least without errors) use subprocesses like os.spawn*** and Popen to perform file copying, or if an alternative in the os module exists, how to use that?

Any other suggestions are welcome, too.

0

There are 0 answers