From b6488d42a153f64e1d9594d03a73f272a28efa0f Mon Sep 17 00:00:00 2001 From: AlessandroZ Date: Fri, 10 Feb 2017 12:01:57 +0100 Subject: [PATCH] checkvm for mac os - remote function --- pupy/packages/darwin/checkvm.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pupy/packages/darwin/checkvm.py diff --git a/pupy/packages/darwin/checkvm.py b/pupy/packages/darwin/checkvm.py new file mode 100644 index 00000000..89a6474f --- /dev/null +++ b/pupy/packages/darwin/checkvm.py @@ -0,0 +1,23 @@ +import subprocess +import os + +def checkvm(): + # check existing dir + dirs = [ + '~/Library/Logs/VMWare', + '~/Library/Logs/VMWare Fusion/' + ] + + for d in dirs: + if os.path.isdir(os.path.expanduser(d)): + return 'VMWare' + + p = subprocess.Popen('system_profiler', stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True) + output, err = p.communicate() + if output: + if 'VMWare' in output: + return 'VMWare' + elif 'VirtualBox' in output: + return 'VirtualBox' + + return None \ No newline at end of file