summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/perforce.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-04 10:26:21 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-07 09:06:36 +0000
commitd08397ba4d1331993300eacbb2f78fcfef19c1cf (patch)
tree374d8aa46a69fbae08d2b3e8e7456a5c61005e4c /bitbake/lib/bb/fetch2/perforce.py
parentf6eefb3ca3bb2a5ea0ec1364bdb0bc41ae58c815 (diff)
downloadpoky-d08397ba4d1331993300eacbb2f78fcfef19c1cf.tar.gz
bitbake/fetch2: Rewrite and improve exception handling, reusing core functions for common operations where possible
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/perforce.py')
-rw-r--r--bitbake/lib/bb/fetch2/perforce.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/bitbake/lib/bb/fetch2/perforce.py b/bitbake/lib/bb/fetch2/perforce.py
index 5c128b3fde..e98440f59f 100644
--- a/bitbake/lib/bb/fetch2/perforce.py
+++ b/bitbake/lib/bb/fetch2/perforce.py
@@ -156,8 +156,7 @@ class Perforce(Fetch):
156 tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false") 156 tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false")
157 tmpfile = tmppipe.readline().strip() 157 tmpfile = tmppipe.readline().strip()
158 if not tmpfile: 158 if not tmpfile:
159 logger.error("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.") 159 raise FetchError("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.", loc)
160 raise FetchError(module)
161 160
162 if "label" in parm: 161 if "label" in parm:
163 depot = "%s@%s" % (depot, parm["label"]) 162 depot = "%s@%s" % (depot, parm["label"])
@@ -171,8 +170,7 @@ class Perforce(Fetch):
171 p4file = os.popen("%s%s files %s" % (p4cmd, p4opt, depot)) 170 p4file = os.popen("%s%s files %s" % (p4cmd, p4opt, depot))
172 171
173 if not p4file: 172 if not p4file:
174 logger.error("Fetch: unable to get the P4 files from %s", depot) 173 raise FetchError("Fetch: unable to get the P4 files from %s" % depot, loc)
175 raise FetchError(module)
176 174
177 count = 0 175 count = 0
178 176
@@ -189,15 +187,9 @@ class Perforce(Fetch):
189 count = count + 1 187 count = count + 1
190 188
191 if count == 0: 189 if count == 0:
192 logger.error("Fetch: No files gathered from the P4 fetch") 190 logger.error()
193 raise FetchError(module) 191 raise FetchError("Fetch: No files gathered from the P4 fetch", loc)
194 192
195 myret = os.system("tar -czf %s %s" % (ud.localpath, module)) 193 runfetchcmd("tar -czf %s %s" % (ud.localpath, module), d, cleanup = [ud.localpath])
196 if myret != 0:
197 try:
198 os.unlink(ud.localpath)
199 except OSError:
200 pass
201 raise FetchError(module)
202 # cleanup 194 # cleanup
203 bb.utils.prunedir(tmpfile) 195 bb.utils.prunedir(tmpfile)