Merge lp:~jameinel/bzr-builddeb/import-scripts-updates2 into lp:~james-w/bzr-builddeb/import-scripts

Proposed by John A Meinel on 2010-02-17
Status: Merged
Merge reported by: James Westby
Merged at revision: not available
Proposed branch: lp:~jameinel/bzr-builddeb/import-scripts-updates2
Merge into: lp:~james-w/bzr-builddeb/import-scripts
Prerequisite: lp:~jameinel/bzr-builddeb/import-scripts-updates
Diff against target: 79 lines (+25/-5)
1 file modified
import_package.py (+25/-5)
To merge this branch: bzr merge lp:~jameinel/bzr-builddeb/import-scripts-updates2
Reviewer Review Type Date Requested Status
Bzr-builddeb-hackers 2010-02-17 Pending
Review via email: mp+19537@code.launchpad.net
To post a comment you must log in.
John A Meinel (jameinel) wrote :

This adds some small tweaking to the import_package.py script. Probably needs some direct comments about what we should keep, but it was useful for me when trying to get started and debug what was going on.

  312 John Arbash Meinel 2010-02-17
      Several small updates.
      1) handle when madison-lite is not installed more gracefully
      2) enable_default_logging() before loading plugins, in case something fails to load.
      3) allow passing -Dxxx flags for bzrlib to use for debugging (like -Dhttp, -Derror, and -Dhpss)

This is currently committed on top of import-scripts-updates, but I can pull them back apart, there isn't a code-level dependency.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'import_package.py'
2--- import_package.py 2010-02-12 21:51:28 +0000
3+++ import_package.py 2010-02-17 21:05:27 +0000
4@@ -1,6 +1,7 @@
5 #!/usr/bin/python
6
7 import datetime
8+import errno
9 import operator
10 import optparse
11 import os
12@@ -17,10 +18,15 @@
13
14 from launchpadlib.errors import HTTPError
15
16-from bzrlib import branch, bzrdir, errors, merge, tag, trace, transport, ui, urlutils
17+from bzrlib import branch, bzrdir, debug, errors, merge, tag, trace, transport, ui, urlutils
18 from bzrlib.plugin import load_plugins
19-from bzrlib.trace import mutter, log_exception_quietly
20+from bzrlib.trace import mutter, log_exception_quietly, enable_default_logging
21
22+# We may not want to do this, but if there is a failure while loading plugins,
23+# it is the only way to find out. One option would be to call
24+# 'trace.pop_log_file()' immediately after loading plugins.
25+enable_default_logging()
26+mutter('import_package started w/ args: %r' % (sys.argv,))
27 load_plugins()
28
29 from bzrlib.plugins.builddeb import import_dsc
30@@ -166,8 +172,15 @@
31 pocket)
32 vlist.add_if_needed(newp)
33 update_lists()
34- proc = subprocess.Popen(["/usr/bin/madison-lite", "--mirror", icommon.lists_dir,
35- package], stdout=subprocess.PIPE, preexec_fn=subprocess_setup)
36+ try:
37+ proc = subprocess.Popen(["/usr/bin/madison-lite", "--mirror", icommon.lists_dir,
38+ package], stdout=subprocess.PIPE, preexec_fn=subprocess_setup)
39+ except OSError, e:
40+ if e.errno in (errno.ENOENT,):
41+ sys.stderr.write('You must have "madison-lite" installed.\n'
42+ 'try: sudo apt-get install madison-lite.\n')
43+ sys.exit(1)
44+ raise
45 output, errout = proc.communicate()
46 assert proc.returncode == 0, "Error running madison-lite"
47 for line in output.splitlines():
48@@ -764,10 +777,11 @@
49 newdir = format.initialize_on_transport(to_transport)
50 repo = newdir.create_repository(shared=True)
51 repo.set_make_working_trees(True)
52+ mutter("finding all versions of %s" % (package,))
53 versions = get_versions(package, extra_debian=extra_debian)
54 assert len(versions.plist) > 0
55 versions.reverse()
56- mutter(str(versions))
57+ mutter("found %d versions: %s" % (len(versions.plist), versions))
58 possible_transports = []
59 versions = find_unimported_versions(temp_dir, versions, package,
60 revid_db, bstore, possible_transports=possible_transports)
61@@ -825,12 +839,18 @@
62 parser.add_option("--no-existing", dest="no_existing", action="store_true")
63 parser.add_option("--extra-debian", dest="extra_debian")
64 parser.add_option("--verbose", dest="verbose", action="store_true")
65+parser.add_option("-D", dest="debug_flags", action="append", default=[],
66+ help="Set debug flags, see 'bzr help debug-flags'")
67
68 options, args = parser.parse_args()
69
70 if options.verbose:
71 trace.set_verbosity_level(1)
72 trace.push_log_file(sys.stderr)
73+if sys.stderr.isatty():
74+ # Don't create a progress bar if we aren't actually in a terminal
75+ ui.ui_factory = ui.make_ui_for_terminal(sys.stdin, sys.stdout, sys.stderr)
76+debug.debug_flags.update(options.debug_flags)
77
78
79 if len(args) < 1:

Subscribers

People subscribed via source and target branches

to all changes: