def __init__(self, path, tags=[], mimetype=None): self.path = path self.data = {} self.sources = [] self.tags = tags self.hashes = self.get_hashes() self.timestamp = to_iso8601() self.mimetype = mimetype self.status = SAMPLE_STATUS_NEW self.xrefs = {"parent": [], "child": []} # Size boundary check sample_size = os.stat(path).st_size if sample_size > SAMPLE_MAX_FILESIZE: os.unlink(path) raise ValueError( "Sample %s (%s) is bigger than maximum file size allowed: %s" % (path, humansize(sample_size), humansize(SAMPLE_MAX_FILESIZE)) ) if sample_size < SAMPLE_MIN_FILESIZE and self.mimetype != "text/url": os.unlink(path) raise ValueError( "Sample %s (%s) is smaller than minimum file size allowed: %s" % (path, humansize(sample_size), humansize(SAMPLE_MIN_FILESIZE)) ) if not self.check_exists(): self.store_sample() self.prepare_sample() self.store_data()
def add_source(self, provider, filename, reference=None): sources = self.sources sources.append({ 'timestamp': to_iso8601(), 'provider': provider, 'filename': filename, 'reference': reference }) self.sources = sources
def __init__(self, path, mimetype=None): self.path = path self.data = {} self.sources = [] self.tags = [] self.hashes = self.get_hashes() self.timestamp = to_iso8601() self.mimetype = mimetype self.status = SAMPLE_STATUS_NEW self.xrefs = { 'parent': [], 'child': [], } # Size boundary check sample_size = os.stat(path).st_size if sample_size > SAMPLE_MAX_FILESIZE: os.unlink(path) raise ValueError( 'Sample %s (%s) is bigger than maximum file size allowed: %s' % (path, humansize(sample_size), humansize(SAMPLE_MAX_FILESIZE))) if sample_size < SAMPLE_MIN_FILESIZE and self.mimetype != "text/url": os.unlink(path) raise ValueError( 'Sample %s (%s) is smaller than minimum file size allowed: %s' % (path, humansize(sample_size), humansize(SAMPLE_MIN_FILESIZE))) if not self.check_exists(): self.store_sample() self.prepare_sample() self.store_data()
def add_source(self, provider, filename, reference=None): sources = self.sources sources.append({"timestamp": to_iso8601(), "provider": provider, "filename": filename, "reference": reference}) self.sources = sources
def add_source(self, provider, filename, reference=None): sources = self.sources sources.append( {'timestamp': to_iso8601(), 'provider': provider, 'filename': filename, 'reference': reference} ) self.sources = sources
def add_source(self, provider, filename, reference=None): """Add where you get this sample as a source""" sources = self.sources sources.append( {'timestamp': to_iso8601(), 'provider': provider, 'filename': filename, 'reference': reference} ) self.sources = sources