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
65
66
67
68
69
70
71
72
73
74
75
76
|
#!/usr/bin/python2.4
# Copyright 2005 Canonical Ltd. All rights reserved.
# Author: David Allouche <david@allouche.net>
"""Download a cscvs source tree from a remote repository of source trees.
usage: importd-get-source.py local_source remote_dir
local_source must be the absolute path where to unpack the retrieved source
tree.
remote_dir must be the URL of a directory containing a gzipped tarball
"$(basename local_source).tgz".
The remote tarball will be downloaded as $local_source.tgz, and untarred as
$local_source. Any of those names already in use will be deleted at the
beginning of the script.
The basename of local_source is used to avoid confusing between cvs source
trees (cvsworking) and svn source trees (svnworking).
XXX: As a transition feature, if the remote tarball is not present but the
local_source is present locally, that script will behave like
importd-put-source.py -- David Allouche 2006-08-02
"""
import _pythonpath
import sys
import logging
from optparse import OptionParser
from canonical.launchpad.scripts import logger_options, logger, log
from canonical.codehosting.codeimport.bzr_progress import (
setup_batch_progress)
from canonical.codehosting.codeimport.sourcetransport import (
ImportdSourceTransport)
def parse_args(args):
"""Parse command line options"""
parser = OptionParser()
# Add the verbose/quiet options.
logger_options(parser)
return parser.parse_args(args)
def main(argv):
options, args = parse_args(argv[1:])
local_source, remote_dir = args
# Get the global logger for this task.
logger(options, 'importd-get-source')
# We use bzrlib transport facility and we don't want debug messages from
# bzr at that point.
bzr_logger = logging.getLogger("bzr")
bzr_logger.setLevel(logging.INFO)
# We use the bzrlib progress reporting facility to notify importd of
# progress. We want produce line-by-line progress report.
setup_batch_progress()
# The actual work happens here.
ImportdSourceTransport(log, local_source, remote_dir).getImportdSource()
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))
|