/usr/bin/btcompletedir.bittorrent is in bittorrent 3.4.2-12.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #!/usr/bin/python
# Written by Bram Cohen
# see LICENSE.txt for license information
from os.path import join, split
from threading import Event
from traceback import print_exc
from sys import argv
from BitTorrent.btmakemetafile import calcsize, make_meta_file, ignore
def dummy(x):
pass
def completedir(files, url, flag = Event(), vc = dummy, fc = dummy, piece_len_pow2 = None):
files.sort()
ext = '.torrent'
togen = []
for f in files:
if f[-len(ext):] != ext:
togen.append(f)
total = 0
for i in togen:
total += calcsize(i)
subtotal = [0]
def callback(x, subtotal = subtotal, total = total, vc = vc):
subtotal[0] += x
vc(float(subtotal[0]) / total)
for i in togen:
t = split(i)
if t[1] == '':
i = t[0]
fc(i)
try:
make_meta_file(i, url, flag = flag, progress = callback, progress_percent=0, piece_len_exp = piece_len_pow2)
except ValueError:
print_exc()
def dc(v):
print v
if __name__ == '__main__':
completedir(argv[2:], argv[1], fc = dc)
|