Retrieve computer information in Python

Yan 9 years ago in Scripting 0

I was asked recently if their was any equivalent to the substitution parameters found in Micromine macros:

@username Current user's username 

@networkdomain Current user's network domain 

@computername Current user's computer name 

@windowsversion Current user's Windows operating system version 

in the MMpy python module.

The quick answer is no, but yes! The main difference between macros and scripting in Micromine is that when you are using python scripts you are actually using a complete programming language that can get all those informations.

In python, most operating system information can be found in the os module. You simply need to import the module :

import os
This module contains a mapping object called environ that contains a lot of information relevant to the computer. You can access specific field:


or list all the properties:

for k, v in os.environ.items():      
print("%s=%s" % (k, v))