コード例 #1
0
ファイル: handleservice.py プロジェクト: cash2one/ZPB
def Do20(companyid, siteid, syncid, taskid, **kwargs):
    task = DBTask.queryWithId(syncid)
    try:
        handler = SiteConfig.GetTaskHandler(companyid, siteid, taskid)
        # 账号已解除绑定
        if handler.bind.is_valid != 'T':
            DBTask.newSchedule(companyid, siteid, False)
            raise CompanyAccountUnBindError(companyid, siteid, u'账号已解除绑定')
        # 账号未验证通过
        if handler.bind.check_status == 10:
            raise CompanyAccountInvalidError(companyid, siteid, u'账号登录失败')
        try:
            handler.position_import()
            if HANDLE_STATUS.SUCCESS == handler.status:
                task.sync_status = 2000
                task.succ_num += 1
                task.log_info = handler.message
                # 账号绑定
                handler.bind.check_status = 50
                handler.bind.login_result = '登录成功'
                handler.bind.last_succ_time = datetime.today()
                handler.bind.save()
                # 下发其它异步任务
                infouid = md5(taskid + 'info')
                dtc. async ('zpb.service.handleservice.DoInfo',
                            *(companyid, siteid, infouid),
                            uid=infouid)
                resuid = md5(taskid + '201')
                dtc. async ('zpb.service.handleservice.Do201',
                            *(companyid, siteid, syncid, resuid),
                            uid=resuid)
                logger.info(handler.message)
            elif HANDLE_STATUS.AGAIN == handler.status:
                task.sync_status = 11
                task.fail_num += 1
                task.log_info = handler.message
                logger.error(handler.message)
            else:
                task.sync_status = 10
                task.fail_num += 1
                task.log_info = handler.message
                logger.error(handler.message)
        except BaseException as e:
            raise UnHandleRuntimeError(e)
    except BaseError as e:
        task.sync_status = 10
        task.fail_num += 1
        task.log_info = e.message
    task.save()
コード例 #2
0
ファイル: BaseHandlerManager.py プロジェクト: cash2one/ZPB
 def async_resume_import(self, resume):
     resume['uid'] = md5('{companyid}-{siteid}-{resumeid}'.format(**resume))
     ResumeRedisCli.hincrby(Conf.RESUME_IMPORT_HKEY % self.taskid, 'total')
     ret, _ = dtc. async ('zpb.service.resumeservice.DownResume',
                          'zpb.service.stateservice.CheckResumeImportStat',
                          **resume)
     if not ret:
         ResumeRedisCli.hincrby(Conf.RESUME_IMPORT_HKEY % self.taskid,
                                'ignore')
コード例 #3
0
ファイル: emailconf.py プロジェクト: cash2one/ZPB
 def _uuid(self):
     uid = md5('{}-{}-{}-{}'.format(self.company_id, self.email_user, self.import_id, self.__class__.__name__))
     uname = u'<{}>邮件简历搜索器'.format(self.email_user)
     task = {
         'id': uid,
         'name': uname,
         'func': 'zpb.service.mailservice.DoMailSearcher',
         'args': (self.company_id, uid, self.import_id, 0)
     }
     return task
コード例 #4
0
ファイル: implocalfile.py プロジェクト: cash2one/ZPB
 def _uuid(self):
     uid = md5('{}-{}-{}'.format(self.company_id, self.import_id, self.__class__.__name__))
     uname = u'手动简历解析'
     task = {
         'id': uid,
         'name': uname,
         'func': 'zpb.service.resumeservice.ParseLocalResume',
         'args': (self.company_id, uid, self.import_id)
     }
     return task
コード例 #5
0
 def _uuid(self):
     uid = md5('{}-{}-{}-{}'.format(self.company_id, self.sync_id, self.resume_code, self.__class__.__name__))
     uname = u'<{}>简历付费下载'.format(SiteConfig.getSiteNameById(self.site_id))
     task = {
         'id': uid,
         'name': uname,
         'func': 'zpb.service.handleservice.DoResumePayDown',
         'args': (self.company_id, self.site_id, self.sync_id, self.from_site_code, self.own_pay, uid),
         'kwargs': {'priority': 1}
     }
     return task
コード例 #6
0
 def _uuid(self):
     uid = md5('{}-{}'.format(self.link_id, self.__class__.__name__))
     uname = u'关键词百科超链接'
     task = {
         'id': uid,
         'name': uname,
         'func': 'zpb.service.hyperlinkservice.GetBaikLink',
         'args': (self.link_id, self.link_name),
         'kwargs': {
             'priority': 50
         }
     }
     return task
コード例 #7
0
 def _uuid(self, siteid):
     uid = md5('{}-{}-{}-{}'.format(self.company_id, siteid, self.sync_id,
                                    self.__class__.__name__))
     uname = u'<{}>任务指令中心:{}'.format(SiteConfig.getSiteNameById(siteid),
                                     self.command_type),
     task = {
         'id': uid,
         'name': uname,
         'func': 'zpb.service.handleservice.Do{}'.format(self.command_type),
         # args: 必要条件
         'args': (self.company_id, siteid, self.sync_id, uid),
         # kwargs: 非必要条件
         'kwargs': {
             'jobid': self.job_id,
             'otherid': self.other_id,
             'priority': self.proc_priority
         }
     }
     return task
コード例 #8
0
ファイル: dama2.py プロジェクト: cash2one/ZPB
 def _getSign(self, params):
     return md5(self.__class__.appkey + self.__class__.username +
                params)[0:8]
コード例 #9
0
ファイル: dama2.py プロジェクト: cash2one/ZPB
class Dama2(object):
    """
    打码兔,限制每日最多打码题分1000
    提供网址打码和图片打码,后者打码速度更快
    """

    appid = Conf.DAMA['appid']
    appkey = Conf.DAMA['appkey']
    baseuri = Conf.DAMA['damauri']
    username = Conf.DAMA['username']
    passwd = Conf.DAMA['passwd']
    # 计算密码块
    md5pwd = md5(appkey + md5(md5(username) + md5(passwd)))

    def __init__(self):
        self.httpCli = HttpHandler(self.__class__.__name__)

    # 请求签名
    def _getSign(self, params):
        return md5(self.__class__.appkey + self.__class__.username +
                   params)[0:8]

    # 通过URL打码
    def d2Url(self, dtype, url):
        data = {
            'appID': self.__class__.appid,
            'user': self.__class__.username,
            'pwd': self.__class__.md5pwd,
            'type': dtype,
            'url': url,
            'sign': self._getSign(url)
        }
        rep = self.httpCli.call('{}/d2Url'.format(self.__class__.baseuri),
                                data)
        js = json.loads(rep.data)
        if js['ret'] == 0:
            cookie = js.get('cookie', '')
            cookie = unquote(cookie).replace('+', ' ')
            return {
                'verify': js['result'],
                'cookie': cookie,
                'retid': js['id']
            }
        else:
            raise DamaError(js['ret'])

    # 通过验证码图片打码
    def d2File(self, dtype, filedata):
        data = {
            'appID': self.__class__.appid,
            'user': self.__class__.username,
            'pwd': self.__class__.md5pwd,
            'type': dtype,
            'fileData': binascii.b2a_hex(filedata),
            'sign': self._getSign(filedata)
        }
        rep = self.httpCli.call('{}/d2File'.format(self.__class__.baseuri),
                                data)
        js = json.loads(rep.data)
        if js['ret'] == 0:
            cookie = js.get('cookie', '')
            cookie = unquote(cookie).replace('+', ' ')
            return {
                'verify': js['result'],
                'cookie': cookie,
                'retid': js['id']
            }
        else:
            raise DamaError(js['ret'])