Exemple #1
0
def logError(err):
    with open(
            '/apps/jobhuntin/backslash/logs/send_resume_request_job_errors.txt',
            'a') as f:
        f.write(str(datetime.datetime.utcnow()) + '\t' + err + '\n')
    eventnotifier.sendEventNotification(
        "Jobhunt Job Error: send_resume_request_job", err)
def handle(request):
    rec, redirect = codejar.actions.handleSecurity(request, 'recruiter')
    if not rec: return redirect
    
    email_list = dataplus.dictGetSafeVal(request.REQUEST, 'email_list', '')
    email_query = dataplus.dictGetSafeVal(request.REQUEST, 'email_query', '')
    if email_query:
        search_keywords, experience, location, max_salary = cPickle.loads(base64.b64decode(email_query))
        response = search_helper.matchResumes(search_keywords, experience, location, max_salary, datetime.datetime(1981, 1, 9))
        email_list = dataplus.decode(string.join([usr['email'] for usr in response.results], '; '))
    
    action = dataplus.dictGetSafeVal(request.REQUEST, 'action', '')
    if action == 'show_form':
        return codejar.actions.render(request, 'recruiters/emailusers.htm',
                               {'to_list':email_list,
                                'recruiter': rec})
    
    elif action == 'email_users':
        subject = dataplus.dictGetSafeVal(request.REQUEST, 'subject', '')
        message = dataplus.dictGetSafeVal(request.REQUEST, 'message', '')
        
        message += '<p>&nbsp;</p><div style="border-bottom: 1px solid rgb(153, 153, 153);"></div><p>This email has been sent by %s(%s) of %s using <a href="http://www.jobhunt.in">www.jobhunt.in</a> services.</p>' % (rec.name, rec.email, rec.organization)
        mailman.sendMail(rec.name + '<*****@*****.**>', email_list.split(';'), subject, message, reply_to=rec.email)
        
        eventnotifier.sendEventNotification("New Recruiter Mass Mail: " + subject + " - " + rec.name + "(" + rec.email + ")" + " message:\n" + message)
        
        return HttpResponseRedirect('dashboard.htm?flashId=email_sent')
Exemple #3
0
def logError(err):
    with open('/apps/jobhuntin/backslash/logs/trinity_feed_job_errors.txt',
              'a') as f:
        f.write(str(datetime.datetime.utcnow()) + '\t' + err + '\n')
    print "Stopping job:", err
    eventnotifier.sendEventNotification("Jobhunt Job Error: trinity_feed_job",
                                        err)
Exemple #4
0
def handle(request):
    account, redirect = codejar.actions.handleSecurity(request, 'account')
    if request.method == 'GET': 
        msg_type = dataplus.dictGetSafeVal(request.REQUEST, 'type','contactus')
        
        msg_hdr = {'contactus': 'Contact us',
                    'bug': 'Bug Report',
                    'feedback': 'Feedback',
                    'suggestion': 'Suggestion',
                    'reportabuse': 'Report Abuse'}[msg_type]
        
        email = ''
        name = ''
        if account:
            email = account.username
            account_detail = models.User.objects.filter(account=account)
            if not account_detail:
                account_detail = models.Recruiter.objects.filter(account=account)
            name = account_detail[0].name
        
        return codejar.actions.render(request, 'msg.htm',
                                 {'msg_hdr':msg_hdr,
                                  'email':email,
                                  'name':name })
        
    elif request.method == 'POST':
        name = dataplus.dictGetSafeVal(request.REQUEST, 'name', '')
        email = dataplus.dictGetSafeVal(request.REQUEST, 'email', '')
        msg_hdr = dataplus.dictGetSafeVal(request.REQUEST, 'messageHeader', '')
        message = dataplus.dictGetSafeVal(request.REQUEST, 'message', '')
        
        eventnotifier.sendEventNotification("New Message: " + msg_hdr + " " + name + "(" + email + ")" + " says:\n" + message)
        
        return HttpResponseRedirect('thanks.html')
def handle(request):
    if request.method == 'GET':
        rec, redirect = codejar.actions.handleSecurity(request, 'recruiter')
        if not rec: return redirect

        #Propaganda special
        is_prop_login = dataplus.dictGetVal(request.session, 'prop_login',
                                            False)
        if is_prop_login:
            account_state = dataplus.dictGetVal(request.session,
                                                'account_state', 'I')
            if account_state == 'I':
                if rec.account.account_state == 'I':
                    rec.account.account_state = 'A'
                    rec.account.save()
                    eventnotifier.sendEventNotification(
                        'Recruiter PropActivated: ' + rec.email)

            elif account_state == 'A':
                return HttpResponseRedirect('propactivation.htm')

        recent_searches = models.RecruiterData.getRecentSearches(rec)
        recent_searches_formatted = []
        for dict in recent_searches:
            dict['keywords'] = dict['keywords'].replace(', ', ',').replace(
                ',', ', ')
            json_dict = u"{'keywords':'%s', 'experience':'%d', 'location':'%s', 'max_salary':'%d'}" % (
                dict['keywords'], dict['experience'], dict['location'],
                dict['max_salary'])
            display_str = dict['keywords']
            if dict['experience'] > 0:
                display_str += u" with %d years" % (dict['experience'])
            if not dict['location'].lower() == 'any':
                display_str += u" in " + dict['location']
            recent_searches_formatted.append((display_str, json_dict))

        return codejar.actions.render(
            request, 'recruiters/dashboard.htm', {
                'experience_html':
                experienceHTML(),
                'salary_html':
                salaryHTML(),
                'location_html':
                locationHTML(),
                'recent_searches':
                recent_searches_formatted,
                'recent_subscriptions': [
                    str(subscr)
                    for subscr in rec.subscriptions.order_by('-added_on')[:2]
                ],
                'email_verified':
                rec.account.email_verified
            })

    elif request.method == 'POST':
        ##      shouldn't be happening :)
        pass
Exemple #6
0
    def save(self):
        import sys, datetime
        sys.path.append('/websites/jobhuntin')
        from utils import mailer, eventnotifier
        if not self.id:
            eventnotifier.sendEventNotification(
                'New User: %s posted on: %s' %
                (self.doc_filename,
                 datetime.datetime.utcnow().strftime('%d/%m/%Y %H:%M:%S %p')))

        if self.name and self.email and self.tags and self.pref_location:
            if not self.tagged:
                self.tagged = True
                from datetime import datetime
                self.tagged_on = datetime.utcnow()

        if self.account.account_type == 'FU' and self.id > 0 and self.tagged:
            user_old = User.objects.get(id=self.id)
            if user_old and not user_old.email:
                params = {'user_key': self.key}
                usrs = User.objects.filter(email=self.email,
                                           account__account_state='A',
                                           id__lt=self.id)
                if usrs:
                    if usrs.filter(account__account_type='PU'):
                        mailer.sendPremiumUserLoginToUpdateAlert(
                            self.email, by_mail=bool(self.mail_ref))
                        self.delete()
                        return
                    else:
                        for usr in usrs.all():
                            usr.account.account_state = 'I'
                            usr.account.save()
                            IndexDelta(user_id=usr.id, index_type='D').save()

                        mailer.sendResumeUpdatedMail(self.email, params)
                else:
                    mailer.sendResumeAddedMail(self.email, params)

        super(User, self).save()

        #If he is tagged and is job hunting, he has to be indexed
        if self.tagged and self.is_job_hunting == 'yes':
            IndexDelta(user_id=self.id, index_type='U').save()
Exemple #7
0
 def save(self):
     import sys
     sys.path.append('/websites/jobhuntin')
     from utils import eventnotifier
     if not self.id:
         eventnotifier.sendEventNotification('New Recruiter: ' + self.email)
     if self.verified and self.verified_on.year < 2000:
         from datetime import datetime
         self.verified_on = datetime.utcnow()
         self.account.account_state = 'A'
         
     if self.id > 0 and self.verified:
         rec = Recruiter.objects.get(id=self.id)
         if rec and not rec.verified:
             from jobs import recruiter_mail_job
             for sub in rec.subscriptions.all():
                 recruiter_mail_job.sendSubscriptionResults(sub, rec.id, rec.key, rec.email)
             
     super(Recruiter, self).save()
Exemple #8
0
    def save(self):
        import sys
        sys.path.append('/websites/jobhuntin')
        from utils import eventnotifier
        if not self.id:
            eventnotifier.sendEventNotification('New Recruiter: ' + self.email)
        if self.verified and self.verified_on.year < 2000:
            from datetime import datetime
            self.verified_on = datetime.utcnow()
            self.account.account_state = 'A'

        if self.id > 0 and self.verified:
            rec = Recruiter.objects.get(id=self.id)
            if rec and not rec.verified:
                from jobs import recruiter_mail_job
                for sub in rec.subscriptions.all():
                    recruiter_mail_job.sendSubscriptionResults(
                        sub, rec.id, rec.key, rec.email)

        super(Recruiter, self).save()
Exemple #9
0
def handle(request):    
    if request.method == 'GET':         
        return codejar.actions.render(request, 'tellfriends.htm')
        
    elif request.method == 'POST':
        sender_name = dataplus.dictGetSafeVal(request.REQUEST, 'name')
        emails = []
        emails[len(emails):] = dataplus.dictGetSafeVal(request.REQUEST, 'email1', '').split(',')
        emails[len(emails):] = dataplus.dictGetSafeVal(request.REQUEST, 'email2', '').split(',')
        emails[len(emails):] = dataplus.dictGetSafeVal(request.REQUEST, 'email3', '').split(',')
        message = dataplus.dictGetSafeVal(request.REQUEST, 'messageBox')
        
        valid_emails = [eml for eml in emails if eml != '']
        if sender_name and valid_emails and message:
            ip_address = request.META['REMOTE_ADDR']
            sent_count = getSentRequestCount(ip_address)
            send_max = 6 - sent_count
            if send_max < 0:    send_max = 0
            
            requests = []
            for email_id in valid_emails:
                fr = models.TellFriend(sender_name=sender_name, 
                                        receiver_email=email_id, 
                                        message=message,
                                        ip_address=ip_address)
                fr.save()
                requests.append(fr)
            
            subject = 'New Tell Friends Request'
            if send_max < len(valid_emails):    subject += ": Require verification"
            event_desc = "Sender: %s\nReceiver(s): %s\nMessage: %s" % (sender_name, string.join(valid_emails, ','), message)
            eventnotifier.sendEventNotification(subject, event_desc)
            
            for req in requests[:send_max]:
                mailer.sendInviteFriend(req)
                req.sent = True
                req.save()
            
            return HttpResponseRedirect('toldfriends.html')
        else:
            return HttpResponse('Gimme some valid data :(')
Exemple #10
0
def handle(request):
    rec, redirect = codejar.actions.handleSecurity(request, 'recruiter')
    if not rec: return redirect

    email_list = dataplus.dictGetSafeVal(request.REQUEST, 'email_list', '')
    email_query = dataplus.dictGetSafeVal(request.REQUEST, 'email_query', '')
    if email_query:
        search_keywords, experience, location, max_salary = cPickle.loads(
            base64.b64decode(email_query))
        response = search_helper.matchResumes(search_keywords, experience,
                                              location, max_salary,
                                              datetime.datetime(1981, 1, 9))
        email_list = dataplus.decode(
            string.join([usr['email'] for usr in response.results], '; '))

    action = dataplus.dictGetSafeVal(request.REQUEST, 'action', '')
    if action == 'show_form':
        return codejar.actions.render(request, 'recruiters/emailusers.htm', {
            'to_list': email_list,
            'recruiter': rec
        })

    elif action == 'email_users':
        subject = dataplus.dictGetSafeVal(request.REQUEST, 'subject', '')
        message = dataplus.dictGetSafeVal(request.REQUEST, 'message', '')

        message += '<p>&nbsp;</p><div style="border-bottom: 1px solid rgb(153, 153, 153);"></div><p>This email has been sent by %s(%s) of %s using <a href="http://www.jobhunt.in">www.jobhunt.in</a> services.</p>' % (
            rec.name, rec.email, rec.organization)
        mailman.sendMail(rec.name + '<*****@*****.**>',
                         email_list.split(';'),
                         subject,
                         message,
                         reply_to=rec.email)

        eventnotifier.sendEventNotification("New Recruiter Mass Mail: " +
                                            subject + " - " + rec.name + "(" +
                                            rec.email + ")" + " message:\n" +
                                            message)

        return HttpResponseRedirect('dashboard.htm?flashId=email_sent')
def handle(request):
    if request.method == 'GET':
        rec, redirect = codejar.actions.handleSecurity(request, 'recruiter')
        if not rec:    return redirect
        
        #Propaganda special
        is_prop_login = dataplus.dictGetVal(request.session, 'prop_login', False)
        if is_prop_login:
            account_state = dataplus.dictGetVal(request.session, 'account_state', 'I')
            if account_state == 'I':
                if rec.account.account_state == 'I':
                    rec.account.account_state = 'A'
                    rec.account.save()
                    eventnotifier.sendEventNotification('Recruiter PropActivated: ' + rec.email)

            elif account_state == 'A':
                return HttpResponseRedirect('propactivation.htm')
        

        recent_searches = models.RecruiterData.getRecentSearches(rec)
        recent_searches_formatted = []
        for dict in recent_searches:
            dict['keywords'] = dict['keywords'].replace(', ', ',').replace(',', ', ')
            json_dict = u"{'keywords':'%s', 'experience':'%d', 'location':'%s', 'max_salary':'%d'}" % (dict['keywords'], dict['experience'], dict['location'], dict['max_salary'])
            display_str = dict['keywords']
            if dict['experience'] > 0:  display_str += u" with %d years" % (dict['experience'])
            if not dict['location'].lower() == 'any':   display_str += u" in " + dict['location']
            recent_searches_formatted.append((display_str, json_dict))

        return codejar.actions.render(request, 'recruiters/dashboard.htm',
                {'experience_html':experienceHTML(),
                 'salary_html': salaryHTML(),
                 'location_html': locationHTML(),
                 'recent_searches': recent_searches_formatted,
                 'recent_subscriptions': [str(subscr) for subscr in rec.subscriptions.order_by('-added_on')[:2]],
                 'email_verified': rec.account.email_verified })

    elif request.method == 'POST':
##      shouldn't be happening :)
        pass
Exemple #12
0
    def save(self):
        import sys, datetime
        sys.path.append('/websites/jobhuntin')
        from utils import mailer, eventnotifier
        if not self.id:
            eventnotifier.sendEventNotification('New User: %s posted on: %s' % (self.doc_filename, datetime.datetime.utcnow().strftime('%d/%m/%Y %H:%M:%S %p')))

        if self.name and self.email and self.tags and self.pref_location:
            if not self.tagged:
                self.tagged = True
                from datetime import datetime
                self.tagged_on = datetime.utcnow()

        if self.account.account_type == 'FU' and self.id > 0 and self.tagged:
            user_old = User.objects.get(id=self.id)
            if user_old and not user_old.email:
                params = {'user_key': self.key }
                usrs = User.objects.filter(email=self.email, account__account_state='A', id__lt=self.id)
                if usrs:
                    if usrs.filter(account__account_type = 'PU'):
                        mailer.sendPremiumUserLoginToUpdateAlert(self.email, by_mail = bool(self.mail_ref))
                        self.delete()
                        return
                    else:
                        for usr in usrs.all():
                            usr.account.account_state = 'I'
                            usr.account.save()
                            IndexDelta(user_id=usr.id, index_type='D').save()

                        mailer.sendResumeUpdatedMail(self.email, params)
                else:
                    mailer.sendResumeAddedMail(self.email, params)

        super(User, self).save()
        
        #If he is tagged and is job hunting, he has to be indexed
        if self.tagged and self.is_job_hunting == 'yes':    IndexDelta(user_id=self.id, index_type='U').save()
Exemple #13
0
def handle(request):
    rec, redirect = codejar.actions.handleSecurity(request, 'recruiter')
    if not rec:    return redirect

    recruiter_data = models.RecruiterData.objects.filter(recruiter=rec)[0]
    remaining_invites = recruiter_data.num_invites

    if request.method == 'GET':
        if remaining_invites == 0:
            eventnotifier.sendEventNotification('Recruiter %s with Id %s, has exhausted his invites' % (rec.name, rec.id))

        html, msg = getHTML(remaining_invites)
        return codejar.actions.render(request, 'recruiters/invites.htm',
                                      {'invite_message': msg,
                                       'email_boxes_html': html})

    elif request.method == 'POST':
        emails  = []
        if dataplus.dictGetSafeVal(request.REQUEST, 'email1'): emails.append(dataplus.dictGetSafeVal(request.REQUEST, 'email1').strip())
        if dataplus.dictGetSafeVal(request.REQUEST, 'email2'): emails.append(dataplus.dictGetSafeVal(request.REQUEST, 'email2').strip())
        if dataplus.dictGetSafeVal(request.REQUEST, 'email3'): emails.append(dataplus.dictGetSafeVal(request.REQUEST, 'email3').strip())
        if dataplus.dictGetSafeVal(request.REQUEST, 'email4'): emails.append(dataplus.dictGetSafeVal(request.REQUEST, 'email4').strip())
        if dataplus.dictGetSafeVal(request.REQUEST, 'email5'): emails.append(dataplus.dictGetSafeVal(request.REQUEST, 'email5').strip())

        if remaining_invites < 5:
            emails = emails[:remaining_invites]

        for email in emails:
            parameters = {'from': rec.name,
                          'token':models.Token.getNew(rec.account.id, email, 'Invites')}
            mailer.sendRecruiterInvites(email, parameters)
            eventnotifier.sendEventNotification('Recruiter %s(%s) has invited "%s"' % (rec.name, rec.email, email))

        remaining_invites = remaining_invites - len(emails)
        recruiter_data.num_invites = remaining_invites
        recruiter_data.save()

        if remaining_invites <= 0:
            eventnotifier.sendEventNotification('Recruiter %s with Id %s, has exhausted his invites' % (rec.name, rec.id))

        html, msg = getHTML(remaining_invites)
        return codejar.actions.render(request, 'recruiters/invites.htm',
                                      {'flash_alerts':['Invites have been sent. ' + msg],
                                       'email_boxes_html': html})
Exemple #14
0
def saveEmailedResumes():
    global error_count
    pop = poplib.POP3(pop_server)
    pop.user(pop_user)
    pop.pass_(pop_pass)
    stats = pop.stat()
    rx_headers = re.compile('^(From|To|Subject|Content-Type):', re.IGNORECASE)

    if stats and stats[0] > 0:
        connection = psycopg2.connect(
            "dbname='jhindb' user='******' password='******' host='127.0.0.1'"
        )
        cursor = connection.cursor()

        time_now = datetime.datetime.utcnow()
        count = stats[0]
        for i in range(1, 1 + count):
            try:
                resp, lines, bytes = pop.top(i, 10)
                req_lines = filter(rx_headers.match, lines)
                headers = map(lambda x: x.split(': ', 1), req_lines)

                def find_in_headers(hdr_name):
                    res = filter(lambda x: x[0].lower() == hdr_name.lower(),
                                 headers)
                    if len(res) > 0: return res[0][1]
                    else: return ''

                doc_filename = None
                doc_filepath = None
                has_doc = False
                if find_in_headers('Content-Type').lower().startswith(
                        'multipart'):

                    msg = email.message_from_string('\n'.join(pop.retr(i)[1]))
                    body = {'html': '', 'plain': ''}
                    for part in msg.walk():
                        if part.get_content_maintype() == 'text':
                            sub_type = part.get_content_subtype()
                            if sub_type in ['plain', 'html']:
                                data = dataplus.decode(
                                    part.get_payload(decode=True))
                                if len(data) < 25: pass
                                body[sub_type] = data

                        if part.get_content_maintype(
                        ) == 'application' and part.get_content_subtype(
                        ) == 'msword':
                            doc_filepath = saveResumeFile(
                                part.get_payload(decode=True))
                            doc_filename = part.get_filename()
                            has_doc = True

                    if doc_filename:
                        stmt = "INSERT INTO website_receivedmail (from_address, subject, body_html, body_text, doc_filepath, received_on)"
                        stmt += " VALUES (%(from_address)s, %(subject)s, %(html_body)s, %(plain_body)s, %(doc_filepath)s, %(time_now)s)"
                        cursor.execute(
                            stmt, {
                                'from_address': find_in_headers('From')[:100],
                                'subject': find_in_headers('Subject')[:100],
                                'html_body': body['html'],
                                'plain_body': body['plain'],
                                'doc_filepath': doc_filepath,
                                'time_now': str(time_now)
                            })
                        cursor.execute(
                            "SELECT CURRVAL('website_receivedmail_id_seq');")
                        mail_id = str(cursor.fetchone()[0])
                        resume_key = dataplus.getUniqueId()

                        stmt = 'INSERT INTO website_resume (doc_filename, doc_filepath, html_filepath, text_filepath, doc_hash, posted_on, mail_ref_id, "name", email, experience, tags, industry, "location", current_employer, summary, "key", tagged, is_active, min_salary, desired_employer) '
                        stmt += "VALUES (%(doc_filename)s ,%(doc_filepath)s, '', '', '', %(time_now)s, %(mail_id)s, '', '', 0, '', '', '', '', '', %(resume_key)s, False, False, 0, '')"
                        cursor.execute(
                            stmt, {
                                'doc_filename': doc_filename,
                                'doc_filepath': doc_filepath,
                                'time_now': str(time_now),
                                'mail_id': mail_id,
                                'resume_key': resume_key
                            })

                from_hdr = find_in_headers('From')
                candidate_name = getNameFromHeader(from_hdr)
                if has_doc:
                    params = {'name': candidate_name, 'resume_key': resume_key}
                    mailer.sendResumeReceivedMail(from_hdr, params)
                    eventnotifier.sendEventNotification(
                        'New Resume by mail: %s posted on: %s' %
                        (doc_filename,
                         time_now.strftime('%d/%m/%Y %H:%M:%S %p')))
                else:
                    params = {'name': candidate_name}
                    mailer.sendInvalidResumeMail(from_hdr, params)

                pop.dele(i)

            except:
                error_count += 1
                setErrorCount(error_count)
                logError('Processing mail ' + find_in_headers('From') + ' - ' +
                         find_in_headers('Subject') + ' failed : ' +
                         str(sys.exc_info()[0]) + ', ' +
                         str(sys.exc_info()[1]))
                if error_count == max_errors:
                    logError(
                        'Jobhunt Job Error: Stopping mail_pickup_job as it has encountered Maximum number of errors.'
                    )
                    break

        connection.commit()
    pop.quit()
Exemple #15
0
def handle(request):
    rec, redirect = codejar.actions.handleSecurity(request, 'recruiter')
    if not rec: return redirect

    recruiter_data = models.RecruiterData.objects.filter(recruiter=rec)[0]
    remaining_invites = recruiter_data.num_invites

    if request.method == 'GET':
        if remaining_invites == 0:
            eventnotifier.sendEventNotification(
                'Recruiter %s with Id %s, has exhausted his invites' %
                (rec.name, rec.id))

        html, msg = getHTML(remaining_invites)
        return codejar.actions.render(request, 'recruiters/invites.htm', {
            'invite_message': msg,
            'email_boxes_html': html
        })

    elif request.method == 'POST':
        emails = []
        if dataplus.dictGetSafeVal(request.REQUEST, 'email1'):
            emails.append(
                dataplus.dictGetSafeVal(request.REQUEST, 'email1').strip())
        if dataplus.dictGetSafeVal(request.REQUEST, 'email2'):
            emails.append(
                dataplus.dictGetSafeVal(request.REQUEST, 'email2').strip())
        if dataplus.dictGetSafeVal(request.REQUEST, 'email3'):
            emails.append(
                dataplus.dictGetSafeVal(request.REQUEST, 'email3').strip())
        if dataplus.dictGetSafeVal(request.REQUEST, 'email4'):
            emails.append(
                dataplus.dictGetSafeVal(request.REQUEST, 'email4').strip())
        if dataplus.dictGetSafeVal(request.REQUEST, 'email5'):
            emails.append(
                dataplus.dictGetSafeVal(request.REQUEST, 'email5').strip())

        if remaining_invites < 5:
            emails = emails[:remaining_invites]

        for email in emails:
            parameters = {
                'from': rec.name,
                'token': models.Token.getNew(rec.account.id, email, 'Invites')
            }
            mailer.sendRecruiterInvites(email, parameters)
            eventnotifier.sendEventNotification(
                'Recruiter %s(%s) has invited "%s"' %
                (rec.name, rec.email, email))

        remaining_invites = remaining_invites - len(emails)
        recruiter_data.num_invites = remaining_invites
        recruiter_data.save()

        if remaining_invites <= 0:
            eventnotifier.sendEventNotification(
                'Recruiter %s with Id %s, has exhausted his invites' %
                (rec.name, rec.id))

        html, msg = getHTML(remaining_invites)
        return codejar.actions.render(
            request, 'recruiters/invites.htm', {
                'flash_alerts': ['Invites have been sent. ' + msg],
                'email_boxes_html': html
            })
Exemple #16
0
def logError(err):
    with open('/apps/jobhuntin/backslash/logs/trinity_feed_job_errors.txt', 'a') as f:
        f.write(str(datetime.datetime.utcnow()) + '\t' + err + '\n')
    print "Stopping job:", err
    eventnotifier.sendEventNotification("Jobhunt Job Error: trinity_feed_job", err)
Exemple #17
0
def logError(err):
    with open('/apps/jobhuntin/logs/resume_save_errors.txt', 'a') as file:
        file.write(str(datetime.datetime.utcnow()) + '\t' + err + '\n')
    eventnotifier.sendEventNotification(
        "Jobhunt Job Error: resume_process_job", err)
Exemple #18
0
def saveEmailedResumes():
    global error_count
    pop = poplib.POP3(pop_server)
    pop.user(pop_user)
    pop.pass_(pop_pass)
    stats = pop.stat()
    rx_headers = re.compile('^(From|To|Subject|Content-Type):',re.IGNORECASE)
    
    if stats and stats[0] > 0:  
        connection = psycopg2.connect("dbname='jhindb' user='******' password='******' host='127.0.0.1'")
        cursor = connection.cursor()
        
        time_now = datetime.datetime.utcnow()
        count = stats[0]
        for i in range(1,1+count):
            try:
                resp, lines, bytes = pop.top(i,10)
                req_lines = filter(rx_headers.match, lines)
                headers = map(lambda x: x.split(': ', 1), req_lines)
                
                def find_in_headers(hdr_name):
                    res = filter(lambda x: x[0].lower() == hdr_name.lower(), headers)
                    if len(res) > 0:    return res[0][1]
                    else:   return ''
                
                doc_filename = None
                doc_filepath = None
                has_doc = False
                if find_in_headers('Content-Type').lower().startswith('multipart'):
                
                    msg = email.message_from_string('\n'.join(pop.retr(i)[1]))
                    body = {'html':'', 'plain':''}
                    for part in msg.walk():
                        if part.get_content_maintype() == 'text':
                            sub_type = part.get_content_subtype()
                            if sub_type in ['plain','html']:
                                data = dataplus.decode(part.get_payload(decode=True))
                                if len(data) < 25:  pass
                                body[sub_type] = data
                        
                        if part.get_content_maintype() == 'application' and part.get_content_subtype() == 'msword':
                            doc_filepath = saveResumeFile(part.get_payload(decode=True))
                            doc_filename = part.get_filename()
                            has_doc = True
                    
                    if doc_filename:
                        stmt = "INSERT INTO website_receivedmail (from_address, subject, body_html, body_text, doc_filepath, received_on)"
                        stmt += " VALUES (%(from_address)s, %(subject)s, %(html_body)s, %(plain_body)s, %(doc_filepath)s, %(time_now)s)"
                        cursor.execute(stmt, {'from_address':find_in_headers('From')[:100], 'subject':find_in_headers('Subject')[:100],
                                            'html_body':body['html'], 'plain_body':body['plain'],
                                            'doc_filepath':doc_filepath, 'time_now':str(time_now)})
                        cursor.execute("SELECT CURRVAL('website_receivedmail_id_seq');")
                        mail_id = str(cursor.fetchone()[0])
                        resume_key = dataplus.getUniqueId()
                        
                        stmt = 'INSERT INTO website_resume (doc_filename, doc_filepath, html_filepath, text_filepath, doc_hash, posted_on, mail_ref_id, "name", email, experience, tags, industry, "location", current_employer, summary, "key", tagged, is_active, min_salary, desired_employer) '
                        stmt += "VALUES (%(doc_filename)s ,%(doc_filepath)s, '', '', '', %(time_now)s, %(mail_id)s, '', '', 0, '', '', '', '', '', %(resume_key)s, False, False, 0, '')"
                        cursor.execute(stmt, {'doc_filename':doc_filename, 'doc_filepath':doc_filepath, 'time_now':str(time_now), 'mail_id':mail_id, 'resume_key':resume_key})
                    
                from_hdr = find_in_headers('From')
                candidate_name = getNameFromHeader(from_hdr)
                if has_doc:
                    params = {'name':candidate_name, 'resume_key': resume_key}
                    mailer.sendResumeReceivedMail(from_hdr, params)
                    eventnotifier.sendEventNotification('New Resume by mail: %s posted on: %s' % (doc_filename, time_now.strftime('%d/%m/%Y %H:%M:%S %p')))
                else:
                    params = {'name': candidate_name}
                    mailer.sendInvalidResumeMail(from_hdr, params)
                
                pop.dele(i)
                    
            except:
                error_count += 1
                setErrorCount(error_count)
                logError('Processing mail ' + find_in_headers('From') + ' - ' + find_in_headers('Subject') + ' failed : ' + str(sys.exc_info()[0]) + ', ' + str(sys.exc_info()[1]))
                if error_count == max_errors:
                    logError('Jobhunt Job Error: Stopping mail_pickup_job as it has encountered Maximum number of errors.')
                    break
                
        connection.commit()
    pop.quit()
def logError(err):
    with open('/apps/jobhuntin/backslash/logs/send_resume_request_job_errors.txt', 'a') as f:
        f.write(str(datetime.datetime.utcnow()) + '\t' + err + '\n')
    eventnotifier.sendEventNotification("Jobhunt Job Error: send_resume_request_job", err)
Exemple #20
0
def logError(err):
    with open('/apps/jobhuntin/logs/resume_save_errors.txt', 'a') as file:
        file.write(str(datetime.datetime.utcnow()) + '\t' + err + '\n')
    eventnotifier.sendEventNotification("Jobhunt Job Error: resume_process_job", err)