Last active
January 10, 2017 00:27
-
-
Save SohierDane/e2458ab105794c96f4f0b8bc626e6782 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
from ats.one_click_applier import ATSApplierInput | |
from ats.taleo.applier_type_test import TaleoApplier | |
from collections import Counter | |
from postings.selenium_visitor import PostingSeleniumVisitor | |
from util.orator.job_scout import JobScout | |
from util.proxies import setup_phantom | |
from util.database import setup_cursor, execute_query | |
from util.aws import INTERNAL_BUCKET, S3Downloader | |
job_scout = JobScout(user_id=0, posting_id=0, | |
context={'application_user_info': {}}) | |
applier_input = ATSApplierInput(job_scout, "resume.txt") | |
def load_visitor(): | |
service_args = ['--proxy-type=http', | |
'--webdriver-loglevel=ERROR'] | |
posting_driver = setup_phantom(service_args) | |
visitor = PostingSeleniumVisitor(posting_driver) | |
return visitor | |
def check_applier_type(visitor, taleo_url): | |
visitor.get_posting_info(taleo_url) | |
applier_type = TaleoApplier.factory(visitor, applier_input) | |
return applier_type | |
if __name__ == '__main__': | |
db_cursor = setup_cursor() | |
query = "select id, cache_url, source_url from postings where source_url like '%taleo%'" | |
query += " and posted_at > '2016-12-15'::date and not description like '%##%' and cache_url is not null;" | |
query_results = [x for x in execute_query(db_cursor, query)] | |
visitor = load_visitor() | |
results = dict() | |
local_server_prefix = 'http://127.0.0.1:8080/' | |
for entry in query_results: | |
try: | |
s3_path = entry['cache_url'] | |
dler = S3Downloader(INTERNAL_BUCKET, s3_path[s3_path.find(INTERNAL_BUCKET) + | |
len(INTERNAL_BUCKET) + 1:]) | |
# expects http-server running at root as the temp files are placed relative to root | |
temp_file_path = dler.__enter__() | |
results[entry['id']] = check_applier_type(visitor, | |
local_server_prefix + temp_file_path) | |
dler.__exit__('', '', '') # empty strings are for unused args in method. | |
print("Finished applier check for " + entry['source_url'] + ': ' + results[entry['id']]) | |
except: | |
print('Skipping ' + entry['id'] + 'due to error') | |
print("Applier type counts:") | |
print(Counter(results.values())) | |
print(results) | |
visitor.close() | |
# edits to applier file: | |
def factory(visitor, ats_applier_input): | |
simple_submit_xpath = "//input[@value='Apply for this Position']" | |
simple_submit_elems = visitor.driver.find_elements_by_xpath(simple_submit_xpath) | |
one_page_submit_with_creds_xpath = "//span[@class='head1' and text()='Submit Application']" | |
one_page_submit_with_creds_elems = visitor.driver.find_elements_by_xpath(one_page_submit_with_creds_xpath) | |
if simple_submit_elems: | |
return "Simple" | |
elif one_page_submit_with_creds_elems: | |
return "One_page" | |
else: | |
return "Pipeline" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment