summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/wget.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2014-02-28 17:26:20 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-02 17:25:29 +0000
commit69b4614ff3cfe6f92e3271062aed06cc01151299 (patch)
treed09d5d3e323d8fcc1f68bf27668f1ca9ee6ec69c /bitbake/lib/bb/fetch2/wget.py
parent5f0e3a8800b1939fa9573ddef8a279140c91ec3c (diff)
downloadpoky-69b4614ff3cfe6f92e3271062aed06cc01151299.tar.gz
bitbake: fetch/wget: Separate out download and checkstatus functions
These two functions have little in common, separate them out. (Bitbake rev: 7413e0fa4dca9571ea98f32dab87d4fd60bc8de9) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/wget.py')
-rw-r--r--bitbake/lib/bb/fetch2/wget.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index bb686b52db..ffd608f213 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -60,41 +60,47 @@ class Wget(FetchMethod):
60 60
61 self.basecmd = d.getVar("FETCHCMD_wget", True) or "/usr/bin/env wget -t 2 -T 30 -nv --passive-ftp --no-check-certificate" 61 self.basecmd = d.getVar("FETCHCMD_wget", True) or "/usr/bin/env wget -t 2 -T 30 -nv --passive-ftp --no-check-certificate"
62 62
63 def download(self, ud, d, checkonly = False): 63 def _runwget(self, ud, d, command, quiet):
64
65 logger.debug(2, "Fetching %s using command '%s'" % (ud.url, command))
66 bb.fetch2.check_network_access(d, command)
67 runfetchcmd(command, d, quiet)
68
69 def download(self, ud, d):
64 """Fetch urls""" 70 """Fetch urls"""
65 71
66 fetchcmd = self.basecmd 72 fetchcmd = self.basecmd
67 73
68 if not checkonly and 'downloadfilename' in ud.parm: 74 if 'downloadfilename' in ud.parm:
69 dldir = d.getVar("DL_DIR", True) 75 dldir = d.getVar("DL_DIR", True)
70 bb.utils.mkdirhier(os.path.dirname(dldir + os.sep + ud.localfile)) 76 bb.utils.mkdirhier(os.path.dirname(dldir + os.sep + ud.localfile))
71 fetchcmd += " -O " + dldir + os.sep + ud.localfile 77 fetchcmd += " -O " + dldir + os.sep + ud.localfile
72 78
73 uri = ud.url.split(";")[0] 79 uri = ud.url.split(";")[0]
74 if checkonly: 80 if os.path.exists(ud.localpath):
75 fetchcmd = self.basecmd + " --spider '%s'" % uri
76 elif os.path.exists(ud.localpath):
77 # file exists, but we didnt complete it.. trying again.. 81 # file exists, but we didnt complete it.. trying again..
78 fetchcmd = self.basecmd + d.expand(" -c -P ${DL_DIR} '%s'" % uri) 82 fetchcmd = self.basecmd + d.expand(" -c -P ${DL_DIR} '%s'" % uri)
79 else: 83 else:
80 fetchcmd = self.basecmd + d.expand(" -P ${DL_DIR} '%s'" % uri) 84 fetchcmd = self.basecmd + d.expand(" -P ${DL_DIR} '%s'" % uri)
81 85
82 if not checkonly: 86 self._runwget(ud, d, fetchcmd, False)
83 logger.info("fetch " + uri)
84 logger.debug(2, "executing " + fetchcmd)
85 bb.fetch2.check_network_access(d, fetchcmd)
86 runfetchcmd(fetchcmd, d, quiet=checkonly)
87 87
88 # Sanity check since wget can pretend it succeed when it didn't 88 # Sanity check since wget can pretend it succeed when it didn't
89 # Also, this used to happen if sourceforge sent us to the mirror page 89 # Also, this used to happen if sourceforge sent us to the mirror page
90 if not os.path.exists(ud.localpath) and not checkonly: 90 if not os.path.exists(ud.localpath):
91 raise FetchError("The fetch command returned success for url %s but %s doesn't exist?!" % (uri, ud.localpath), uri) 91 raise FetchError("The fetch command returned success for url %s but %s doesn't exist?!" % (uri, ud.localpath), uri)
92 92
93 if not checkonly and os.path.getsize(ud.localpath) == 0: 93 if os.path.getsize(ud.localpath) == 0:
94 os.remove(ud.localpath) 94 os.remove(ud.localpath)
95 raise FetchError("The fetch of %s resulted in a zero size file?! Deleting and failing since this isn't right." % (uri), uri) 95 raise FetchError("The fetch of %s resulted in a zero size file?! Deleting and failing since this isn't right." % (uri), uri)
96 96
97 return True 97 return True
98 98
99 def checkstatus(self, ud, d): 99 def checkstatus(self, ud, d):
100 return self.download(ud, d, True) 100
101 uri = ud.url.split(";")[0]
102 fetchcmd = self.basecmd + " --spider '%s'" % uri
103
104 self._runwget(ud, d, fetchcmd, True)
105
106 return True