tom/dependencies.py
def checkfile(self, url, md5=False):
        """Checks if file on given URL exists and optionally returns its md5 sum
           Args:
               url - URL to check (starting with http or ftp, other protocols might not work)
               md5 - set it to True to force downloading file and returning md5 sum
                   (otherwise, for http[s] we use HEAD request)
           Returns:
               True, False, or md5 of a linked file
        """
        log.debug('checking URL: ' + url)
        try:
            if not md5 and url.startswith('http'):
                log.debug('testing with HEAD')
                r = requests.head(url)
                return r.status_code >= 200 and r.status_code < 300
            else:
                log.debug('getting whole file')
                m = hashlib.md5()
                with urllib.request.urlopen(url) as f:
                    data = f.read(4096)
                    while data:
                        m.update(data)
                        data = f.read(4096)
                return m.hexdigest()
        except:
            return False
Checks if file on given URL exists and optionally returns its md5 sum
           Args:
               url - URL to check (starting with http or ftp, other protocols might not work)
               md5 - set it to True to force downloading file and returning md5 sum
                   (otherwise, for http[s] we use HEAD request)
           Returns:
               True, False, or md5 of a linked file
        
Checks if file on given URL exists and optionally returns its md5 sum
Args:
url - URL to check (starting with http or ftp, other protocols might not work)
md5 - set it to True to force downloading file and returning md5 sum
(otherwise, for http[s] we use HEAD request)
Returns:
True, False, or md5 of a linked file
Checks if file on given URL exists and optionally returns its md5 sum Args : url - URL to check ( starting with http or ftp other protocols might not work ) md5 - set it to True to force downloading file and returning md5 sum ( otherwise for http [ s ] we use HEAD request ) Returns : True False or md5 of a linked file
def checkfile(self, url, md5=False):
        log.debug('checking URL: ' + url)
        try:
            if not md5 and url.startswith('http'):
                log.debug('testing with HEAD')
                r = requests.head(url)
                return r.status_code >= 200 and r.status_code < 300
            else:
                log.debug('getting whole file')
                m = hashlib.md5()
                with urllib.request.urlopen(url) as f:
                    data = f.read(4096)
                    while data:
                        m.update(data)
                        data = f.read(4096)
                return m.hexdigest()
        except:
            return False
def checkfile ( self , url , md5 = False ) : log . debug ( 'checking URL: ' + url ) try : if not md5 and url . startswith ( 'http' ) : log . debug ( 'testing with HEAD' ) r = requests . head ( url ) return r . status_code >= 200 and r . status_code < 300 else : log . debug ( 'getting whole file' ) m = hashlib . md5 ( ) with urllib . request . urlopen ( url ) as f : data = f . read ( 4096 ) while data : m . update ( data ) data = f . read ( 4096 ) return m . hexdigest ( ) except : return False
Checks if file on given URL exists and optionally returns its md5 sum
Args:
url - URL to check (starting with http or ftp, other protocols might not work)
md5 - set it to True to force downloading file and returning md5 sum
(otherwise, for http[s] we use HEAD request)
Returns:
True, False, or md5 of a linked file
Checks if file on given URL exists and optionally returns its md5 sum Args : url - URL to check ( starting with http or ftp other protocols might not work ) md5 - set it to True to force downloading file and returning md5 sum ( otherwise for http [ s ] we use HEAD request ) Returns : True False or md5 of a linked file
"""Checks if file on given URL exists and optionally returns its md5 sum
           Args:
               url - URL to check (starting with http or ftp, other protocols might not work)
               md5 - set it to True to force downloading file and returning md5 sum
                   (otherwise, for http[s] we use HEAD request)
           Returns:
               True, False, or md5 of a linked file
        """
self
url
md5