mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
5dc59bacc6
commit
06baf7445a
@ -57,13 +57,14 @@ class Rsync(Command):
|
|||||||
self.info(cmd)
|
self.info(cmd)
|
||||||
subprocess.check_call(cmd, shell=True, env=env)
|
subprocess.check_call(cmd, shell=True, env=env)
|
||||||
|
|
||||||
def push(host, vmname):
|
def push(host, vmname, available):
|
||||||
if vmname is None:
|
if vmname is None:
|
||||||
hostname = host.partition(':')[0].partition('@')[-1]
|
hostname = host.partition(':')[0].partition('@')[-1]
|
||||||
ok = is_host_reachable(hostname)
|
ok = is_host_reachable(hostname)
|
||||||
else:
|
else:
|
||||||
ok = is_vm_running(vmname)
|
ok = is_vm_running(vmname)
|
||||||
if ok:
|
if ok:
|
||||||
|
available[vmname or host] = True
|
||||||
rcmd = BASE_RSYNC + EXCLUDES + ['.', host]
|
rcmd = BASE_RSYNC + EXCLUDES + ['.', host]
|
||||||
print '\n\nPushing to:', vmname or host, '\n'
|
print '\n\nPushing to:', vmname or host, '\n'
|
||||||
subprocess.check_call(rcmd, stdout=open(os.devnull, 'wb'))
|
subprocess.check_call(rcmd, stdout=open(os.devnull, 'wb'))
|
||||||
@ -74,7 +75,7 @@ class Push(Command):
|
|||||||
|
|
||||||
def run(self, opts):
|
def run(self, opts):
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
threads = {}
|
threads, available = {}, {}
|
||||||
for host, vmname in {
|
for host, vmname in {
|
||||||
r'Owner@winxp:/cygdrive/c/Documents\ and\ Settings/Owner/calibre':'winxp',
|
r'Owner@winxp:/cygdrive/c/Documents\ and\ Settings/Owner/calibre':'winxp',
|
||||||
'kovid@ox:calibre':None,
|
'kovid@ox:calibre':None,
|
||||||
@ -82,13 +83,14 @@ class Push(Command):
|
|||||||
'kovid@win7-x64:calibre-src':'win7-x64',
|
'kovid@win7-x64:calibre-src':'win7-x64',
|
||||||
'kovid@tiny:calibre':None,
|
'kovid@tiny:calibre':None,
|
||||||
}.iteritems():
|
}.iteritems():
|
||||||
threads[vmname or host] = thread = Thread(target=push, args=(host, vmname,))
|
threads[vmname or host] = thread = Thread(target=push, args=(host, vmname, available))
|
||||||
thread.start()
|
thread.start()
|
||||||
while threads:
|
while threads:
|
||||||
for name, thread in tuple(threads.iteritems()):
|
for name, thread in tuple(threads.iteritems()):
|
||||||
thread.join(0.01)
|
thread.join(0.01)
|
||||||
if not thread.is_alive():
|
if not thread.is_alive():
|
||||||
print '\n\n', name, 'done'
|
if available.get(name, False):
|
||||||
|
print '\n\n', name, 'done'
|
||||||
threads.pop(name)
|
threads.pop(name)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user