Faster push

This commit is contained in:
Kovid Goyal 2012-06-20 17:08:04 +05:30
parent dd51d1163a
commit 6919614d36

View File

@ -24,6 +24,15 @@ def get_rsync_pw():
return open('/home/kovid/work/kde/conf/buildbot').read().partition( return open('/home/kovid/work/kde/conf/buildbot').read().partition(
':')[-1].strip() ':')[-1].strip()
def is_vm_running(name):
pat = '/%s/'%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 True
return False
class Rsync(Command): class Rsync(Command):
description = 'Sync source tree from development machine' description = 'Sync source tree from development machine'
@ -46,15 +55,17 @@ class Push(Command):
def run(self, opts): def run(self, opts):
from threading import Thread from threading import Thread
threads = [] threads = []
for host in ( for host, vmname in {
r'Owner@winxp:/cygdrive/c/Documents\ and\ Settings/Owner/calibre', r'Owner@winxp:/cygdrive/c/Documents\ and\ Settings/Owner/calibre':'winxp',
'kovid@ox:calibre', 'kovid@ox:calibre':None,
r'kovid@win7:/cygdrive/c/Users/kovid/calibre', r'kovid@win7:/cygdrive/c/Users/kovid/calibre':'Windows 7',
): }.iteritems():
rcmd = BASE_RSYNC + EXCLUDES + ['.', host] if vmname is None or is_vm_running(vmname):
print '\n\nPushing to:', host, '\n' rcmd = BASE_RSYNC + EXCLUDES + ['.', host]
threads.append(Thread(target=subprocess.check_call, args=(rcmd,))) print '\n\nPushing to:', vmname or host, '\n'
threads[-1].start() threads.append(Thread(target=subprocess.check_call, args=(rcmd,),
kwargs={'stdout':open(os.devnull, 'wb')}))
threads[-1].start()
for thread in threads: for thread in threads:
thread.join() thread.join()
@ -118,13 +129,7 @@ class VMInstaller(Command):
def run_vm(self): def run_vm(self):
pat = '/%s/'%(self.VM_CHECK or self.VM_NAME) if is_vm_running(self.VM_CHECK or self.VM_NAME): return
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]) self.__p = subprocess.Popen([self.vm])
def start_vm(self, sleep=75): def start_vm(self, sleep=75):