2 import sys, os, struct, getopt, subprocess, signal
3 from bup import options, ssh, path
4 from bup.helpers import *
7 bup on <hostname> index ...
8 bup on <hostname> save ...
9 bup on <hostname> split ...
11 o = options.Options(optspec, optfunc=getopt.getopt)
12 (opt, flags, extra) = o.parse(sys.argv[1:])
14 o.fatal('arguments expected')
16 class SigException(Exception):
17 def __init__(self, signum):
19 Exception.__init__(self, 'signal %d received' % signum)
20 def handler(signum, frame):
21 raise SigException(signum)
23 signal.signal(signal.SIGTERM, handler)
24 signal.signal(signal.SIGINT, handler)
31 hp = extra[0].split(':')
33 (hostname, port) = (hp[0], None)
38 p = ssh.connect(hostname, port, 'on--server')
40 argvs = '\0'.join(['bup'] + argv)
41 p.stdin.write(struct.pack('!I', len(argvs)) + argvs)
44 sp = subprocess.Popen([path.exe(), 'server'],
45 stdin=p.stdout, stdout=p.stdin)
51 # if we get a signal while waiting, we have to keep waiting, just
52 # in case our child doesn't die.
57 except SigException, e:
58 log('\nbup on: %s\n' % e)
59 os.kill(p.pid, e.signum)