def execute(cell, kernel, session): """Run a single cell, waiting for its output""" msg = session.msg('execute_request', content={ 'code': cell.source, 'user_expressions': [], 'silent': False, 'allow_stdin': False, }) msg['channel'] = 'shell' parent_id = msg['header']['msg_id'] ws = kernel['channels'] gen_log.debug("Executing:\n%s", cell.source) ws.write_message(json.dumps(msg, default=date_default)) output_done = False shell_done = False while not (output_done and shell_done): jmsg = yield ws.read_message() msg = json.loads(jmsg) if msg['channel'] == 'iopub': gen_log.debug("output:\n%s", json.dumps(msg['content'], indent=1)) if msg['msg_type'] == 'status' \ and msg['content']['execution_state'] == 'idle' \ and msg['parent_header']['msg_id'] == parent_id: output_done = True elif msg['channel'] == 'shell': gen_log.debug("reply:\n%s", json.dumps(msg['content'], indent=1)) shell_done = True else: gen_log.warn("Unrecognized channel: %s\n%s", msg['channel'], json.dumps(msg['content'], indent=1) )
def execute(cell, kernel, session): """Run a single cell, waiting for its output""" msg = session.msg('execute_request', content={ 'code': cell.source, 'user_expressions': [], 'silent': False, 'allow_stdin': False, }) msg['channel'] = 'shell' parent_id = msg['header']['msg_id'] ws = kernel['channels'] gen_log.debug("Executing:\n%s", cell.source) ws.write_message(json.dumps(msg, default=date_default)) output_done = False shell_done = False while not (output_done and shell_done): jmsg = yield ws.read_message() msg = json.loads(jmsg) if msg['channel'] == 'iopub': gen_log.debug("output:\n%s", json.dumps(msg['content'], indent=1)) if msg['msg_type'] == 'status' \ and msg['content']['execution_state'] == 'idle' \ and msg['parent_header']['msg_id'] == parent_id: output_done = True elif msg['channel'] == 'shell': gen_log.debug("reply:\n%s", json.dumps(msg['content'], indent=1)) shell_done = True else: gen_log.warn("Unrecognized channel: %s\n%s", msg['channel'], json.dumps(msg['content'], indent=1))
def commit(self): # TODO: need to catch errors whenever flush called (maybe turn off # autoflush?) try: self.session.commit() return True except Exception as e: gen_log.warn('error committing session: {}'.format(str(e))) self.session.rollback() return False
def shutdown(self, io_loop): for func in self.funcs[:]: try: func() except: LOG.exception('Failed to call %r', func) LOG.warn( 'Shutdown initiated, will force stop in %d seconds', self.max_wait ) self.stop_loop(io_loop, self.time_func() + self.max_wait)
def stop_loop(self, io_loop, deadline): now = self.time_func() if now < deadline and self.is_loop_busy(io_loop): io_loop.call_later(0.5, self.stop_loop, io_loop, deadline) return if now >= deadline: LOG.warn('Deadline passed, forcing stop ..') io_loop.stop() LOG.warn('Shutdown complete')
def handle_signal(self, sig, frame): io_loop = ioloop.IOLoop.current() if self.shutting_down: # repeated signal - just kill the loop LOG.warn('Caught signal %d again, terminating ..', sig) io_loop.stop() return self.shutting_down = True LOG.warn('Caught signal %d', sig) io_loop.add_callback_from_signal(self.shutdown, io_loop)
def filter_ev(self, ev): mail_allowed = False if self.is_dkim_signed_valid(ev): dkresult = self.get_spf_result(ev) if dkresult in readdress_configs.get_spf_allowed_results(): mail_allowed = True if ev['msg'].get('spam_report').get('score', 5) > 5.5: mail_allowed = False action = readdress_configs.ConfigSectionMap( 'APP')['DKIM_SPF_FAILURE_ACTION'] if action == 'REJECT': mail_allowed = False elif (action == 'WARN' or action == 'ALLOW') and mail_allowed == False: mail_allowed = True gen_log.warn("Mail with msgid {} failed filter check".format( ev['msg']['headers']['Message-Id'])) return mail_allowed
def _get_repo(self, hook, build): """Returns :class:`asyncat.repository.Repository` via :class:`BaseCIWebhook` and :class:`BaseCIBuild`. """ secret = hook.get_secret() gen_log.info("Got secret from hook %s", secret) try: config = self.application.find_repo_config( secret, build.get_name(), ) except KeyError: gen_log.warn("Could not find config with secret: %s.", secret) self.write("Secret mismatch.") raise web.HTTPError(403) return Repository( self.application.github_client, config["owner"], config["name"], )
def on_err(self, callback): """DEPRECATED, does nothing""" gen_log.warn("on_err does nothing, and will be removed")
def stop_on_err(self): """DEPRECATED, does nothing""" gen_log.warn("on_err does nothing, and will be removed")
return from initiate_verification import send_verification_mail send_verification_mail(suspended_user, True) self.set_status(200) self.write({'status': 200}) self.finish() return handler = 'APP' formatter = ( '\n' + handler + ':%(asctime)s-[%(filename)s:%(lineno)s]-%(levelname)s - %(message)s') logging.basicConfig(level=logging.DEBUG, format=formatter, stream=sys.stdout) gen_log.warn("Starting APP") #logging.basicConfig(stream=sys.stdout,level=logging.DEBUG) inbounddb = MotorClient().inbounddb #expire after 30days from now inbounddb.invitesRecipients.ensure_index("Expiry_date", expireAfterSeconds=0) rclient = StrictRedis() settings = { "static_path": "frontend/Freeze/", "template_path": "frontend/Freeze/html/", "inbounddb": inbounddb, "rclient": rclient, "coganlys_app_id": "679106064d7f4c5692bcf28",