Skip to content
This repository was archived by the owner on Dec 16, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions dbuild/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def wait_container(docker_client, container):
return rv


def container_logs(docker_client, container):
def container_logs(docker_client, container, include_timestamps=True):
""" Get container stdout and stderr """
for log in docker_client.logs(container=container, stream=True,
timestamps=True):
timestamps=include_timestamps):
yield log.strip()


Expand Down Expand Up @@ -98,7 +98,7 @@ def docker_build(build_dir, build_type, source_dir='source', force_rm=False,
release='trusty', extra_repos_file='repos',
extra_repo_keys_file='keys', build_cache=True, proxy="",
build_owner=None, parallel=1, no_default_sources=False,
**kwargs):
include_timestamps=True, **kwargs):
"""
build_dir: build directory, this directory will be mounted to /build in
container
Expand All @@ -121,6 +121,7 @@ def docker_build(build_dir, build_type, source_dir='source', force_rm=False,
build_owner: user id which will own all build files
parallel: how many processes to run in parallel
no_default_sources: only use sources from extra_repos_file
include_timestamps: show timestamps
kwargs: dict of unknown arguments. Ignored. For forward compatibility.
"""

Expand Down Expand Up @@ -248,6 +249,9 @@ def main(argv=sys.argv[1:]):
ap.add_argument('--no-default-sources', action='store_true',
help='Discard existing sources, only use the ones '
'passed in')
ap.add_argument('--no-include-timestamps', dest='include_timestamps',
action='store_false',
help='Don\'t include timestamps in output')
args = ap.parse_args(argv)

try:
Expand All @@ -259,7 +263,8 @@ def main(argv=sys.argv[1:]):
extra_repo_keys_file=args.extra_repo_keys_file,
build_cache=args.build_cache, proxy=args.proxy,
build_owner=args.build_owner,
no_default_sources=args.no_default_sources)
no_default_sources=args.no_default_sources,
include_timestamps=args.include_timestamps)
except exceptions.DbuildSourceBuildFailedException:
print('ERROR | Source build failed for build directory: %s'
% args.build_dir)
Expand All @@ -275,7 +280,8 @@ def main(argv=sys.argv[1:]):
build_cache=args.build_cache, proxy=args.proxy,
build_owner=args.build_owner,
parallel=args.parallel,
no_default_sources=args.no_default_sources)
no_default_sources=args.no_default_sources,
include_timestamps=args.include_timestamps)
except exceptions.DbuildBinaryBuildFailedException:
print('ERROR | Binary build failed for build directory: %s'
% args.build_dir)
Expand Down
8 changes: 5 additions & 3 deletions dbuild/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,18 @@ def test_build_failed_binary_build(self):

@mock.patch('dbuild.docker_build')
def test_build_cli(self, docker_build):
dbuild.main(['/some/dir'])
dbuild.main(['--no-include-timestamps', '/some/dir'])
self.assertEquals(docker_build.call_args_list,
[mock.call(build_cache=True, build_dir='/some/dir', build_owner=None,
build_type='source', dist='ubuntu',
docker_url='unix://var/run/docker.sock', extra_repo_keys_file='keys',
extra_repos_file='repos', force_rm=False, proxy='', release='trusty',
source_dir='source', no_default_sources=False),
source_dir='source', no_default_sources=False,
include_timestamps=False),
mock.call(build_cache=True, build_dir='/some/dir', build_owner=None,
build_type='binary', dist='ubuntu',
docker_url='unix://var/run/docker.sock',
extra_repo_keys_file='keys', extra_repos_file='repos',
force_rm=False, proxy='', parallel=1, release='trusty',
source_dir='source', no_default_sources=False)])
source_dir='source', no_default_sources=False,
include_timestamps=False)])
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ deps =

commands =
python -m coverage erase
python -m coverage run --source=dbuild -m nose
python -m coverage run --source=dbuild -m nose -- {posargs}
- bash -c 'test -n "{env:TRAVIS:}" && codecov'

[testenv:py27-flake8]
Expand Down