Merge lp:~james-w/linaro-image-tools/debug into lp:linaro-image-tools/11.11

Proposed by James Westby
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: 161
Merged at revision: 198
Proposed branch: lp:~james-w/linaro-image-tools/debug
Merge into: lp:linaro-image-tools/11.11
Diff against target: 156 lines (+42/-0)
4 files modified
hwpack/__init__.py (+10/-0)
hwpack/builder.py (+8/-0)
hwpack/packages.py (+10/-0)
linaro-hwpack-create (+14/-0)
To merge this branch: bzr merge lp:~james-w/linaro-image-tools/debug
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle (community) Approve
Review via email: mp+40116@code.launchpad.net

Description of the change

Hi,

This adds some output as the tool is running, and also adds a --debug
option that we can add more info to.

Thanks,

James

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Seems basically fine. I'm a bit confused as to what is INFO and what is DEBUG. Would it make sense to have things that happen once per run at INFO and once per package at DEBUG? But I guess it's not that important.

Revision history for this message
James Westby (james-w) wrote :

On Fri, 05 Nov 2010 02:07:44 -0000, Michael Hudson-Doyle <email address hidden> wrote:
> Seems basically fine. I'm a bit confused as to what is INFO and what
> is DEBUG. Would it make sense to have things that happen once per run
> at INFO and once per package at DEBUG? But I guess it's not that
> important.

Yeah, I just made some simple ones INFO. I'll spend a few minutes
thinking about the desired output and add that as INFO, and leave the
rest as DEBUG.

Thanks,

James

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Meant to approve it the first time.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hwpack/__init__.py'
--- hwpack/__init__.py 2010-08-27 18:27:58 +0000
+++ hwpack/__init__.py 2010-11-04 16:16:05 +0000
@@ -0,0 +1,10 @@
1import logging
2
3
4class NullHandler(logging.Handler):
5 def emit(self, record):
6 pass
7
8
9h = NullHandler()
10logging.getLogger(__name__).addHandler(h)
011
=== modified file 'hwpack/builder.py'
--- hwpack/builder.py 2010-09-14 18:09:01 +0000
+++ hwpack/builder.py 2010-11-04 16:16:05 +0000
@@ -1,3 +1,4 @@
1import logging
1import errno2import errno
23
3from hwpack.config import Config4from hwpack.config import Config
@@ -5,6 +6,9 @@
5from hwpack.packages import PackageFetcher6from hwpack.packages import PackageFetcher
67
78
9logger = logging.getLogger(__name__)
10
11
8class ConfigFileMissing(Exception):12class ConfigFileMissing(Exception):
913
10 def __init__(self, filename):14 def __init__(self, filename):
@@ -28,11 +32,13 @@
2832
29 def build(self):33 def build(self):
30 for architecture in self.config.architectures:34 for architecture in self.config.architectures:
35 logger.info("Building for %s" % architecture)
31 metadata = Metadata.from_config(36 metadata = Metadata.from_config(
32 self.config, self.version, architecture)37 self.config, self.version, architecture)
33 hwpack = HardwarePack(metadata)38 hwpack = HardwarePack(metadata)
34 sources = self.config.sources39 sources = self.config.sources
35 hwpack.add_apt_sources(sources)40 hwpack.add_apt_sources(sources)
41 logger.info("Fetching packages")
36 fetcher = PackageFetcher(42 fetcher = PackageFetcher(
37 sources.values(), architecture=architecture)43 sources.values(), architecture=architecture)
38 with fetcher:44 with fetcher:
@@ -40,6 +46,8 @@
40 packages = fetcher.fetch_packages(46 packages = fetcher.fetch_packages(
41 self.config.packages,47 self.config.packages,
42 download_content=self.config.include_debs)48 download_content=self.config.include_debs)
49 logger.debug("Adding packages to hwpack")
43 hwpack.add_packages(packages)50 hwpack.add_packages(packages)
44 with open(hwpack.filename(), 'w') as f:51 with open(hwpack.filename(), 'w') as f:
45 hwpack.to_file(f)52 hwpack.to_file(f)
53 logger.info("Wrote %s" % hwpack.filename())
4654
=== modified file 'hwpack/packages.py'
--- hwpack/packages.py 2010-09-24 20:00:05 +0000
+++ hwpack/packages.py 2010-11-04 16:16:05 +0000
@@ -1,3 +1,4 @@
1import logging
1import os2import os
2import shutil3import shutil
3import tempfile4import tempfile
@@ -7,6 +8,9 @@
7import apt_pkg8import apt_pkg
89
910
11logger = logging.getLogger(__name__)
12
13
10def get_packages_file(packages, extra_text=None):14def get_packages_file(packages, extra_text=None):
11 """Get the Packages file contents indexing `packages`.15 """Get the Packages file contents indexing `packages`.
1216
@@ -280,6 +284,7 @@
280 of sources.284 of sources.
281 """285 """
282 self.cleanup()286 self.cleanup()
287 logger.debug("Writing apt configs")
283 self.tempdir = tempfile.mkdtemp(prefix="hwpack-apt-cache-")288 self.tempdir = tempfile.mkdtemp(prefix="hwpack-apt-cache-")
284 dirs = ["var/lib/dpkg",289 dirs = ["var/lib/dpkg",
285 "etc/apt/",290 "etc/apt/",
@@ -299,6 +304,7 @@
299 with open(apt_conf, 'w') as f:304 with open(apt_conf, 'w') as f:
300 f.write('Apt {\nArchitecture "%s";\n}\n' % self.architecture)305 f.write('Apt {\nArchitecture "%s";\n}\n' % self.architecture)
301 self.cache = Cache(rootdir=self.tempdir, memonly=True)306 self.cache = Cache(rootdir=self.tempdir, memonly=True)
307 logger.debug("Updating apt cache")
302 self.cache.update()308 self.cache.update()
303 self.cache.open()309 self.cache.open()
304 return self310 return self
@@ -393,6 +399,7 @@
393 :param packages: the list of package names to ignore.399 :param packages: the list of package names to ignore.
394 :type packages: an iterable of str400 :type packages: an iterable of str
395 """401 """
402 logger.debug("Ignoring %s" % packages)
396 for package in packages:403 for package in packages:
397 self.cache.cache[package].mark_install(auto_fix=False)404 self.cache.cache[package].mark_install(auto_fix=False)
398 if self.cache.cache.broken_count:405 if self.cache.cache.broken_count:
@@ -411,6 +418,7 @@
411 candidate = package.installed418 candidate = package.installed
412 base = os.path.basename(candidate.filename)419 base = os.path.basename(candidate.filename)
413 installed.append(FetchedPackage.from_apt(candidate, base))420 installed.append(FetchedPackage.from_apt(candidate, base))
421 logger.debug("Ignored %s" % package.name)
414 self.cache.set_installed_packages(installed)422 self.cache.set_installed_packages(installed)
415 broken = [p.name for p in self.cache.cache423 broken = [p.name for p in self.cache.cache
416 if p.is_inst_broken or p.is_now_broken]424 if p.is_inst_broken or p.is_now_broken]
@@ -428,6 +436,7 @@
428 seen_packages.add(package.name)436 seen_packages.add(package.name)
429 all_packages = set(package_dict.keys())437 all_packages = set(package_dict.keys())
430 for unseen_package in all_packages.difference(seen_packages):438 for unseen_package in all_packages.difference(seen_packages):
439 logger.debug("%s is ignored, skipping" % unseen_package)
431 del package_dict[unseen_package]440 del package_dict[unseen_package]
432441
433 def fetch_packages(self, packages, download_content=True):442 def fetch_packages(self, packages, download_content=True):
@@ -474,6 +483,7 @@
474 acq = apt_pkg.Acquire(DummyProgress())483 acq = apt_pkg.Acquire(DummyProgress())
475 acqfiles = []484 acqfiles = []
476 for package in self.cache.cache.get_changes():485 for package in self.cache.cache.get_changes():
486 logger.debug("Fetching %s" % package)
477 candidate = package.candidate487 candidate = package.candidate
478 base = os.path.basename(candidate.filename)488 base = os.path.basename(candidate.filename)
479 if package.name not in fetched:489 if package.name not in fetched:
480490
=== modified file 'linaro-hwpack-create'
--- linaro-hwpack-create 2010-09-13 19:15:28 +0000
+++ linaro-hwpack-create 2010-11-04 16:16:05 +0000
@@ -1,6 +1,7 @@
1#!/usr/bin/python1#!/usr/bin/python
22
3import argparse3import argparse
4import logging
4import sys5import sys
56
6from hwpack.builder import ConfigFileMissing, HardwarePackBuilder7from hwpack.builder import ConfigFileMissing, HardwarePackBuilder
@@ -14,7 +15,20 @@
14 "from.")15 "from.")
15 parser.add_argument(16 parser.add_argument(
16 "VERSION", help="The version of the hardware pack to create.")17 "VERSION", help="The version of the hardware pack to create.")
18 parser.add_argument("--debug", action="store_true")
17 args = parser.parse_args()19 args = parser.parse_args()
20 ch = logging.StreamHandler()
21 ch.setLevel(logging.INFO)
22 formatter = logging.Formatter("%(message)s")
23 ch.setFormatter(formatter)
24 logger = logging.getLogger("hwpack")
25 logger.setLevel(logging.INFO)
26 logger.addHandler(ch)
27 if args.debug:
28 ch.setLevel(logging.DEBUG)
29 formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
30 ch.setFormatter(formatter)
31 logger.setLevel(logging.DEBUG)
18 try:32 try:
19 builder = HardwarePackBuilder(args.CONFIG_FILE, args.VERSION)33 builder = HardwarePackBuilder(args.CONFIG_FILE, args.VERSION)
20 except ConfigFileMissing, e:34 except ConfigFileMissing, e:

Subscribers

People subscribed via source and target branches