def send_mails(self, title, dryrun=False): if not self.send_nag_mail: return env = Environment(loader=FileSystemLoader('templates')) common = env.get_template('common.html') login_info = utils.get_login_info() From = Nag.get_from() Default_Cc = self.get_cc() mails = self.prepare_mails() for m in mails: Cc = Default_Cc.copy() if m['manager']: Cc.add(m['manager']) body = common.render(message=m['body'], query_url=None) receivers = set(m['to']) | set(Cc) status = 'Success' try: mail.send( From, sorted(m['to']), title, body, Cc=sorted(Cc), html=True, login=login_info, dryrun=dryrun, ) except: # NOQA logger.exception('Tool {}'.format(self.name())) status = 'Failure' db.Email.add(self.name(), receivers, 'individual', status)
def send_mails(self, title, dryrun=False): if not self.send_nag_mail: return env = Environment(loader=FileSystemLoader("templates")) common = env.get_template("common.html") login_info = utils.get_login_info() From = Nag.get_from() Default_Cc = self.get_cc() mails = self.prepare_mails() for m in mails: Cc = Default_Cc.copy() if m["manager"]: Cc.add(m["manager"]) body = common.render(message=m["body"], query_url=None) receivers = set(m["to"]) | set(Cc) status = "Success" try: mail.send( From, sorted(m["to"]), title, body, Cc=sorted(Cc), html=True, login=login_info, dryrun=dryrun, ) except Exception: logger.exception("Tool {}".format(self.name())) status = "Failure" db.Email.add(self.name(), receivers, "individual", status)
def send_mails(self, title, dryrun=False): if not self.send_nag_mail: return env = Environment(loader=FileSystemLoader('templates')) common = env.get_template('common.html') login_info = utils.get_login_info() From = Nag.get_from() Default_Cc = Nag.get_cc() mails = self.prepare_mails() for m in mails: Cc = Default_Cc.copy() if m['manager']: Cc.add(m['manager']) body = common.render(message=m['body'], query_url=None) receivers = set(m['to']) | set(Cc) status = 'Success' try: mail.send( From, sorted(m['to']), title, body, Cc=sorted(Cc), html=True, login=login_info, dryrun=dryrun, ) except: # NOQA logger.exception('Tool {}'.format(self.name())) status = 'Failure' db.Email.add(self.name(), receivers, 'individual', status)
def gather(self): env = Environment(loader=FileSystemLoader("templates")) common = env.get_template("common.html") login_info = utils.get_login_info() From = Nag.get_from() Default_Cc = set(utils.get_config("auto_nag", "cc", [])) all_mails = {} for nagger in self.naggers: mails = nagger.prepare_mails() for m in mails: manager = m["manager"] if manager not in all_mails: all_mails[manager] = {"to": m["to"], "body": m["body"]} else: all_mails[manager]["to"] |= m["to"] all_mails[manager]["body"] += "\n" + m["body"] for manager, m in all_mails.items(): Cc = Default_Cc.copy() Cc.add(manager) body = common.render(message=m["body"], has_table=True) mail.send( From, list(sorted(m["to"])), self.title(), body, Cc=list(sorted(Cc)), html=True, login=login_info, dryrun=self.is_dryrun, ) time.sleep(1)
def gather(self, dryrun): env = Environment(loader=FileSystemLoader('templates')) common = env.get_template('common.html') login_info = utils.get_login_info() From = Nag.get_from() Default_Cc = Nag.get_cc() all_mails = {} for nagger in self.naggers: mails = nagger.prepare_mails() for m in mails: manager = m['manager'] if manager not in all_mails: all_mails[manager] = {'to': m['to'], 'body': m['body']} else: all_mails[manager]['to'] |= m['to'] all_mails[manager]['body'] += '\n' + m['body'] for manager, m in all_mails.items(): Cc = Default_Cc.copy() Cc.add(manager) body = common.render(message=m['body'], has_table=True) mail.send( From, list(sorted(m['to'])), self.title(), body, Cc=list(sorted(Cc)), html=True, login=login_info, dryrun=dryrun, ) time.sleep(1)
def send_mails(self, title, dryrun=False): if not self.send_nag_mail: return env = Environment(loader=FileSystemLoader('templates')) common = env.get_template('common.html') login_info = utils.get_login_info() From = Nag.get_from() Default_Cc = Nag.get_cc() mails = self.prepare_mails() for m in mails: Cc = Default_Cc.copy() if m['manager']: Cc.add(m['manager']) body = common.render(message=m['body'], query_url=None, has_table=True) mail.send( From, sorted(m['to']), title, body, Cc=sorted(Cc), html=True, login=login_info, dryrun=dryrun, )
def __init__(self): self.model_class = RegressorModel self.repo_dir = get_login_info()["repo_dir"] if not os.path.exists(self.repo_dir): cmd = hglib.util.cmdbuilder( "robustcheckout", "https://hg.mozilla.org/mozilla-central", self.repo_dir, purge=True, sharebase=self.repo_dir + "-shared", networkattempts=7, branch=b"tip", ) cmd.insert(0, hglib.HGPATH) proc = hglib.util.popen(cmd) out, err = proc.communicate() if proc.returncode: raise hglib.error.CommandError(cmd, proc.returncode, out, err) logger.info("mozilla-central cloned") # Remove pushlog DB to make sure it's regenerated. try: os.remove(os.path.join(self.repo_dir, ".hg", "pushlog2.db")) except FileNotFoundError: logger.info("pushlog database doesn't exist") logger.info("Pulling and updating mozilla-central") with hglib.open(self.repo_dir) as hg: hg.pull(update=True) logger.info("mozilla-central pulled and updated") db.download_version(repository.COMMITS_DB) if db.is_old_version(repository.COMMITS_DB) or not os.path.exists( repository.COMMITS_DB): db.download(repository.COMMITS_DB, force=True, support_files_too=True) super().__init__() self.model = self.model_class.load(self.retrieve_model())
def send_email(self, date="today"): """Send the email""" if date: date = lmdutils.get_date(date) d = lmdutils.get_date_ymd(date) if isinstance(self, Nag): self.nag_date = d if not self.must_run(d): return if not self.has_enough_data(): logger.info("The tool {} hasn't enough data to run".format( self.name())) return login_info = utils.get_login_info() title, body = self.get_email(date) if title: receivers = self.get_receivers() status = "Success" try: mail.send( login_info["ldap_username"], receivers, title, body, html=True, login=login_info, dryrun=self.dryrun, ) except Exception: logger.exception("Tool {}".format(self.name())) status = "Failure" db.Email.add(self.name(), receivers, "global", status) if isinstance(self, Nag): self.send_mails(title, dryrun=self.dryrun) else: name = self.name().upper() if date: logger.info("{}: No data for {}".format(name, date)) else: logger.info("{}: No data".format(name)) logger.info("Query: {}".format(self.query_url))
def send_email(self, date='today'): """Send the email""" if date: date = lmdutils.get_date(date) d = lmdutils.get_date_ymd(date) if isinstance(self, Nag): self.nag_date = d if not self.must_run(d): return if not self.has_enough_data(): logger.info('The tool {} hasn\'t enough data to run'.format( self.name())) return login_info = utils.get_login_info() title, body = self.get_email(date) if title: receivers = self.get_receivers() status = 'Success' try: mail.send( login_info['ldap_username'], receivers, title, body, html=True, login=login_info, dryrun=self.dryrun, ) except: # NOQA logger.exception('Tool {}'.format(self.name())) status = 'Failure' db.Email.add(self.name(), receivers, 'global', status) if isinstance(self, Nag): self.send_mails(title, dryrun=self.dryrun) else: name = self.name().upper() if date: logger.info('{}: No data for {}'.format(name, date)) else: logger.info('{}: No data'.format(name)) logger.info('Query: {}'.format(self.query_url))
def send_email(self, date='today'): """Send the email""" if date: date = lmdutils.get_date(date) d = lmdutils.get_date_ymd(date) if isinstance(self, Nag): self.nag_date = d if not self.must_run(d): return if not self.has_enough_data(): logger.info('The tool {} hasn\'t enough data to run'.format(self.name())) return login_info = utils.get_login_info() title, body = self.get_email(date) if title: receivers = self.get_receivers() status = 'Success' try: mail.send( login_info['ldap_username'], receivers, title, body, html=True, login=login_info, dryrun=self.dryrun, ) except: # NOQA logger.exception('Tool {}'.format(self.name())) status = 'Failure' db.Email.add(self.name(), receivers, 'global', status) if isinstance(self, Nag): self.send_mails(title, dryrun=self.dryrun) else: name = self.name().upper() if date: logger.info('{}: No data for {}'.format(name, date)) else: logger.info('{}: No data'.format(name)) logger.info('Query: {}'.format(self.query_url))
def send_email(self, date='today', dryrun=False): """Send the email""" if date: date = lmdutils.get_date(date) d = lmdutils.get_date_ymd(date) if isinstance(self, Nag): self.nag_date = d if not self.must_run(d): return if not self.has_enough_data(): logger.info('The tool {} hasn\'t enough data to run'.format( self.name())) return login_info = utils.get_login_info() title, body = self.get_email(login_info['bz_api_key'], date, dryrun) if title: mail.send( login_info['ldap_username'], utils.get_config(self.name(), 'receivers'), title, body, html=True, login=login_info, dryrun=dryrun, ) if isinstance(self, Nag): self.send_mails(title, dryrun=dryrun) else: name = self.name().upper() if date: logger.info('{}: No data for {}'.format(name, date)) else: logger.info('{}: No data'.format(name))
def __init__(self): super(NotLanded, self).__init__() self.nweeks = utils.get_config(self.name(), 'number_of_weeks', 2) self.nyears = utils.get_config(self.name(), 'number_of_years', 2) self.phab_token = utils.get_login_info()['phab_api_key'] self.extra_ni = {}
def __init__(self): super(NotLanded, self).__init__() self.nweeks = utils.get_config(self.name(), "number_of_weeks", 2) self.nyears = utils.get_config(self.name(), "number_of_years", 2) self.phab = PhabricatorAPI(utils.get_login_info()["phab_api_key"]) self.extra_ni = {}