]> arthur.barton.de Git - bup.git/blob - cmd/join-cmd.py
cleanup-mounts-under: Don't fail when /proc/mounts isn't readable
[bup.git] / cmd / join-cmd.py
1 #!/usr/bin/env python
2 import sys
3 from bup import git, options, client
4 from bup.helpers import *
5
6
7 optspec = """
8 bup join [-r host:path] [refs or hashes...]
9 --
10 r,remote=  remote repository path
11 o=         output filename
12 """
13 o = options.Options(optspec)
14 (opt, flags, extra) = o.parse(sys.argv[1:])
15
16 git.check_repo_or_die()
17
18 if not extra:
19     extra = linereader(sys.stdin)
20
21 ret = 0
22
23 if opt.remote:
24     cli = client.Client(opt.remote)
25     cat = cli.cat
26 else:
27     cp = git.CatPipe()
28     cat = cp.join
29
30 if opt.o:
31     outfile = open(opt.o, 'wb')
32 else:
33     outfile = sys.stdout
34
35 for id in extra:
36     try:
37         for blob in cat(id):
38             outfile.write(blob)
39     except KeyError, e:
40         outfile.flush()
41         log('error: %s\n' % e)
42         ret = 1
43
44 sys.exit(ret)