summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-06-18 07:56:55 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-07-02 15:41:37 +0100
commit20dc452614c991d1a4f5b7dcc1307cd03cba0c55 (patch)
tree096376554cde186c8abea965a84b842dd3b8ff24
parentb9f8af16f4aca5df1849e0ee2904d58e120cb67d (diff)
downloadpoky-20dc452614c991d1a4f5b7dcc1307cd03cba0c55.tar.gz
Drop a couple usages of readlines
(Bitbake rev: 40925230781ddd550bf21d90714c5349f9240a51) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
-rw-r--r--bitbake/lib/bb/ui/crumbs/buildmanager.py43
-rw-r--r--bitbake/lib/bb/ui/puccho.py28
2 files changed, 35 insertions, 36 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/buildmanager.py b/bitbake/lib/bb/ui/crumbs/buildmanager.py
index b5a4dae0de..e858d75e4c 100644
--- a/bitbake/lib/bb/ui/crumbs/buildmanager.py
+++ b/bitbake/lib/bb/ui/crumbs/buildmanager.py
@@ -76,31 +76,30 @@ class BuildConfiguration:
76 # file format. 76 # file format.
77 @staticmethod 77 @staticmethod
78 def load_from_file (filename): 78 def load_from_file (filename):
79 f = open (filename, "r")
80 79
81 conf = BuildConfiguration() 80 conf = BuildConfiguration()
82 for line in f.readlines(): 81 with open(filename, "r") as f:
83 data = line.split (";")[1] 82 for line in f:
84 if (line.startswith ("metadata-url;")): 83 data = line.split (";")[1]
85 conf.metadata_url = data.strip() 84 if (line.startswith ("metadata-url;")):
86 continue 85 conf.metadata_url = data.strip()
87 if (line.startswith ("url;")): 86 continue
88 conf.urls += [data.strip()] 87 if (line.startswith ("url;")):
89 continue 88 conf.urls += [data.strip()]
90 if (line.startswith ("extra-url;")): 89 continue
91 conf.extra_urls += [data.strip()] 90 if (line.startswith ("extra-url;")):
92 continue 91 conf.extra_urls += [data.strip()]
93 if (line.startswith ("machine;")): 92 continue
94 conf.machine = data.strip() 93 if (line.startswith ("machine;")):
95 continue 94 conf.machine = data.strip()
96 if (line.startswith ("distribution;")): 95 continue
97 conf.distro = data.strip() 96 if (line.startswith ("distribution;")):
98 continue 97 conf.distro = data.strip()
99 if (line.startswith ("image;")): 98 continue
100 conf.image = data.strip() 99 if (line.startswith ("image;")):
101 continue 100 conf.image = data.strip()
101 continue
102 102
103 f.close ()
104 return conf 103 return conf
105 104
106 # Serialise to a file. This is part of the build process and we use this 105 # Serialise to a file. This is part of the build process and we use this
diff --git a/bitbake/lib/bb/ui/puccho.py b/bitbake/lib/bb/ui/puccho.py
index 2ac025303e..a627fc803f 100644
--- a/bitbake/lib/bb/ui/puccho.py
+++ b/bitbake/lib/bb/ui/puccho.py
@@ -24,6 +24,7 @@ import gtk.glade
24import threading 24import threading
25import urllib2 25import urllib2
26import os 26import os
27import contextlib
27 28
28from bb.ui.crumbs.buildmanager import BuildManager, BuildConfiguration 29from bb.ui.crumbs.buildmanager import BuildManager, BuildConfiguration
29from bb.ui.crumbs.buildmanager import BuildManagerTreeView 30from bb.ui.crumbs.buildmanager import BuildManagerTreeView
@@ -77,20 +78,19 @@ class MetaDataLoader(gobject.GObject):
77 def run (self): 78 def run (self):
78 result = {} 79 result = {}
79 try: 80 try:
80 f = urllib2.urlopen (self.url) 81 with contextlib.closing (urllib2.urlopen (self.url)) as f:
81 82 # Parse the metadata format. The format is....
82 # Parse the metadata format. The format is.... 83 # <machine>;<default distro>|<distro>...;<default image>|<image>...;<type##url>|...
83 # <machine>;<default distro>|<distro>...;<default image>|<image>...;<type##url>|... 84 for line in f:
84 for line in f.readlines(): 85 components = line.split(";")
85 components = line.split(";") 86 if (len (components) < 4):
86 if (len (components) < 4): 87 raise MetaDataLoader.LoaderThread.LoaderImportException
87 raise MetaDataLoader.LoaderThread.LoaderImportException 88 machine = components[0]
88 machine = components[0] 89 distros = components[1].split("|")
89 distros = components[1].split("|") 90 images = components[2].split("|")
90 images = components[2].split("|") 91 urls = components[3].split("|")
91 urls = components[3].split("|") 92
92 93 result[machine] = (distros, images, urls)
93 result[machine] = (distros, images, urls)
94 94
95 # Create an object representing this *potential* 95 # Create an object representing this *potential*
96 # configuration. It can become concrete if the machine, distro 96 # configuration. It can become concrete if the machine, distro