def email_message(): data = json.loads(request.data) email = data.get("email") subject = data.get("subject") body = data.get("body") if not email or not body: return_data = {"message": "An email and body are required."} return json.dumps(return_data), 500, {"Content-Type": "application/json"} data = {"ip": request.remote_addr, "time": format_date(now_utc(), "%H:%M:%S, %B %d, %Y")} send_contact_email(email, subject, body, data=data) return json.dumps(data), 200, {"Content-Type": "application/json"}
def create(model, **kwargs): m = model() if hasattr(m, 'uuid'): m.uuid = str(uuid4()) if hasattr(m, 'created_at'): m.created_at = now_utc() for k, v in kwargs.items(): if hasattr(m, k): setattr(m, k, v) return save(m, refresh=True)
def restart_deploy(self, hard_restart=False): self.deploying = Deploy.update(self.deploying.uuid, last_deployed=now_utc()) for host in self.service.get_hosts(): dp = DeployInstance(host.uuid, self.service.uuid) succeeded = dp.restart_deploy(self.deploying, hard_restart=hard_restart) self.deploy_succeeded = self.deploy_succeeded & succeeded if self.deploy_succeeded: current_deploy = self.service.get_current_deploy() if self.deploying == current_deploy: return Deploy.update(uuid=current_deploy.uuid, currently_running=False) Deploy.update(uuid=self.deploying.uuid, currently_running=True) self._text_admins()
def deploy(self): self.deploying = Deploy.update(self.deploying.uuid, last_deployed=now_utc(), started=True) for host in self.service.get_hosts(): dp = DeployInstance(host.uuid, self.service.uuid) succeeded = dp.deploy_instance(self.deploying) self.deploy_succeeded = self.deploy_succeeded & succeeded self.deploying = Deploy.update(self.deploying.uuid, currently_running=self.deploy_succeeded, on_machine=self.deploy_succeeded, succeeded=self.deploy_succeeded, finished=True) if self.current_deploy and self.deploying.uuid != self.current_deploy.uuid: self.current_deploy = Deploy.update(self.current_deploy.uuid, currently_running=not self.deploy_succeeded) if self.deploy_succeeded and self.service.has_database: self.run_script('run_migrations.py') self._text_admins()
def email_message(): data = json.loads(request.data) email = data.get('email') subject = data.get('subject') body = data.get('body') if not email or not body: return_data = {'message': 'An email and body are required.'} return json.dumps(return_data), 500, { 'Content-Type': 'application/json' } data = { 'ip': request.remote_addr, 'time': format_date(now_utc(), '%H:%M:%S, %B %d, %Y') } send_contact_email(email, subject, body, data=data) return json.dumps(data), 200, {'Content-Type': 'application/json'}