示例#1
0
 def _register(self, stu_id):
     '''
     For a member to register for starting the chat.
     '''
     if stu_id.upper() not in self._students:
         self.sender.sendMessage('請輸入學生代表學號')
     elif not self._reg_code == '' and not self._is_verified:
         self.sender.sendMessage('驗證碼已寄發,請到 NTU Mail 查看')
     else:
         self._stu_id = stu_id.upper()
         self._is_chairperson = True if stu_id.upper(
         ) == CHAIRPERSON_ID.upper() else False
         self._reg_code = ''.join(
             random.choice('0123456789') for i in range(5))
         send_mail(stu_id=stu_id, reg_code=self._reg_code)
         print('<{stu_id}> <{chat_id}> register {reg_code}'.format(
             stu_id=self._stu_id, reg_code=self._reg_code, chat_id=self.id))
         self.sender.sendMessage('驗證碼已寄發')
示例#2
0
        restart_flag = 1
        while restart_flag == 1:
            # 프로시져 실행 후 os 재실행 상태 확인
            logging.info('[%s] uptime check iteration %s' % (svr, tmp_var))
            is_uptime = server.get_uptime(svr)
            
            if is_uptime <= 10800: # os가 재 실행 됬으므로 uptime이 작음
                restart_flag = 0
                logging.info('[%s] server restart is done, You should run install script' % svr)
                # os 설정이 완료 되었으므로 mail alert
                sender = common.common.getconf(ini_file, 'info', 'mail_sender')
                recv = common.common.getconf(ini_file, 'info', 'mail_reciever')
                mail_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'mail', 'mail-'+svr)
                server.make_mail_file(mail_file, svr, 'server restart is done', 
										'Now binary sync & svc start')
                server.send_mail('[INFO] ' +svr+' restart done', sender, recv, mail_file )
                time.sleep(15)
            else:
                logging.info('[%s] server restart is now processing, after 1min re check!! - uptime %s' 
                            % (svr, is_uptime)) 
                tmp_var = tmp_var +1
                time.sleep(60)

        # os설정 이후 필요한 필수 패키지 및 서비스 공통 설정 스크립트 실행
        os_set_flag = 1
        while os_set_flag == 1:
            is_restart_done = server.is_open_port(svr, 22)
            
            if is_restart_done == True:
                server.rcp_lib(svr, os_set_acc, passwd, remote_lib)
                time.sleep(30)
示例#3
0
文件: start.py 项目: juner417/xylitol
			error_file = os.path.join(error_dir, 
										hostname+'-server.err')
		
			# 1. svr status 체크 port(22)
			svr_status = server.is_open_port(svr, svr_port)

			if svr_status == True: 
				logging.info('[SERVER] %s server is alive' % svr)
			else:
				msg = '''[SERVER][%s] %s server is down''' % (svr, svr)
				server.make_err_file(error_file, svr, 'down', msg)
		except Exception as e:
			logging.exception("Exception in user code:")
			continue

	# check the err file
	# 에러파일 디렉토리 확인
	errfile_list = glob.glob(error_dir+'/*')
	if len(errfile_list) >= 1:
		for err in errfile_list:
			err_flag = server.tail_trace_log(err)
			if err_flag == True:
				logging.info('%s file is modifying and send a email' % err)
				mail_title = '[Alert] %s server error file exists' % hostname
				server.send_mail(mail_title, mail_sender, mail_reciver, err)
				server.rsync_err_file(error_dir, sync_dir)
			else:
				logging.info('%s file is not modified during last 3 min' % err)	
		logging.info('error file sync' % errfile_list)		
		#server.rsync_err_file(error_dir, sync_dir)