Exemple #1
0
def does_id_exists_in_DB(profile_id):
    if not DB.SAVE_ON:
        scr_hlp.print_if_DEBUG(
            "DB.SAVE_ON is False. So program is not fetching data")
        return
    conn = psycopg2.connect(user=pg_user,
                            password=pg_pass,
                            host=pg_host,
                            port=pg_port,
                            database=pg_db)
    cur = conn.cursor()
    cur.execute(f"select id from main where id={profile_id}")
    count = cur.rowcount
    cur.close()
    conn.close()
    scr_hlp.print_if_DEBUG(f"Checking if profile id: {profile_id} exists?")
    if count != 0:
        scr_hlp.pause_if_EXTRADEBUG("profile exists.")
        return True
    scr_hlp.pause_if_EXTRADEBUG("profile not exists")
    return False
Exemple #2
0
def addtoDB(columns_lst, values_lst, dtable):
    if not DB.SAVE_ON:
        scr_hlp.print_if_DEBUG(
            "DB.SAVE_ON is False. So program is not saving data")
        return
    conn = psycopg2.connect(user=pg_user,
                            password=pg_pass,
                            host=pg_host,
                            port=pg_port,
                            database=pg_db)

    cur = conn.cursor()
    columns = ", ".join(columns_lst)
    values = ", ".join([f"'{replaceq(v)}'" for v in values_lst])
    insert_q = f"insert into {dtable} ({columns}) values({values});"
    cur.execute(insert_q)
    count = cur.rowcount
    conn.commit()
    scr_hlp.pause_if_EXTRADEBUG(
        f"{count} Record inserted successfully into mobile table")
    cur.close()
    conn.close()
Exemple #3
0
    def open_wb():
        scr_hlp.print_if_DEBUG("Opening an existing sheet named = %s" %
                               xlsx_hlp.current)
        wbRD = xlrd.open_workbook(xlsx_hlp.current)
        sheets = wbRD.sheets()
        xlsx_hlp.wb = xlsxwriter.Workbook(xlsx_hlp.current)
        for sheet in sheets:  # write data from old file
            if sheet.name == 'main':
                ws = xlsx_hlp.ws_main = xlsx_hlp.wb.add_worksheet(sheet.name)
                xlsx_hlp.row_num_main = sheet.nrows
                scr_hlp.print_if_DEBUG("%s was having %i rows previously." %
                                       (sheet.name, sheet.nrows - 1))

            elif sheet.name == 'compétences':
                ws = xlsx_hlp.ws_comp = xlsx_hlp.wb.add_worksheet(sheet.name)
                xlsx_hlp.row_num_comp = sheet.nrows
                scr_hlp.print_if_DEBUG("%s was having %i rows previously." %
                                       (sheet.name, sheet.nrows - 1))

            elif sheet.name == 'lang':
                ws = xlsx_hlp.ws_lang = xlsx_hlp.wb.add_worksheet(sheet.name)
                xlsx_hlp.row_num_lang = sheet.nrows
                scr_hlp.print_if_DEBUG("%s was having %i rows previously." %
                                       (sheet.name, sheet.nrows - 1))

            elif sheet.name == 'atouts':
                ws = xlsx_hlp.ws_atouts = xlsx_hlp.wb.add_worksheet(sheet.name)
                xlsx_hlp.row_num_atouts = sheet.nrows
                scr_hlp.print_if_DEBUG("%s was having %i rows previously." %
                                       (sheet.name, sheet.nrows - 1))

            elif sheet.name == 'nb_moments_cles':
                ws = xlsx_hlp.ws_nb_moments = xlsx_hlp.wb.add_worksheet(
                    sheet.name)
                xlsx_hlp.row_num_nb_moments = sheet.nrows
                scr_hlp.print_if_DEBUG("%s was having %i rows previously." %
                                       (sheet.name, sheet.nrows - 1))

            else:
                raise NameError("Some Problem in Excel file")

            for row in range(sheet.nrows):
                for col in range(sheet.ncols):
                    ws.write(row, col, sheet.cell(row, col).value)
Exemple #4
0
                "//button[@class='optanon-allow-all accept-cookies-button']")

            while True:
                scr_hlp.pause_if_EXTRADEBUG("Starting job with page_num = %i" %
                                            page_num)
                scr_hlp.load_page(
                    list_page_URL % page_num,
                    do_handle_login=False,
                    refresh_also=False,
                    wait_ele_xpath=
                    "//a[@class='actualLink' and contains(@href,'/detailProfil/')]",
                    ele_count=20)
                candidates_nodes = scr_hlp.d.find_elements_by_xpath(
                    "//a[@class='actualLink' and contains(@href,'/detailProfil/')]"
                )
                scr_hlp.print_if_DEBUG("Total candidates on this page are: " +
                                       str(len(candidates_nodes)))
                is_next_exists = scr_hlp.is_next_page_exists()
                scr_hlp.print_if_DEBUG("is_next_exists = %r" %
                                       scr_hlp.is_next_page_exists())
                c_page_URLs = []
                #save all urls in current page
                for i in range(0, len(candidates_nodes)):
                    c_URL = candidates_nodes[i].get_attribute("href")
                    scr_hlp.print_if_DEBUG(
                        str(i) + ": Candidate link: " + c_URL)
                    c_page_URLs.append(c_URL)

                scr_hlp.print_if_DEBUG(
                    "Total candidates on page_num = %i are %i" %
                    (page_num, len(c_page_URLs)))
                #load those urls