diff options
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/buildmanager.py | 43 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/puccho.py | 28 |
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 | |||
24 | import threading | 24 | import threading |
25 | import urllib2 | 25 | import urllib2 |
26 | import os | 26 | import os |
27 | import contextlib | ||
27 | 28 | ||
28 | from bb.ui.crumbs.buildmanager import BuildManager, BuildConfiguration | 29 | from bb.ui.crumbs.buildmanager import BuildManager, BuildConfiguration |
29 | from bb.ui.crumbs.buildmanager import BuildManagerTreeView | 30 | from 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 |