AIL-framework/bin/modules/Tags.py

52 lines
1.1 KiB
Python
Raw Normal View History

2018-05-16 14:39:01 +02:00
#!/usr/bin/env python3
# -*-coding:UTF-8 -*
"""
The Tags Module
================================
This module add tags to an item.
2018-05-16 14:39:01 +02:00
"""
2021-04-28 15:24:33 +02:00
##################################
# Import External packages
##################################
import os
import sys
2021-04-28 15:24:33 +02:00
sys.path.append(os.environ['AIL_BIN'])
2021-04-28 15:24:33 +02:00
##################################
# Import Project packages
##################################
from modules.abstract_module import AbstractModule
2018-05-16 14:39:01 +02:00
2021-04-28 15:24:33 +02:00
class Tags(AbstractModule):
"""
Tags module for AIL framework
"""
def __init__(self):
super(Tags, self).__init__()
2018-05-16 14:39:01 +02:00
# Waiting time in seconds between to message processed
2021-04-28 15:24:33 +02:00
self.pending_seconds = 10
2018-05-16 14:39:01 +02:00
2021-04-28 15:24:33 +02:00
# Send module state to logs
2023-05-12 15:29:53 +02:00
self.logger.info(f'Module {self.module_name} initialized')
2018-05-16 14:39:01 +02:00
2021-04-28 15:24:33 +02:00
def compute(self, message):
item = self.obj
tag = message
2018-05-16 14:39:01 +02:00
# Create a new tag
item.add_tag(tag)
2024-03-13 11:58:40 +01:00
print(f'{self.obj.get_global_id()}: Tagged {tag}')
2021-10-29 18:48:12 +02:00
# Forward message to channel
self.add_message_to_queue(message=tag, queue='Tag_feed')
2021-10-29 18:48:12 +02:00
2021-04-28 15:24:33 +02:00
if __name__ == '__main__':
module = Tags()
module.run()