def fetch_json(self): cache_file = CacheFile(self.working_dir) gulpfile = self.get_gulpfile_path(self.working_dir) data = None if cache_file.exists(): filesha1 = Hasher.sha1(gulpfile) data = cache_file.read() if gulpfile in data and data[gulpfile]["sha1"] == filesha1: return data[gulpfile]["tasks"] self.callcount += 1 if self.callcount == 1: return self.write_to_cache() if data is None: raise Exception("Could not write to cache gulpfile.") if gulpfile in data: raise Exception( "Sha1 from gulp cache ({0}) is not equal to calculated ({1}).\nTry erasing the cache and running Gulp again." .format(data[gulpfile]["sha1"], filesha1)) else: raise Exception( "Have you renamed a folder?.\nSometimes Sublime doesn't update the project path, try removing the folder from the project and adding it again." )
def delete_cache(self, file_index): if file_index > -1: self.working_dir = self.gulp_files[file_index] try: cache_file = CacheFile(self.working_dir) if cache_file.exists(): cache_file.remove() self.status_message('Cache removed successfully') except Exception as e: self.status_message("Could not remove cache: %s" % str(e))
def fetch_json(self): cache_file = CacheFile(self.working_dir) gulpfile = self.get_gulpfile_path(self.working_dir) data = None if cache_file.exists(): filesha1 = Hasher.sha1(gulpfile) data = cache_file.read() if gulpfile in data and data[gulpfile]["sha1"] == filesha1: return data[gulpfile]["tasks"] self.callcount += 1 if self.callcount == 1: return self.write_to_cache() if data is None: raise Exception("Could not write to cache gulpfile.") if gulpfile in data: raise Exception("Sha1 from gulp cache ({0}) is not equal to calculated ({1}).\nTry erasing the cache and running Gulp again.".format(data[gulpfile]["sha1"], filesha1)) else: raise Exception("Have you renamed a folder?.\nSometimes Sublime doesn't update the project path, try removing the folder from the project and adding it again.")