Dont try to start VMs if already running

This commit is contained in:
Kovid Goyal 2012-06-03 11:34:25 +05:30
parent e545b5eb36
commit 5cc583c3bd
2 changed files with 9 additions and 0 deletions

View File

@ -67,6 +67,7 @@ class VMInstaller(Command):
INSTALLER_EXT = None
VM = None
VM_NAME = None
VM_CHECK = None
FREEZE_COMMAND = None
FREEZE_TEMPLATE = 'python setup.py {freeze_command}'
SHUTDOWN_CMD = ['sudo', 'poweroff']
@ -117,6 +118,13 @@ class VMInstaller(Command):
def run_vm(self):
pat = '/%s/'%(self.VM_CHECK or self.VM_NAME)
pids= [pid for pid in os.listdir('/proc') if pid.isdigit()]
for pid in pids:
cmdline = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
if 'vmware-vmx' in cmdline and pat in cmdline:
return
self.__p = subprocess.Popen([self.vm])
def start_vm(self, sleep=75):

View File

@ -28,6 +28,7 @@ class Win32(VMInstaller):
INSTALLER_EXT = 'exe'
VM_NAME = 'xp_build'
VM = '/vmware/bin/%s'%VM_NAME
VM_CHECK = 'calibre_windows_xp_home'
FREEZE_COMMAND = 'win32_freeze'
FREEZE_TEMPLATE = 'python -OO setup.py {freeze_command} --no-ice'
INSTALLER_EXT = 'msi'