summaryrefslogtreecommitdiffstats
path: root/meta/classes/package.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-09 17:05:58 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-09 22:28:04 +0100
commit566628d8cd674a964d5824391cfd1585a1a22a87 (patch)
tree670366ee1492ff8bb18b9261dfab9d06c06b0a2d /meta/classes/package.bbclass
parentd2ef952851d9ef16875fdbbbc6ae6eb6cfc10cc0 (diff)
downloadpoky-566628d8cd674a964d5824391cfd1585a1a22a87.tar.gz
class/lib: Fix up various file access methods
There are various bits of cruft that have built up around our file accesses. This patch cleans some of them up, specifically: * Remove pointless "from __builtin__ import file" * Use open(), not file() * Wrap file usage in a with container to ensure files are closed * Add missing .close() calls in some cases (From OE-Core rev: a43e0a8ecd0441131e929daf998c3cd454d9c8f3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package.bbclass')
-rw-r--r--meta/classes/package.bbclass7
1 files changed, 4 insertions, 3 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 7d0684c95c..36b3ae5109 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1096,7 +1096,8 @@ python emit_pkgdata() {
1096 1096
1097 def get_directory_size(dir): 1097 def get_directory_size(dir):
1098 if os.listdir(dir): 1098 if os.listdir(dir):
1099 size = int(os.popen('du -sk %s' % dir).readlines()[0].split('\t')[0]) 1099 with os.popen('du -sk %s' % dir) as f:
1100 size = int(f.readlines()[0].split('\t')[0])
1100 else: 1101 else:
1101 size = 0 1102 size = 0
1102 return size 1103 return size
@@ -1203,7 +1204,7 @@ python emit_pkgdata() {
1203 g = glob('*') 1204 g = glob('*')
1204 if g or allow_empty == "1": 1205 if g or allow_empty == "1":
1205 packagedfile = pkgdatadir + '/runtime/%s.packaged' % pkg 1206 packagedfile = pkgdatadir + '/runtime/%s.packaged' % pkg
1206 file(packagedfile, 'w').close() 1207 open(packagedfile, 'w').close()
1207 1208
1208 if bb.data.inherits_class('kernel', d) or bb.data.inherits_class('module-base', d): 1209 if bb.data.inherits_class('kernel', d) or bb.data.inherits_class('module-base', d):
1209 write_extra_runtime_pkgs(variants, packages, pkgdatadir) 1210 write_extra_runtime_pkgs(variants, packages, pkgdatadir)
@@ -1633,7 +1634,7 @@ def read_libdep_files(d):
1633 for extension in ".shlibdeps", ".pcdeps", ".clilibdeps": 1634 for extension in ".shlibdeps", ".pcdeps", ".clilibdeps":
1634 depsfile = d.expand("${PKGDEST}/" + pkg + extension) 1635 depsfile = d.expand("${PKGDEST}/" + pkg + extension)
1635 if os.access(depsfile, os.R_OK): 1636 if os.access(depsfile, os.R_OK):
1636 fd = file(depsfile) 1637 fd = open(depsfile)
1637 lines = fd.readlines() 1638 lines = fd.readlines()
1638 fd.close() 1639 fd.close()
1639 for l in lines: 1640 for l in lines: