Merge pull request #217 from advaithm/torxed-v2.2.0

added isVM function
This commit is contained in:
Anton Hvornum 2021-04-07 11:40:28 +00:00 committed by GitHub
commit 04bc9ce05f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -41,4 +41,12 @@ def cpuVendor()-> Optional[str]:
if info.get('field',None):
if info.get('field',None) == "Vendor ID:":
return info.get('data',None)
def isVM() -> bool:
try:
subprocess.check_call(["systemd-detect-virt"]) # systemd-detect-virt issues a none 0 exit code if it is not on a virtual machine
return True
except:
return False
# TODO: Add more identifiers