def post(self): loggerService.info("Sending a message to MS Teams") message = api.payload send_teams_message(message['from'] + ': ' + message['message']) return { 'channel': 'DevOps', 'organization': 'Newtech', 'message': message['message'], 'from': message['from'] }
def teams_message(**context): conf = context["dag_run"].conf NETWORK_SERVICE = conf['NETWORK_SERVICE'] NETWORK_SUBMISSION = conf['NETWORK_SUBMISSION'] formio = Formio() data = formio.get_submission(NETWORK_SERVICE, NETWORK_SUBMISSION) task_id = data[0]['data']['task_id'] submission = data[0] backup_date = backup_date = datetime.now().strftime("%Y-%m-%d") msg = 'NETWORK_SERVICE: ' + str( NETWORK_SERVICE) + '\n NETWORK_SUBMISSION: ' + NETWORK_SUBMISSION f = open(DAG_WORKING_FOLDER + '/' + 'backup_' + str(task_id) + '_' + str(backup_date) + '.conf') data = f.read() # msg += '\n ' + str(data) try: send_teams_message(msg) except Exception as e: print('Error sending message: ' + str(e))
import sys sys.path.append('../') from services.MSTeamsService import send_teams_message from config.settings import config from services.loggerService import loggerService if __name__ == '__main__': try: msg = sys.argv[1] send_teams_message(msg) except Exception as e: loggerService.error('Missing parameter or error sending message: ' + str(e))