mirror of https://github.com/CIRCL/AIL-framework
fix: [retro hunt] fix object tag queue + decoded content
parent
6c21a8f8cf
commit
b64c70e0cd
|
@ -111,13 +111,25 @@ class Decoded(AbstractDaterangeObject):
|
||||||
def get_rel_path(self, mimetype=None):
|
def get_rel_path(self, mimetype=None):
|
||||||
if not mimetype:
|
if not mimetype:
|
||||||
mimetype = self.get_mimetype()
|
mimetype = self.get_mimetype()
|
||||||
|
if not mimetype:
|
||||||
|
self.logger.warning(f'Decoded {self.id}: Empty mimetype')
|
||||||
|
return None
|
||||||
return os.path.join(HASH_DIR, mimetype, self.id[0:2], self.id)
|
return os.path.join(HASH_DIR, mimetype, self.id[0:2], self.id)
|
||||||
|
|
||||||
def get_filepath(self, mimetype=None):
|
def get_filepath(self, mimetype=None):
|
||||||
return os.path.join(os.environ['AIL_HOME'], self.get_rel_path(mimetype=mimetype))
|
rel_path = self.get_rel_path(mimetype=mimetype)
|
||||||
|
if not rel_path:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return os.path.join(os.environ['AIL_HOME'], rel_path)
|
||||||
|
|
||||||
def get_content(self, mimetype=None, r_type='str'):
|
def get_content(self, mimetype=None, r_type='str'):
|
||||||
filepath = self.get_filepath(mimetype=mimetype)
|
filepath = self.get_filepath(mimetype=mimetype)
|
||||||
|
if not filepath:
|
||||||
|
if r_type == 'str':
|
||||||
|
return ''
|
||||||
|
else:
|
||||||
|
return b''
|
||||||
if r_type == 'str':
|
if r_type == 'str':
|
||||||
with open(filepath, 'r') as f:
|
with open(filepath, 'r') as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
|
@ -442,7 +454,7 @@ def get_all_decodeds_objects(filters={}):
|
||||||
if i >= len(files):
|
if i >= len(files):
|
||||||
files = []
|
files = []
|
||||||
for file in files:
|
for file in files:
|
||||||
yield Decoded(file).id
|
yield Decoded(file)
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
|
@ -128,10 +128,16 @@ class Retro_Hunt_Module(AbstractModule):
|
||||||
self.retro_hunt.add(self.obj.get_type(), self.obj.get_subtype(), obj_id)
|
self.retro_hunt.add(self.obj.get_type(), self.obj.get_subtype(), obj_id)
|
||||||
|
|
||||||
# TODO FILTER Tags
|
# TODO FILTER Tags
|
||||||
|
|
||||||
|
# TODO refactor Tags module for all object type
|
||||||
# Tags
|
# Tags
|
||||||
for tag in self.tags:
|
if self.obj.get_type() == 'item':
|
||||||
msg = f'{tag};{id}'
|
for tag in self.tags:
|
||||||
self.add_message_to_queue(msg, 'Tags')
|
msg = f'{tag};{obj_id}'
|
||||||
|
self.add_message_to_queue(msg, 'Tags')
|
||||||
|
else:
|
||||||
|
for tag in self.tags:
|
||||||
|
self.obj.add_tag(tag)
|
||||||
|
|
||||||
# # Mails
|
# # Mails
|
||||||
# EXPORTER MAILS
|
# EXPORTER MAILS
|
||||||
|
|
Loading…
Reference in New Issue