def actions(Actions_spec, ACID): #Global variables: ACData = Database().get_ACIDdata(ACID) Link = "https://www.facebook.com/" #Chrome Settings options = webdriver.ChromeOptions() prefs = {"profile.default_content_setting_values.notifications": 2} if Actions_spec[1] == True: Cloc = Path(os.path.abspath("")) #Current Location Extension = Cloc / 'toolkit.crx' options.add_extension(Extension) options.add_experimental_option("prefs", prefs) global driver driver = webdriver.Chrome(options=options) if Actions_spec[0] == True: Login(ACData[1], ACData[2], ACID) elif Actions_spec[0] == False: input_cookies(ACData, Link, driver) if Actions_spec[2] == True: Groups = GetGroups() Database().update_Groups(ACID, Groups) if Actions_spec[3] == True: driver.quit() else: print('do nothin')
def share_actions(ACID, link, Say, PostGroup, share_timeline): #Global variables: database = Database() repeatednum = [] from MySQL_FB_Retrieve_Cookies import input_cookies #Menu ACData = database.get_ACIDdata(ACID) #Disable Chrome notification alerts options = webdriver.ChromeOptions() prefs = {"profile.default_content_setting_values.notifications" : 2} options.add_experimental_option("prefs",prefs) driver = webdriver.Chrome(options=options) input_cookies(ACData, link, driver) print(Duplicate(PostGroup,repeatednum)) print(repeatednum) Close() if share_timeline == True: Share1(driver) for a in range(len(PostGroup)): identify1(driver) exception = 0 if a in repeatednum: exception = 1 share2_1(exception,driver,Say,PostGroup,link,a) driver.quit()
def updateGL_combo(self): Group_table = self.ui.Group_table Group_table.setColumnCount(1) Group_table.setRowCount(0) SelectedGroup_table = self.ui.SelectedGroup_table SelectedGroup_table.setColumnCount(1) SelectedGroup_table.setRowCount(0) name = self.ui.ShareUsername_comboBox.currentText() ACID = self.get_ACID(name) GL = Database().get_Group(ACID) for i in range(1, len(GL)): if GL[i] == "END": break else: a = str(GL[i]) c = QTableWidgetItem(a) Group_table.insertRow(Group_table.rowCount()) Group_table.setItem(i - 1, 0, c) header = Group_table.horizontalHeader() header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) Group_table.sortItems(0, QtCore.Qt.AscendingOrder) this_moment = QtCore.QTime.currentTime() self.ui.timeEdit.setTime(this_moment)
def load_info(self): global userlist userlist = Database().get_ACNames(username) for i in userlist: a = i[1] + " / " + i[2] self.ui.Username_comboBox.addItem(a) self.ui.ShareUsername_comboBox.addItem(a)
def remove_entry_clk(self): confirm = QMessageBox.question( self, 'Please Confirm', "Are you sure you want to remove this entry?", QMessageBox.Yes | QMessageBox.No) if confirm == 16384: row = self.ui.scheduler_table.currentRow() schedule_id = str(self.ui.scheduler_table.item(row, 0).text()) self.ui.scheduler_table.removeRow(row) self.ui.scheduler_table.sortItems(2, QtCore.Qt.AscendingOrder) Database().remove_schedule(schedule_id)
def load_info(self): global userlist userlist = Database().get_ACNames(username) for i in userlist: a = i[1] + " / " + i[2] self.ui.ShareUsername_comboBox.addItem(a) this_moment = QtCore.QTime.currentTime() self.ui.timeEdit.setTime(this_moment) ShareEditor.enable_tl() ShareEditor.enable_pl()
def table_refresh_clk(self): ACTable = Database().update_ACTable(username) #Create Empty Table table = self.ui.tableWidget table.setRowCount(len(ACTable)) if ACTable == []: table.setColumnCount(0) else: table.setColumnCount(len(ACTable[0])) Column_name = Database().update_Column_name() horHeaders = [] for m in range(len(ACTable)): for n in range(len(ACTable[m])): horHeaders.append(Column_name[n][0]) a = str(ACTable[m][n]) newitem = QTableWidgetItem(a) table.setItem(m, n, newitem) table.setHorizontalHeaderLabels(horHeaders)
def refresh_table_clk(self): ScheduleTable = Database().update_ScheduleTable(username) table = self.ui.scheduler_table table.setRowCount(len(ScheduleTable)) if ScheduleTable == []: table.setColumnCount(0) else: table.setColumnCount(len(ScheduleTable[0])) Column_name = Database().update_Column_name2() horHeaders = [] for m in range(len(ScheduleTable)): for n in range(len(ScheduleTable[m])): horHeaders.append(Column_name[n][0]) a = str(ScheduleTable[m][n]) newitem = QTableWidgetItem(a) table.setItem(m, n, newitem) table.setHorizontalHeaderLabels(horHeaders) header = table.horizontalHeader() header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
def updateGT_clk(self): try: id = QInputDialog.getText(self, "Change Group Type", "Enter ACID") if any(int(id[0]) in k for k in userlist) == True: group_type = QInputDialog.getText(self, "Change Group Type", "Enter group_type") Database().updateGT(id[0], group_type[0]) self.table_refresh_clk() else: sys.exit() except: msg = QMessageBox() msg.setText("Incorrect ACID") msg.exec()
class Crud: session = Database.getConnection() def createNode(self, *args, **kwargs): node = Node("Employee", **kwargs) # Node label and properties self.session.create(node) # create a single node using session object self.session.commit() return node def createRelationship(self, frm, to, relation): obj = Relationship(frm, relation, to) obj = self.session.create(Relationship(obj)) return obj def getAllNode(self): query = "MATCH (n) return (n)" # Query for Get all Node from databse nodes = self.session.run(query) print("count the record -->>", self.session.evaluate("MATCH (n) RETURN COUNT(n)")) for node in nodes: print(node) return nodes def getSignleNode(self, id): query = "MATCH (n) where id(n)={id} return (n)".format( id=id) # Query for Get single Node from database node = self.session.run(query) return node def updateNode(self): query = "MERGE (n:Employee {name: 'Mehak'})SET n.age = 100, n.coat = 'Yellow' RETURN n" node = self.session.run(query) self.session.commit() return node def deleteNode(self): query = "MATCH (n) DETACH DELETE " nodes = self.session.run(query) return nodes def deleteSingleRelationalNode(self, id): query = "MATCH (n) WHERE id(n)={id} DETACH DELETE (n)".format(id=id) node = self.session.run(query) return node
def Login(username, password, ACID): try: driver.get("https://www.facebook.com/") sleep(2) try: driver.find_element_by_id("email").send_keys(username) try: driver.find_element_by_id("pass").send_keys(password) sleep(3) driver.find_element_by_xpath("//*[@id='loginbutton']").click() except: driver.find_element_by_xpath( '//*[@placeholder="password"]').send_keys(password) sleep(3) driver.find_element_by_xpath("//*[@name='login']").click() except: driver.find_element_by_xpath('//*[@name="email"]').send_keys( username) driver.find_element_by_xpath('//*[@name="password"]').send_keys( password) sleep(3) driver.find_element_by_xpath("//*[@name='login']").click() sleep(2) #Function 2: get Cookies print("Cookies are retrieving") sleep(10) cookies = driver.get_cookies() print(cookies) Database().update_cookies(ACID, json.dumps(cookies)) print('End LoginFaceBookSuccessfully!\n\n') except: print("Error")
def load_entryinfo(self, schedule_id): schedule_entry = Database().retrieve_schedule_entry(schedule_id) self.ui.label_12.setText("Schedule_id: " + schedule_entry[0]) self.ui.schedule_name.setText(schedule_entry[2]) self.ui.share_link.setText(schedule_entry[3]) self.ui.schedule_notes.setText(schedule_entry[4]) self.ui.Enable_cb.setChecked(bool(strtobool(schedule_entry[5]))) self.ui.randomlink_cb.setChecked(bool(strtobool(schedule_entry[6]))) self.ui.randomtime_cb.setChecked(bool(strtobool(schedule_entry[7]))) #add ac ac_data = eval(schedule_entry[8]) Group_table = self.ui.Sharelist Group_table.setColumnCount(5) Group_table.setRowCount(0) Group_table.setHorizontalHeaderLabels( ['Name/Group_type', 'ACID', 'Time', 'Group Count', 'Groups']) for k in ac_data: Group_table.insertRow(Group_table.rowCount()) for i in range(len(k)): c = QTableWidgetItem(str(k[i])) Group_table.setItem(Group_table.rowCount() - 1, i, c) header = Group_table.horizontalHeader() header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) Group_table.sortItems(2, QtCore.Qt.AscendingOrder) #add comment comment_data = eval(schedule_entry[9]) CommentList = self.ui.CommentList CommentList.setColumnCount(1) CommentList.setRowCount(0) for i in range(len(comment_data)): CommentList.insertRow(CommentList.rowCount()) c = QTableWidgetItem(str(comment_data[i])) CommentList.setItem(CommentList.rowCount() - 1, 0, c) header = CommentList.horizontalHeader() CommentList.setHorizontalHeaderLabels(['Comments']) header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) self.ui.CommentList.sortItems(0, QtCore.Qt.AscendingOrder) #add link link_data = eval(schedule_entry[10]) linklist = self.ui.PastlinkList linklist.setColumnCount(1) linklist.setRowCount(0) for i in range(len(link_data)): linklist.insertRow(linklist.rowCount()) c = QTableWidgetItem(str(link_data[i])) linklist.setItem(linklist.rowCount() - 1, 0, c) header = linklist.horizontalHeader() linklist.setHorizontalHeaderLabels(['Links']) header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) self.ui.PastlinkList.sortItems(0, QtCore.Qt.AscendingOrder) #add time time_data = eval(schedule_entry[11]) Timelist = self.ui.Timelist Timelist.setColumnCount(1) Timelist.setRowCount(0) for i in range(len(time_data)): Timelist.insertRow(Timelist.rowCount()) c = QTableWidgetItem(str(time_data[i])) Timelist.setItem(Timelist.rowCount() - 1, 0, c) header = Timelist.horizontalHeader() Timelist.setHorizontalHeaderLabels(['Time']) header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) self.ui.Timelist.sortItems(0, QtCore.Qt.AscendingOrder)
def __init__(self, parent, controller): Frame.__init__(self, parent) self.configure(padx=20, pady=20) self.headingImage = PhotoImage(file="logo.png") self.headingLabel = Label(self, image=self.headingImage, anchor=CENTER) self.headingLabel.grid(row=0, column=0, columnspan=3) self.userNameVar = StringVar() self.userEmailVar = StringVar() self.userPasswordVar = StringVar() self.userAgeVar = IntVar() self.userGenderVar = StringVar() self.userPhoneVar = IntVar() self.userNameEntry = Entry(self, textvariable=self.userNameVar, font=ENTRY_FONT) self.userNameEntry.insert(0, "Full Name") self.userNameEntry.grid(row=1, column=0, columnspan=3, sticky=EW, pady=5) self.userAgeEntry = Entry(self, textvariable=self.userAgeVar, font=ENTRY_FONT) self.userAgeEntry.insert(0, "Age: ") self.userAgeEntry.grid(row=2, column=0, columnspan=2, sticky=EW, pady=5) self.userEmailEntry = Entry(self, textvariable=self.userEmailVar, font=ENTRY_FONT) self.userEmailEntry.insert(0, "*****@*****.**") self.userEmailEntry.grid(row=3, column=0, pady=5) self.userPasswordEntry = Entry(self, show="*", textvariable=self.userPasswordVar, font=ENTRY_FONT) self.userPasswordEntry.insert(0, "Password") self.userPasswordEntry.grid(row=3, column=1, pady=5) self.radioMale = Radiobutton(self, text="MALE", variable=self.userGenderVar, value="Male") self.radioMale.grid(row=4, column=0, pady=5) self.radioFemale = Radiobutton(self, text="FEMALE", variable=self.userGenderVar, value="Female") self.radioFemale.grid(row=4, column=1, pady=5) self.userPhoneEntry = Entry(self, textvariable=self.userPhoneVar, font=ENTRY_FONT) self.userPhoneEntry.insert(0, "Phone Number: ") self.userPhoneEntry.grid(row=5, column=0, columnspan=2, pady=5) self.signUpButton = Button( self, bg="#e53935", fg="white", text="Sign Up", font=ENTRY_FONT, command=lambda: [ Database.Insert( Database, self.userNameVar.get(), self.userAgeVar.get(), self.userPhoneVar.get(), self.userEmailVar.get(), self.userPasswordVar.get(), self.userGenderVar.get()), messagebox.showinfo("", "SIGNUP Sucessful") ]) self.signUpButton.grid(row=6, column=0, pady=5) self.backloginButton = Button( self, bg="#e53935", fg="white", text="Back to Login", font=ENTRY_FONT, command=lambda: controller.showFrame(LoginPage)) self.backloginButton.grid(row=6, column=1, pady=5)
from tkinter import * from tkinter import messagebox from DatabaseConnection import Database import os dataBase = Database() ENTRY_FONT = ("Fira Mono", 16) class SignUpPage(Frame): def __init__(self, parent, controller): Frame.__init__(self, parent) self.configure(padx=20, pady=20) self.headingImage = PhotoImage(file="logo.png") self.headingLabel = Label(self, image=self.headingImage, anchor=CENTER) self.headingLabel.grid(row=0, column=0, columnspan=3) self.userNameVar = StringVar() self.userEmailVar = StringVar() self.userPasswordVar = StringVar() self.userAgeVar = IntVar() self.userGenderVar = StringVar() self.userPhoneVar = IntVar() self.userNameEntry = Entry(self, textvariable=self.userNameVar, font=ENTRY_FONT) self.userNameEntry.insert(0, "Full Name") self.userNameEntry.grid(row=1,
def saveall_clk(self): try: schedule_name = self.ui.schedule_name.text() share_link = self.ui.share_link.text() schedule_notes = self.ui.schedule_notes.text() Enable_cb = self.ui.Enable_cb.isChecked() randomlink_cb = self.ui.randomlink_cb.isChecked() randomtime_cb = self.ui.randomtime_cb.isChecked() ac = [] for row in range(self.ui.Sharelist.rowCount()): ac.append([]) for column in range(self.ui.Sharelist.columnCount()): ac[row].append( str(self.ui.Sharelist.item(row, column).text())) comments = [] for row in range(self.ui.CommentList.rowCount()): comments.append(str(self.ui.CommentList.item(row, 0).text())) links = [] for row in range(self.ui.PastlinkList.rowCount()): links.append(str(self.ui.PastlinkList.item(row, 0).text())) Times = [] for row in range(self.ui.Timelist.rowCount()): Times.append(str(self.ui.Timelist.item(row, 0).text())) if ac == []: msg = QMessageBox() msg.setText("Account list has nothing, are you serious???") msg.exec() sys.exit() elif comments == []: msg = QMessageBox() msg.setText("Dun be lazy, at least should have 1 comment") msg.exec() sys.exit() elif randomlink_cb == True and links == []: msg = QMessageBox() msg.setText( "You have turned on Random Past Link Mode but there hasn't any valid share link. Please fix." ) msg.exec() sys.exit() elif randomtime_cb == True and Times == []: msg = QMessageBox() msg.setText( "You have turned on Random Time Mode but there hasn't anything in the timelist. Please fix." ) msg.exec() sys.exit() elif randomlink_cb == False: try: if requests.get(share_link).status_code == 200: pass except: msg = QMessageBox() msg.setText( "You haven't turned on Random Past Link Mode and you haven't input a valid share link. Please fix." ) msg.exec() sys.exit() Actions_spec = [ schedule_name, share_link, schedule_notes, Enable_cb, randomlink_cb, randomtime_cb, ac, comments, links, Times ] a = self.ui.label_12.text() if a == 'Schedule_id: None': Database().addschedule(username, Actions_spec) else: id = a.split(" ") Database().updateschedule(Actions_spec, id[1]) self.hide() MainWindow.refresh_table_clk() except: pass
from HelperMethods import Helper from CSVParser import ParseCSV from DatabaseConnection import Database helper = Helper() db = Database() class CSVImporter: def __init__(self): self.csv = None def setDataFrame(self): # sets pandas Data Frame csvPath = helper.inputField('\nPlease enter the path to the csv you wish to import >> ') self.csv = ParseCSV(csvPath) self.csv.printColumns() def setImportColumns(self): # allows user to input columns to import csvResponse = helper.inputField( '\nplease enter the columns [0-' + str(self.csv.columnCount-2) + '] you wish to select separated by a comma: >> ') columnsToImport = sorted(list(map(int, csvResponse.split(',')))) columnsCheck = sorted(list(set(range(self.csv.columnCount)).intersection(columnsToImport))) if columnsCheck != columnsToImport: helper.printOutput('You entered one or more invalid columns') return self.setImportColumns() helper.printOutput('\n You selected the following columns:\n') self.csv.printColumns(columnsToImport)
def schedule_table_refresh_clk(self): id = Database().get_ScheduleID(username) schedule_task = [] for i in id: schedule_entry = Database().retrieve_schedule_entry(i[0]) if schedule_entry[5] == 'True': ac_data = eval(schedule_entry[8]) for j in range(len(ac_data)): if schedule_entry[6] == 'False' and schedule_entry[ 7] == 'False': comment = eval(schedule_entry[9]) tasktr = [ ac_data[j][2], schedule_entry[3], schedule_entry[2], schedule_entry[4], ac_data[j][0], ac_data[j][1], ac_data[j][3], ac_data[j][4], random.choice(comment) ] schedule_task.append(tasktr) elif schedule_entry[6] == 'True' and schedule_entry[ 7] == 'False': comment = eval(schedule_entry[9]) link = eval(schedule_entry[10]) tasktr = [ ac_data[j][2], random.choice(link), schedule_entry[2], schedule_entry[4], ac_data[j][0], ac_data[j][1], ac_data[j][3], ac_data[j][4], random.choice(comment) ] schedule_task.append(tasktr) elif schedule_entry[6] == 'False' and schedule_entry[ 7] == 'True': comment = eval(schedule_entry[9]) time = eval(schedule_entry[11]) tasktr = [ random.choice(time), schedule_entry[3], schedule_entry[2], schedule_entry[4], ac_data[j][0], ac_data[j][1], ac_data[j][3], ac_data[j][4], random.choice(comment) ] schedule_task.append(tasktr) elif schedule_entry[6] == 'True' and schedule_entry[ 7] == 'True': comment = eval(schedule_entry[9]) link = eval(schedule_entry[10]) time = eval(schedule_entry[11]) tasktr = [ random.choice(time), random.choice(link), schedule_entry[2], schedule_entry[4], ac_data[j][0], ac_data[j][1], ac_data[j][3], ac_data[j][4], random.choice(comment) ] schedule_task.append(tasktr) table = self.ui.schedule_table table.setRowCount(len(schedule_task)) if schedule_task == []: table.setColumnCount(0) else: table.setColumnCount(len(schedule_task[0])) horHeaders = [ 'Time', 'Share_link', 'Schedule_Name', 'Schedule_Notes', 'Group_Type/Name', 'ACID', 'Group_Count', 'Groups', 'Comments' ] for m in range(len(schedule_task)): for n in range(len(schedule_task[m])): a = str(schedule_task[m][n]) newitem = QTableWidgetItem(a) table.setItem(m, n, newitem) table.setHorizontalHeaderLabels(horHeaders) header = table.horizontalHeader() header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) table.sortItems(0, QtCore.Qt.AscendingOrder)