-1

I'm writing a licensing system and I need a way to get the computer's hard drive (or SSD, if that matters) serial number, completely OS-independent and Pythonic way.

For example, I can use subprocess.check_output() to run wmic diskdrive get model,serialnumber, but

  1. It works only on Windows;
  2. It runs system shell commands, which is not Pythonic.

Thanks in advance!

  • 2
    You won’t be able to make it “OS independent”, at best you can figure out all the different ways to do it for all the different OSs and choose the appropriate one dynamically. – deceze May 31 '22 at 07:26
  • https://www.thepythoncode.com/article/get-hardware-system-information-python Check this tutorial , in this tutorial used psutil python package – Gajanan May 31 '22 at 07:26
  • You can use fcntl python module on linux (https://docs.python.org/3/library/fcntl.html) and (https://stackoverflow.com/questions/4193514/how-to-get-hard-disk-serial-number-using-python) – LSeu May 31 '22 at 09:23

0 Answers0