def get(self, filename, destpath=None, source=AkaiSampler.MEMORY): log.debug("Transferring file %s to host from source %i" % (filename, source)) try: if fileutils.is_sample(filename): shutil.copy(self.sample_file, destpath) elif fileutils.is_program(filename): shutil.copy(self.program_file, destpath) except IOError: raise model.SamplerException("Failed to get ", filename)
def get_file_size(path): cache_path = _get_cache_path(path) if os.path.exists(cache_path): return os.lstat(cache_path).st_size if fileutils.is_sample(path): return MAX_FILE_SIZE_SAMPLE return MAX_FILE_SIZE_OTHER
def get_file_type(name): assert name is not None if fileutils.is_multi(name): return Multi, FileRef.MULTI if fileutils.is_program(name): return Program, FileRef.PROGRAM if fileutils.is_sample(name): return Sample, FileRef.SAMPLE if fileutils.is_song(name): return Song, FileRef.SONG msg = "No support for file type: %s", name LOG.exception(msg) raise NotImplementedError(msg)
def test_is_sample(self): for name in VALID_SAMPLES: self.assertTrue(fileutils.is_sample(name), msg='%s should be valid' % name)