2018-05-16 14:39:01 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
"""
|
|
|
|
The Tags Module
|
|
|
|
================================
|
|
|
|
|
2021-05-27 17:28:20 +02:00
|
|
|
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
|
|
|
|
##################################
|
2021-06-02 16:04:52 +02:00
|
|
|
import os
|
|
|
|
import sys
|
2021-04-28 15:24:33 +02:00
|
|
|
|
2021-06-02 16:04:52 +02:00
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
2021-04-28 15:24:33 +02:00
|
|
|
##################################
|
|
|
|
# Import Project packages
|
|
|
|
##################################
|
2021-06-02 16:04:52 +02:00
|
|
|
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
|
|
|
|
2022-10-25 16:25:19 +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):
|
2023-06-22 15:38:04 +02:00
|
|
|
item = self.obj
|
|
|
|
tag = message
|
2018-05-16 14:39:01 +02:00
|
|
|
|
2023-06-22 15:38:04 +02:00
|
|
|
# Create a new tag
|
|
|
|
item.add_tag(tag)
|
|
|
|
print(f'{item.get_id()}: Tagged {tag}')
|
2021-10-29 18:48:12 +02:00
|
|
|
|
2023-06-22 15:38:04 +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()
|