def doCron(watch): if config.Config.cronenabled == "0": return if not os.path.exists(os.path.join(config.Config.scriptsdir, "broctl-config.sh")): util.output("error: broctl-config.sh not found (try 'broctl install')") return config.Config.config["cron"] = "1" # Flag to indicate that we're running from cron. if not util.lock(): return util.bufferOutput() if watch: # Check whether nodes are still running an restart if neccessary. for (node, isrunning) in control.isRunning(config.Config.nodes()): if not isrunning and node.hasCrashed(): control.start([node]) # Check for dead hosts. _checkHosts() # Generate statistics. _logStats(5) # Check available disk space. _checkDiskSpace() # Expire old log files. _expireLogs() # Update the HTTP stats directory. _updateHTTPStats() # Run external command if we have one. if config.Config.croncmd: (success, output) = execute.runLocalCmd(config.Config.croncmd) if not success: util.output("error running croncmd: %s" % config.Config.croncmd) # Mail potential output. output = util.getBufferedOutput() if output: util.sendMail("cron: " + output.split("\n")[0], output) util.unlock() config.Config.config["cron"] = "0" util.debug(1, "cron done")
def _makeCrashReports(nodes): cmds = [] for node in nodes: cmds += [(node, "run-cmd", [ os.path.join(config.Config.scriptsdir, "post-terminate"), node.cwd(), "crash" ])] for (node, success, output) in execute.runHelperParallel(cmds): if not success: util.output("cannot run post-terminate for %s" % node.tag) else: util.sendMail("Crash report from %s" % node.tag, "\n".join(output)) node.clearCrashed()
def send_initial_email(self, name, email): print "sending Initial email..." subject = "Betaworks Lunch Roulette TODAY!" header_file = "%s/%s" % (self.appsettings.email_template_path, self.email_header_filename) footer_file = "%s/%s" % (self.appsettings.email_template_path, self.email_footer_filename) form_file = "%s/%s" % (self.appsettings.email_template_path, self.email_form_filename) header_html = open(header_file, 'r').read() footer_html = open(footer_file, 'r').read() form_templ = open(form_file, 'r').read() #replace {{ name }} with name form_html = re.sub("\{\{\s*name\s*\}\}", name, form_templ) #replace {{ email }} with email form_html = re.sub("\{\{\s*email\s*\}\}", email, form_html) body = "%s%s%s" % (header_html, form_html, footer_html) result = None if self.appsettings.debug: print body else: result = util.sendMail("smtp.gmail.com", self.appsettings.email, self.appsettings.password, self.appsettings.smtp_port, [email], self.appsettings.email, subject, html=body) return result
def _makeCrashReports(nodes): for n in nodes: plugin.Registry.broProcessDied(n) cmds = [] for node in nodes: cmds += [(node, "run-cmd", [os.path.join(config.Config.scriptsdir, "post-terminate"), node.cwd(), "crash"])] for (node, success, output) in execute.runHelperParallel(cmds): if not success: util.output("cannot run post-terminate for %s" % node.name) else: util.sendMail("Crash report from %s" % node.name, "\n".join(output)) node.clearCrashed()
def sendOutsideMail(sender, recipient, msg): try: util.sendMail(sender, recipient, msg) except: data = { "status": False, "message": "Le courriel n'a pas pu être envoyé. Veuillez recommencer." } else: data = { "status": True, "message": f"Le courriel a été envoyé avec succès à {recipient}." } finally: sendMessageToClient(str(data))
def doCron(watch): if config.Config.cronenabled == "0": return config.Config.config[ "cron"] = "1" # Flag to indicate that we're running from cron. if not util.lock(): return util.bufferOutput() if watch: # Check whether nodes are still running an restart if neccessary. for (node, isrunning) in control.isRunning(config.Config.nodes()): if not isrunning and node.hasCrashed(): control.start([node]) # Check for dead hosts. _checkHosts() # Generate statistics. _logStats(5) # Check available disk space. _checkDiskSpace() # Expire old log files. _expireLogs() # Update the HTTP stats directory. _updateHTTPStats() # Run external command if we have one. if config.Config.croncmd: execute.runLocalCmd(config.Config.croncmd) # Mail potential output. output = util.getBufferedOutput() if output: util.sendMail("cron: " + output.split("\n")[0], output) util.unlock() config.Config.config["cron"] = "0" util.debug(1, "cron done")
def _makeCrashReports(nodes): for n in nodes: plugin.Registry.broProcessDied(n) msg = "If you want to help us debug this problem, then please forward\nthis mail to [email protected]\n" cmds = [] for node in nodes: cmds += [(node, "run-cmd", [os.path.join(config.Config.scriptsdir, "post-terminate"), node.cwd(), "crash"])] for (node, success, output) in execute.runHelperParallel(cmds): if not success: util.output("cannot run post-terminate for %s" % node.name) else: util.sendMail("Crash report from %s" % node.name, msg + "\n".join(output)) node.clearCrashed()
def doCron(): if config.Config.cronenabled == "0": return if not util.lock(): return util.bufferOutput() config.Config.config["cron"] = "1" # Flag to indicate that we're running from cron. # Check whether nodes are still running an restart if neccessary. for (node, isrunning) in control.isRunning(config.Config.nodes()): if not isrunning and node.hasCrashed(): control.start([node]) # Check for dead hosts. _checkHosts() # Generate statistics. _logStats(5) # Check available disk space. _checkDiskSpace() # Expire old log files. _expireLogs() # Update the HTTP stats directory. _updateHTTPStats() # Run external command if we have one. if config.Config.croncmd: execute.runLocalCmd(config.Config.croncmd) # Mail potential output. output = util.getBufferedOutput() if output: util.sendMail("cron: " + output.split("\n")[0], output) config.Config.config["cron"] = "0" util.unlock()
return file['alternateLink'] break def uploadPdf(path, drive, title): id = getFolderId(root_id, drive, title) for file_name in glob.glob(f'{path}/*.pdf'): exact_name = file_name.rsplit('/', 1)[1] data = {'title': exact_name, 'parents': [{'id': id}]} drive = auth() file = drive.CreateFile(data) file.SetContentFile(file_name) print(f'uploading {exact_name}') file.Upload() print('All done, starting send mail\n') if __name__ == '__main__': title = (datetime.today() - relativedelta(month=1)).strftime('%B %Y') root_id = '{root_id}' path = "{path}" drive = auth() createFolder(root_id, drive, title) uploadPdf(path, drive, title) link = getSelfLink(root_id, drive, title) util.sendMail(link) util.removeTemp(path)