6
6
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
7
7
__docformat__ = 'restructuredtext en'
9
import subprocess, tempfile, os, time
9
import subprocess, tempfile, os, time, socket
11
11
from setup import Command, installer_name
12
12
from setup.build_environment import HOST, PROJECT
51
58
subprocess.check_call(cmd, shell=True, env=env)
60
def push(host, vmname, available):
62
hostname = host.partition(':')[0].partition('@')[-1]
63
ok = is_host_reachable(hostname)
65
ok = is_vm_running(vmname)
67
available[vmname or host] = True
68
rcmd = BASE_RSYNC + EXCLUDES + ['.', host]
69
print '\n\nPushing to:', vmname or host, '\n'
70
subprocess.check_call(rcmd, stdout=open(os.devnull, 'wb'))
54
72
class Push(Command):
58
76
def run(self, opts):
59
77
from threading import Thread
78
threads, available = {}, {}
61
79
for host, vmname in {
62
80
r'Owner@winxp:/cygdrive/c/Documents\ and\ Settings/Owner/calibre':'winxp',
63
81
'kovid@ox:calibre':None,
64
82
r'kovid@win7:/cygdrive/c/Users/kovid/calibre':'Windows 7',
65
83
'kovid@win7-x64:calibre-src':'win7-x64',
84
'kovid@tiny:calibre':None,
67
if vmname is None or is_vm_running(vmname):
68
rcmd = BASE_RSYNC + EXCLUDES + ['.', host]
69
print '\n\nPushing to:', vmname or host, '\n'
70
threads[vmname or host] = thread = Thread(target=subprocess.check_call, args=(rcmd,),
71
kwargs={'stdout':open(os.devnull, 'wb')})
86
threads[vmname or host] = thread = Thread(target=push, args=(host, vmname, available))
74
89
for name, thread in tuple(threads.iteritems()):
76
91
if not thread.is_alive():
77
print '\n\n', name, 'done'
92
if available.get(name, False):
93
print '\n\n', name, 'done'