예제 #1
0
파일: account.py 프로젝트: cash2one/ZPB
 def post(self):
     ret = {'status': 1, 'message': ''}
     try:
         site_id = str2int(self.get_argument('site_id', ''))
         member_name = self.get_argument('member_name', '')
         login_name = self.get_argument('login_name', '')
         session = self.get_argument('sessionid', '')
         # 中文解码
         member_name = unquote(member_name.encode('gbk'))
         login_name = unquote(login_name.encode('gbk'))
         #
         if session:
             if site_id and login_name:
                 messages = decryptBindPasswd('zpb', session).split(':')
                 if len(messages) == 2:
                     companyid = messages[0]
                     if Bind.unBind(companyid, site_id, member_name,
                                    login_name):
                         ret['status'] = 0
                         ret['message'] = u'账号解绑成功!'
                         DBTask.newSchedule(companyid, site_id, False)
                     else:
                         ret['message'] = u'账号解绑失败,账号尚未绑定!'
                 else:
                     ret['message'] = u'非法的请求!'
             else:
                 ret['message'] = u'非法的请求,提交参数不全!'
         else:
             ret['message'] = u'非法的请求!'
     finally:
         logger.debug(ret)
         self.write(json.dumps(ret))
예제 #2
0
파일: account.py 프로젝트: cash2one/ZPB
 def get(self):
     ret = {'status': 1, 'message': ''}
     try:
         company_id = str2int(self.get_argument('company_id', ''))
         site_id = str2int(self.get_argument('site_id', ''))
         if not (company_id and site_id):
             raise InvalidParamError(u'提交参数错误!')
         try:
             handler = SiteConfig.GetTaskHandler(company_id, site_id, None)
             try:
                 # 开始登陆
                 handler.login()
                 # 反馈结果
                 if handler.status == HANDLE_STATUS.SUCCESS:
                     ret['status'] = 100
                     # 增加201轮询指令
                     DBTask.newSchedule(company_id, site_id)
                 else:
                     ret['message'] = handler.message
             except BaseException as e:
                 raise UnHandleRuntimeError(e)
                 logger.error(u'Web服务请求异常,原因:{}'.format(e))
         except BaseError as e:
             ret['message'] = e.message
     finally:
         logger.debug(ret)
         self.write(json.dumps(ret))
예제 #3
0
 def post(self):
     ret = {'status': 1, 'message': ''}
     try:
         user_code = self.get_argument('usercode', '')
         session = self.get_argument('sessionid', '')
         #
         if session:
             if user_code:
                 messages = decryptBindPasswd('zpb', session).split(':')
                 if len(messages) == 2:
                     companyid = messages[0]
                     if EmailConf.unBind(companyid, user_code):
                         ret['status'] = 0
                         ret['message'] = u'账号解绑成功!'
                     else:
                         ret['message'] = u'账号解绑失败,账号尚未绑定!'
                 else:
                     ret['message'] = u'非法的请求!'
             else:
                 ret['message'] = u'非法的请求,提交参数不全!'
         else:
             ret['message'] = u'非法的请求!'
     finally:
         logger.debug(ret)
         self.write(json.dumps(ret))
예제 #4
0
 def post(self):
     ret = {'status': 1, 'message': ''}
     try:
         email_host = self.get_argument('host', '')
         email_port = str2int(self.get_argument('port', '110'))
         user_code = self.get_argument('usercode', '')
         user_pswd = self.get_argument('password', '')
         ssl = self.get_argument('ssl', False)
         session = self.get_argument('sessionid', '')
         if email_port == 0:
             email_port = 110
         if session:
             if email_host and email_port and user_code and user_pswd:
                 messages = decryptBindPasswd('zpb', session).split(':')
                 if len(messages) == 2:
                     companyid = messages[0]
                     res = EmailConf.newAndSave(companyid, email_host,
                                                email_port, ssl, user_code,
                                                user_pswd)
                     # 反馈结果
                     if res:
                         ret['status'] = 0
                         ret['message'] = u'账号绑定成功!'
                     else:
                         ret['message'] = u'内部服务错误!'
                 else:
                     ret['message'] = u'非法的请求!'
             else:
                 ret['message'] = u'非法的请求,提交参数不全!'
         else:
             ret['message'] = u'非法的请求!'
     finally:
         logger.debug(ret)
         self.write(json.dumps(ret))
예제 #5
0
파일: app.py 프로젝트: cash2one/ZPB
 def _async_task(tasks):
     # 分发异步任务
     for task in tasks:
         taskname = task.get('name', False)
         if taskname:
             logger.debug(u'dispatcher task named <{}>'.format(taskname))
         args = task.get('args', ())
         kwargs = task.get('kwargs', {})
         kwargs['uid'] = task['id']
         dtc. async (task['func'], *args, **kwargs)
예제 #6
0
파일: account.py 프로젝트: cash2one/ZPB
 def post(self):
     ret = {'status': 1, 'message': ''}
     try:
         site_id = str2int(self.get_argument('site_id', ''))
         member_name = self.get_argument('member_name', '')
         login_name = self.get_argument('login_name', '')
         login_pswd = self.get_argument('login_pswd', '')
         # 中文解码
         member_name = unquote(member_name.encode('gbk'))
         login_name = unquote(login_name.encode('gbk'))
         #
         session = self.get_argument('sessionid', '')
         try:
             if not session:
                 raise InvalidParamError(u'非法的请求!')
             if not (site_id and login_name and login_pswd):
                 raise InvalidParamError(u'非法的请求!')
             messages = decryptBindPasswd('zpb', session).split(':')
             if len(messages) != 2:
                 raise InvalidParamError(u'非法的请求!')
             companyid = messages[0]
             handler = SiteConfig.GetTaskHandler(0, site_id, None)
             # 登录密码解密
             password = decryptBindPasswd(login_name, login_pswd)
             if not password:
                 raise InvalidParamError(u'登录账号或密码错误!')
             try:
                 # 开始登陆
                 (res,
                  message) = handler.innerlogin(member_name, login_name,
                                                password)
                 # 反馈结果
                 if res:
                     if Bind.newAndSave(companyid, site_id, member_name,
                                        login_name, login_pswd):
                         ret['status'] = 0
                         ret['message'] = u'账号绑定成功!'
                     else:
                         ret['status'] = 0
                         ret['message'] = u'账号已绑定!'
                     DBTask.newSchedule(companyid, site_id)
                 else:
                     ret['message'] = message
             except BaseException as e:
                 raise UnHandleRuntimeError(e)
                 logger.error(u'Web服务请求异常,原因:{}'.format(e))
         except BaseError as e:
             ret['message'] = e.message
     finally:
         logger.debug(ret)
         self.write(json.dumps(ret))
예제 #7
0
def DownResume(checkstatservice, **kwargs):
    data = kwargs.copy()
    taskid = data['taskid']
    companyid = data['companyid']
    siteid = data['siteid']
    username = data['username']
    resumeid = data['resumeid']
    postdate = data['postdate']
    # 强制刷新简历(用於付费简历下载)
    force = data.get('force', False)
    #
    sitename = SiteConfig.getSiteNameById(siteid)
    importkey = Conf.RESUME_IMPORT_HKEY % taskid
    try:
        try:
            # 简历更新度验证(投递日期)
            if not force:
                if not ResumeBase.isNew(companyid, siteid, resumeid, postdate):
                    # 未更新的简历将会被忽略
                    logger.debug(u'<{}>简历<{}, {}>重复下载!'.format(
                        sitename, username, resumeid))
                    ResumeRedisCli.hincrby(importkey, 'ignore')
                    return
            try:
                handler = SiteConfig.GetTaskHandler(companyid, siteid, taskid)
                logger.info(u'正在下载<{}>简历<{}, {}>'.format(
                    sitename, username, resumeid))
                handler.resume_down(data)
                if handler.status == HANDLE_STATUS.SUCCESS:
                    logger.info(handler.message)
                    dtc. async ('zpb.service.resumeservice.ParseResume',
                                checkstatservice, **data),
                elif handler.status == HANDLE_STATUS.AGAIN:
                    logger.info(u'<{}>简历<{}, {}>需要重新下载'.format(
                        sitename, username, resumeid))
                    data['retry'] = data.get('retry', 0) + 1
                    dtc. async ('zpb.service.resumeservice.DownResume',
                                checkstatservice, **data),
                else:
                    ResumeRedisCli.hincrby(importkey, 'failure')
                    logger.error(handler.message)
            except BaseError as e:
                pass
        except BaseException as e:
            dtc. async ('zpb.service.resumeservice.DownResume',
                        checkstatservice, **data),
            logger.error(u'<{}>简历<{}, {}>下载异常,原因:{}'.format(
                sitename, username, resumeid, e))
    finally:
        dtc. async (checkstatservice, taskid)
예제 #8
0
 def post(self):
     ret = {'status': 1, 'message': ''}
     try:
         session = self.get_argument('sessionid', '')
         if session:
             messages = decryptBindPasswd('zpb', session).split(':')
             if len(messages) == 2:
                 companyid = messages[0]
                 logger.debug(u'企业编码<{}>请求已下载简历'.format(companyid))
                 data = ResumeBase.queryAndExport(companyid, pagesize=5)
                 ret['status'] = 0
                 ret['count'] = len(data)
                 ret['message'] = u'简历下载成功!'
                 ret['res_resume_base'] = data
             else:
                 ret['message'] = u'非法的请求!'
         else:
             ret['message'] = u'非法的请求!'
     finally:
         self.write(json.dumps(ret))
예제 #9
0
파일: account.py 프로젝트: cash2one/ZPB
 def post(self):
     ret = {'status': 1, 'message': ''}
     try:
         usercode = self.get_argument('usercode', '')
         password = self.get_argument('password', '')
         if usercode and password:
             (res, message) = CmpLogin.valid(usercode, password)
             if res:
                 message = encryptBindPasswd('zpb', message)
                 if message:
                     ret['status'] = 0
                     ret['data'] = message
                     ret['message'] = u'登录成功!'
                 else:
                     ret['message'] = u'内部服务错误!'
             else:
                 ret['message'] = message
         else:
             ret['message'] = u'用户名或密码不能为空!'
     finally:
         logger.debug(ret)
         self.write(json.dumps(ret))
예제 #10
0
파일: app.py 프로젝트: cash2one/ZPB
 def sig_handler(self, signum, frame):
     logger.debug('{} got signal {}'.format(current_process().name, signum))
     self.stop()