summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/svk.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/svk.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/svk.py')
-rw-r--r--bitbake/lib/bb/fetch2/svk.py23
1 files changed, 6 insertions, 17 deletions
diff --git a/bitbake/lib/bb/fetch2/svk.py b/bitbake/lib/bb/fetch2/svk.py
index 95206f52fb..8220bf3dc2 100644
--- a/bitbake/lib/bb/fetch2/svk.py
+++ b/bitbake/lib/bb/fetch2/svk.py
@@ -45,7 +45,7 @@ class Svk(Fetch):
45 def urldata_init(self, ud, d): 45 def urldata_init(self, ud, d):
46 46
47 if not "module" in ud.parm: 47 if not "module" in ud.parm:
48 raise MissingParameterError("svk method needs a 'module' parameter") 48 raise MissingParameterError('module', ud.url)
49 else: 49 else:
50 ud.module = ud.parm["module"] 50 ud.module = ud.parm["module"]
51 51
@@ -75,29 +75,18 @@ class Svk(Fetch):
75 tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false") 75 tmppipe = os.popen(data.getVar('MKTEMPDIRCMD', localdata, 1) or "false")
76 tmpfile = tmppipe.readline().strip() 76 tmpfile = tmppipe.readline().strip()
77 if not tmpfile: 77 if not tmpfile:
78 logger.error("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.") 78 logger.error()
79 raise FetchError(ud.module) 79 raise FetchError("Fetch: unable to create temporary directory.. make sure 'mktemp' is in the PATH.", loc)
80 80
81 # check out sources there 81 # check out sources there
82 os.chdir(tmpfile) 82 os.chdir(tmpfile)
83 logger.info("Fetch " + loc) 83 logger.info("Fetch " + loc)
84 logger.debug(1, "Running %s", svkcmd) 84 logger.debug(1, "Running %s", svkcmd)
85 myret = os.system(svkcmd) 85 runfetchcmd(svkcmd, d, cleanup = [tmpfile])
86 if myret != 0:
87 try:
88 os.rmdir(tmpfile)
89 except OSError:
90 pass
91 raise FetchError(ud.module)
92 86
93 os.chdir(os.path.join(tmpfile, os.path.dirname(ud.module))) 87 os.chdir(os.path.join(tmpfile, os.path.dirname(ud.module)))
94 # tar them up to a defined filename 88 # tar them up to a defined filename
95 myret = os.system("tar -czf %s %s" % (ud.localpath, os.path.basename(ud.module))) 89 runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.basename(ud.module)), d, cleanup = [ud.localpath])
96 if myret != 0: 90
97 try:
98 os.unlink(ud.localpath)
99 except OSError:
100 pass
101 raise FetchError(ud.module)
102 # cleanup 91 # cleanup
103 bb.utils.prunedir(tmpfile) 92 bb.utils.prunedir(tmpfile)