def enviar_email_notificacao(self, cc: List[str] = None, nome: str = '', grupo: str = ''): if self.__status == False: return reports = get_info('reports', grupo) assunto = Config.get('email', grupo, 'assunto') to = [Config.get('email', grupo, 'email')] conteudo = Config.get('email', grupo, 'conteudo') # Cria o cabecalho da mensagem if cc is None: cc = [] msg = MIMEMultipart('related; charset=utf-8') msg['Subject'] = f'{assunto}' msg['From'] = self.__from msg['To'] = ','.join(to) msg['Cc'] = ','.join(cc) # Carrega o arquivo de template template = str(Path(assets.__path__[0]) / 'email_notificacao.html') msg.attach(self.__carregar_template(template, nome, conteudo)) for i in reports: msg.attach(self.__carregar_anexo(i)) os.remove(i) print('removeu') # Envia o email self.__enviar_email(to + cc, msg)
def get_info(raiz: str, grupo: str): items = [Config.get(raiz, grupo)] lista = [] for i in items: lista = (list(i.keys())) if lista: lista_url = [] for i in lista: lista_url.append(Config.get(raiz, grupo, i)) return lista_url # def get_info(raiz: str, items: List[str]): # if items: # lista_url = [] # for i in items: # lista_url.append(Config.get(raiz, i)) # # return lista_url
def __init__(self, ): self.__host = Config.get('mailer', 'server') self.__port = Config.get('mailer', 'port') self.__ttls = Config.get('mailer', 'ttls') == 'true' self.__status = Config.get('mailer', 'status') # self.__user = Config.get('mailer', 'login') self.__pass = Config.get('mailer', 'password') self.__from = Config.get('mailer', 'from')
def __init__(self): self.__user = Config.get('powerbi', 'user') self.__pass = Config.get('powerbi', 'password') self.__driver = webdriver.Chrome('C:/Git/rpc/pbi-bot/chromedriver.exe')