From d08397ba4d1331993300eacbb2f78fcfef19c1cf Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 4 Feb 2011 10:26:21 +0000 Subject: bitbake/fetch2: Rewrite and improve exception handling, reusing core functions for common operations where possible Signed-off-by: Richard Purdie --- bitbake/lib/bb/fetch2/perforce.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'bitbake/lib/bb/fetch2/perforce.py') 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): tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false") tmpfile = tmppipe.readline().strip() if not tmpfile: - logger.error("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.") - raise FetchError(module) + raise FetchError("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.", loc) if "label" in parm: depot = "%s@%s" % (depot, parm["label"]) @@ -171,8 +170,7 @@ class Perforce(Fetch): p4file = os.popen("%s%s files %s" % (p4cmd, p4opt, depot)) if not p4file: - logger.error("Fetch: unable to get the P4 files from %s", depot) - raise FetchError(module) + raise FetchError("Fetch: unable to get the P4 files from %s" % depot, loc) count = 0 @@ -189,15 +187,9 @@ class Perforce(Fetch): count = count + 1 if count == 0: - logger.error("Fetch: No files gathered from the P4 fetch") - raise FetchError(module) - - myret = os.system("tar -czf %s %s" % (ud.localpath, module)) - if myret != 0: - try: - os.unlink(ud.localpath) - except OSError: - pass - raise FetchError(module) + logger.error() + raise FetchError("Fetch: No files gathered from the P4 fetch", loc) + + runfetchcmd("tar -czf %s %s" % (ud.localpath, module), d, cleanup = [ud.localpath]) # cleanup bb.utils.prunedir(tmpfile) -- cgit v1.2.3