Skip to content

Commit

Permalink
Dont try to start VMs if already running
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Jun 3, 2012
1 parent e545b5e commit 5cc583c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions setup/installer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -117,6 +118,13 @@ def stop_vmware(self):


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):
Expand Down
1 change: 1 addition & 0 deletions setup/installer/windows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 5cc583c

Please sign in to comment.