improve login mattermost

  • Addd the code to log in charm
import request

class MattermostWebHook():

    """Class to send messages in mattermost"""
    def __init__(self):
        """Method that initializes the class."""
        #: str : webhook created in the mattermost API.
        self.hook = 'https://mattermost.web.cern.ch/hooks/94ho3zi6a78czxdrjbrre6hxty'
        #: str : header for the request.
        self.headers = {'Content-Type': 'application/json',}
        #: class request : self definition of request class.
        self.requests = requests

    def __del__(self):
        """Method that delete Class."""
        print("Deleting class {}".format(self.__class__.__name__))

    def SendMsg(self, msg):
        """Send message to mattermost over the webhook

        Args:
            msg (str): message to the chat

        """
        data = '{ "text" : "' + msg + ' "}'
        self.requests.post(url=self.hook, headers=self.headers, data=data)