0

I have a project in my job. The target is to prepare 14 SD cards for provisioning any Raspberry Pi 3. So I have to found a solution to do it automatically and follow which SD card is ready to start and which one is complete.

I have the idea to build with a Python3 program and a tkinter interface because I know a little bit Python and not others languages...

The program should work like this :

  • List every Windows drives where SD card is mounted

  • Push a button in front of the letter of the SD card drive to start the provisioning.

  • The provisioning is all steps to make the SD cards bootable with an OS. So I have to pass some DISKPART commands or equivalent in Python I think, if you have any suggestions ?

  • Show a statut in front of each drive to follow if the drive is pending, working, complete, etc.

I have a huge interogation about this. My program has to refresh every informations. I mean the program should work in real time or not ? What is the best way to proceed ?

To be clear, I don't want someone building to me this program, I just want to have some good idea to implement.

Thank you

  • you could have the whole thing running in a loop that calls get_drives() periodically, then compare the return value with the value from the previous run and react if it changed. Tell us what you have tried and what was the specific problem stopping you? Without more information it's hard to tell what your actual problem is. – Zinki Nov 29 '17 at 14:47
  • I updated my post with the entire story :) –  Nov 29 '17 at 15:49

2 Answers2

0

I can't help with the Python part, but if you have a WinAPI window with message handling (so the WindowProc thing), WM_DEVICECHANGE is the message, here are the actual event categories and RegisterDeviceNotification is how you subscribe to it. Complete (but C) MSDN example is here

While implementing it may require some work, viability itself depends on getting access/not getting access to the message queue (from Python). Based on this and this it seems to be possible, but I have no experience with it.

tevemadar
  • 12,389
  • 3
  • 21
  • 49
  • Many thanks for you answer. I updated my post with my entire issue. –  Nov 29 '17 at 15:49
0

You can use this module to execute commands. For example:

import subprocess

completed = subprocess.run(['ls', '-1'])
print('returncode:', completed.returncode)
F.M.F.
  • 1,929
  • 3
  • 23
  • 42