def populate_from(self, path, md5_path='md5sum'): self.type, self.format, self.quality = get_media_details(path) if not(self.type and self.format and self.quality): raise ValueError("Sorry, %s is not a supported file type." % path) self.md5 = get_checksum(path, md5_path=md5_path) st_info = os.stat(path) self.filesize = st_info.st_size
def format_status(item): full_path = os.path.join(req.app.upload_path, item['filename']) status = [] try: finfo = os.stat(full_path) if(finfo.st_size != item['filesize']): status.append("wrong filesize") if(req.postpath[-1] == 'check-md5'): filehash = media.get_checksum(full_path, md5_path=req.app.md5_path) if(filehash != item['md5']): status.append("incorrect hash") except OSError, e: status.append(e.strerror)