File: btmakemetafile.py

package info (click to toggle)
debtorrent 0.1.9
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,452 kB
  • ctags: 1,183
  • sloc: python: 13,526; sh: 274; makefile: 51
file content (64 lines) | stat: -rwxr-xr-x 1,725 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
#
# Written by Bram Cohen
# multitracker extensions by John Hoffman
# Modified by Cameron Dale
# see LICENSE.txt for license information
#
# $Id: btmakemetafile.py 335 2008-01-19 22:05:46Z camrdale-guest $

"""Creates a metainfo file from a Packages file.

Converts a Packages file into a metainfo file containing all the information
needed to download all the packages in the Packages file.

"""

from DebTorrent import PSYCO
if PSYCO.psyco:
    try:
        import psyco
        assert psyco.__version__ >= 0x010100f0
        psyco.full()
    except:
        pass

from sys import argv, version, exit, version_info
from os.path import split
assert version_info >= (2,3), 'Requires Python 2.3 or better'
from DebTorrent.BT1.makemetafile import make_meta_file, defaults, print_announcelist_details
from DebTorrent.parseargs import parseargs, formatDefinitions
import logging

logging.basicConfig()
logger = logging.getLogger()

def prog(amount):
    """Display the current status of the file scan.
    
    @type amount: C{int}
    @param amount: the number of packages that have been found so far in the
        file
    
    """
    
    print '%d packages found\r' % amount,

if len(argv) < 2:
    a,b = split(argv[0])
    print 'Usage: ' + b + ' <Packages file> [Packages file...] [params...]'
    print
    print formatDefinitions(defaults, 80)
    print_announcelist_details()
    print ('')
    exit(2)

try:
    config, args = parseargs(argv[1:], defaults, 1, None)
    for file in args:
        make_meta_file(file, config, progress = prog)
        print ''
except ValueError, e:
    logger.exception(str(e))
    print 'error: ' + str(e)
    print 'run with no args for parameter explanations'