From: Zack Cerza Date: Mon, 20 Apr 2015 17:25:24 +0000 (-0600) Subject: Log stderr in get_latest_image_version_deb() X-Git-Tag: 1.1.0~966^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7c4521450b7ebc50097122528fc3ed342186d0b1;p=teuthology.git Log stderr in get_latest_image_version_deb() It was being suppressed needlessly. Also fix lots of linter issues. Signed-off-by: Zack Cerza --- diff --git a/teuthology/task/kernel.py b/teuthology/task/kernel.py index 9a7b1bbad9..8119299a7a 100644 --- a/teuthology/task/kernel.py +++ b/teuthology/task/kernel.py @@ -889,6 +889,7 @@ def get_latest_image_version_rpm(remote): log.debug("get_latest_image_version_rpm: %s", version) return version + def get_latest_image_version_deb(remote, ostype): """ Get kernel image version of the newest kernel deb package. @@ -897,41 +898,45 @@ def get_latest_image_version_deb(remote, ostype): Round-about way to get the newest kernel uname -r compliant version string from the virtual package which is the newest kenel for debian/ubuntu. """ - output, err_mess = StringIO(), StringIO() - newest='' - #Depend of virtual package has uname -r output in package name. Grab that. + output = StringIO() + newest = '' + # Depend of virtual package has uname -r output in package name. Grab that. if 'debian' in ostype: - remote.run(args=['sudo', 'apt-get', '-y', 'install', 'linux-image-amd64' ], stdout=output, stderr=err_mess ) - remote.run(args=['dpkg', '-s', 'linux-image-amd64' ], stdout=output, stderr=err_mess ) + remote.run(args=['sudo', 'apt-get', '-y', 'install', + 'linux-image-amd64'], stdout=output) + remote.run(args=['dpkg', '-s', 'linux-image-amd64'], stdout=output) for line in output.getvalue().split('\n'): if 'Depends:' in line: newest = line.split('linux-image-')[1] output.close() - err_mess.close() return newest - #Ubuntu is a depend in a depend. + # Ubuntu is a depend in a depend. if 'ubuntu' in ostype: try: - remote.run(args=['sudo', 'apt-get', '-y', 'install', 'linux-image-current-generic' ], stdout=output, stderr=err_mess ) - remote.run(args=['dpkg', '-s', 'linux-image-current-generic' ], stdout=output, stderr=err_mess ) + remote.run(args=['sudo', 'apt-get', '-y', 'install', + 'linux-image-current-generic'], stdout=output) + remote.run(args=['dpkg', '-s', 'linux-image-current-generic'], + stdout=output) for line in output.getvalue().split('\n'): if 'Depends:' in line: depends = line.split('Depends: ')[1] - remote.run(args=['dpkg', '-s', depends ], stdout=output, stderr=err_mess ) + remote.run(args=['dpkg', '-s', depends], stdout=output) except run.CommandFailedError: # Non precise ubuntu machines (like trusty) don't have # linux-image-current-generic so use linux-image-generic instead. - remote.run(args=['sudo', 'apt-get', '-y', 'install', 'linux-image-generic' ], stdout=output, stderr=err_mess ) - remote.run(args=['dpkg', '-s', 'linux-image-generic' ], stdout=output, stderr=err_mess ) + remote.run(args=['sudo', 'apt-get', '-y', 'install', + 'linux-image-generic'], stdout=output) + remote.run(args=['dpkg', '-s', 'linux-image-generic'], + stdout=output) for line in output.getvalue().split('\n'): if 'Depends:' in line: newest = line.split('linux-image-')[1] if ',' in newest: newest = newest.split(',')[0] output.close() - err_mess.close() return newest + def get_sha1_from_pkg_name(path): """ Get commit hash (min 7 max 40 chars) from (rpm or deb) package name.