Beispiel #1
0
def checkPath(path):
    d = len(path)
    for i in xrange(0, d - 1):
        resp = headRequestCached(path[i])
        if isGoodStatus(resp) and isPage(resp):
            content = getRequestCached(path[i])
            urls = getURLs(content, path[i])
            if path[i + 1] not in urls:
                return False
        else:
            return False
    return True
Beispiel #2
0
 def read(self, size, offset):
     if isPage(self.resp) or self.getSize() <= MAXFILESIZE:
         content = getRequestCached(self.url)
         slen = self.getSize()
         if offset < slen:
             if offset + size > slen:
                 size = slen - offset
             buf = content[offset:offset + size]
         else:
             raise RuntimeError("Invalid range")
     else:
         if isAcceptedPartialDownload(self.resp):
             buf = partialGetRequest(self.url, size, offset)
         else:
             raise RuntimeError("Not accepted partial download")
     return buf
Beispiel #3
0
 def release(self):
     if not isPage(self.resp):
         removeFromCache(self.url)
Beispiel #4
0
 def isFile(self):
     if not self.isGoodStatus:
         return False
     return not isPage(self.resp) or self.isPageFile
Beispiel #5
0
 def isDir(self):
     if not self.isGoodStatus:
         return False
     return isPage(self.resp) and not self.isPageFile