def id_by_sha1(self, file): sha1 = sha1_by_file(file) print 'SHA1: %s' % sha1 try: return Media.objects.filter(master_sha1=sha1)[0].pk except: return None
def id_by_sha1(self, file): sha1 = sha1_by_file(file) print 'SHA1: %s' % sha1 try: from alibrary.models import Media return Media.objects.filter(master_sha1=sha1)[0].pk except Exception, e: print "SHA1 EXCEPTION:" print e return None
def id_by_sha1(self, file): sha1 = sha1_by_file(file) log.debug(u'generated SHA1 %s for %s' % (sha1, file)) from alibrary.models import Media duplicates = Media.objects.filter(master_sha1=sha1) if duplicates.exists(): log.info(u'detected duplicate by SHA1 hash. pk is: %s' % duplicates[0].pk) return duplicates[0].pk else: log.debug(u'no duplicate by SHA1 hash.') return None
def generate_sha1(self): return sha1_by_file(self.master)