Пример #1
0
def main(username=USERNAME, password=PASSWORD, driver=CHROME_DRIVER_LOCATION):
    """
    Execution logic for variables setup and running 
    TestCase to interact with LinkedIn website.
    """
    ascii_art()

    try:
        check_for_login_data(username, password, driver)
    except NameError:
        return False

    # get list of students
    try:
        with open("students.txt") as f:
            # read, remove Byte order mark from Google Docs, split, then strip.
            students = f.read().strip("").splitlines()
    except FileNotFoundError:
        print_no_students_txt()
        return False

    # make URLs conform to standard https://www.linkedin.com/in/ pattern
    students = url_check(students)

    # get list of students that already have been sent requests.
    try:
        with open("connect_req_sent.txt") as f:
            sent = [x.strip() for x in f.read().splitlines() if x]
    except FileNotFoundError:
        sent = []

    # Remove students that have already been sent requests.
    global STUDENTS
    STUDENTS = [x for x in students if x not in sent]

    # if --conn-again flag passed add no_connect_button list to STUDENTS
    # to attempt to connect to those links again.
    if args.conn_again:
        try:
            with open("no_connect_button.log") as f:
                conn_agains = [x.strip() for x in f.read().splitlines() if x]
                [STUDENTS.append(x) for x in conn_agains if x not in STUDENTS]
            with open("no_connect_button.log", "w") as f:
                f.write("")
        except FileNotFoundError:
            pass

    if STUDENTS:
        unittest.main()
    else:
        print("  No new students in students list!  ".center(100, "*"))
        print("\n")
        return False
Пример #2
0
def main(username=USERNAME, password=PASSWORD, driver=CHROME_DRIVER_LOCATION):
    """
    Execution logic for variables setup and running 
    TestCase to interact with LinkedIn website.
    """
    ascii_art()
    check_for_login_data(username, password, driver)

    # get list of students
    try:
        with open("students.txt") as f:
            # read, remove Byte order mark from Google Docs, split, then strip.
            students = f.read().strip("").splitlines()
    except FileNotFoundError:
        print_no_students_txt()
        raise FileNotFoundError("No students.txt file found!")

    # make urls conform to standard https://www.linkedin.com/in/ pattern
    students = url_check(students)

    # get list of students that already have been sent requests.
    try:
        with open("connect_req_sent.txt") as f:
            sent = f.read().splitlines()
    except FileNotFoundError:
        sent = []
    # Remove students that have already been sent requests.
    global STUDENTS
    STUDENTS = [x for x in students if x and x not in sent]

    if STUDENTS:
        unittest.main()
    else:
        print("  No new students in students list!  ".center(100, "*"))
        print("\n")
        return False
Пример #3
0
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
******************************************************************************************************************************************
"""

# download chromedriver to local directory an enter local path below.
CHROME_DRIVER_LOCATION = r""
# LinkedIn credentials
USERNAME = ""
PASSWORD = ""
# Enter correct school or group name.
SCHOOL = "Springboard"

check_for_login_data(USERNAME, PASSWORD, CHROME_DRIVER_LOCATION)

# get list of students
try:
    with open("students.txt") as f:
        # read, remove Byte order mark from Google Docs, split, then strip.
        students = f.read().strip("").splitlines()
except FileNotFoundError:
    print_no_students_txt()
    raise FileNotFoundError("No students.txt file found!")

# make urls conform to standard https://www.linkedin.com/in/ pattern
students = url_check(students)

# get list of students that already have been sent requests.
try:
Пример #4
0
 def test_check_for_login_data(self):
     self.assertEqual(check_for_login_data("x", "x", "x"), None)
     self.assertRaises(NameError, check_for_login_data, *["", "x", "x"])
     self.assertRaises(NameError, check_for_login_data, *["x", "", "x"])
     self.assertRaises(NameError, check_for_login_data, *["x", "x", ""])