Logo Search packages:      
Sourcecode: harvestman version File versions  Download package

def HarvestMan::datamgr::harvestManDataManager::write_file_from_cache (   self,
  url 
)

Write file from url cache. This
works only if the cache dictionary of this
url has a key named 'data' 

Definition at line 101 of file datamgr.py.

00101                                         :
        """ Write file from url cache. This
        works only if the cache dictionary of this
        url has a key named 'data' """

        # New feature in 1.4
        ret = False

        d = self._projectcache
        
        if d.has_key(intern(url)):
            # Value itself is a dictionary
            content = d[intern(url)]
            if content:
                fileloc = content[intern('location')]
                if not content.has_key(intern('data')):
                    return ret
                else:
                    url_data = content[intern('data')]
                    if url_data:
                        # Write file
                        extrainfo("Updating file from cache=>", fileloc)
                        try:
                            f=open(fileloc, 'wb')
                            f.write(url_data)
                            f.close()
                            ret = True
                        except IOError, e:
                            debug('IO Exception', e)
                                
        return ret


Generated by  Doxygen 1.6.0   Back to index