def driver():

    queryTypes = ['by_id', 'by_name']
    queryType = queryTypes[0]

    db_name_ack = 'may27'
    coll_name_ack = 'acks_by_scival'
    coll_name_ack = 'acks_{}'.format(queryType)

    db_name_metrics = 'may27'
    coll_name_metrics = 'metrics_by_scival'
    coll_name_metrics = 'metrics_{}'.format(queryType)

    parent_field = 'scival_id'
    child_field = 'scopus_id'
    child_id_field = 'child_id'

    MY_API_KEY = read_credentials("MY_API_KEY")[0]

    _, year, n = sys.argv
    year = int(year)
    n = int(n)

    doctype = "bk"

    # where to save the results
    dname_book_count = os.path.join(BASE_DIR, "data",
                                    "aff_book_{}".format(year))

    col_dict = {
        2012: "book_downloaded_2012",
        2013: "book_downloaded_2013",
        2014: "book_downloaded_2014",
        2015: "book_downloaded_2015",
        2016: "book_downloaded_2016"
    }

    metricType = 'BookCount'

    coll_ack = mongo_metric_ack(db_name=db_name_ack, coll_name=coll_name_ack)
    coll_metrics = mongo_scopus_metrics(db_name=db_name_metrics,
                                        coll_name=coll_name_metrics)

    valid_dicts = coll_ack.find_valid_parent_ids(metricType, str(year), n)

    get_book_count(n, parent_field, child_id_field, valid_dicts, year, doctype,
                   queryType, dname_book_count, coll_ack, coll_metrics)
예제 #2
0
def put_scival_credentials(driver):


    username = '******'
    password = read_credentials('password')

    username_field = driver.find_element_by_xpath("//input[@id='username']")
    t = runi(5 + runi(-3, 1))
    time.sleep(t)

    password_field = driver.find_element_by_xpath("//input[@id='password-input-password']")
    t = runi(4 + runi(-3, 1))
    time.sleep(t)

    username_field.send_keys(username)
    password_field.send_keys(password, Keys.RETURN)

    t = runi(10 + runi(-3, 1))
    time.sleep(t)

    return driver
    db_name_metrics = db_name_common
    coll_name_metrics = 'metrics_by_scival'
    coll_name_metrics = 'metrics_{}'.format(queryType)
    coll_name_metrics = 'metrics'

    parent_field = 'scival_id'
    child_field = 'scopus_id'
    child_id_field = 'child_id'

    coll_ack = mongo_metric_ack_with_query(db_name=db_name_ack,
                                           coll_name=coll_name_ack)
    coll_metrics = mongo_scopus_metrics_with_query(db_name=db_name_metrics,
                                                   coll_name=coll_name_metrics)

    MY_API_KEY = read_credentials("MY_API_KEY")[0]
    # MY_API_KEY = '12312321321'

    doctype = "bk"

    # where to save the results
    dname_book_count = os.path.join(BASE_DIR, "data",
                                    "aff_book_{}".format(year))

    col_dict = {
        2012: "book_downloaded_2012",
        2013: "book_downloaded_2013",
        2014: "book_downloaded_2014",
        2015: "book_downloaded_2015",
        2016: "book_downloaded_2016"
    }