def getProxyIPsFromDB(self): self.dbSession = dbSession() proxies = self.dbSession.query(Proxy).all() if len(proxies) > 0: self.proxyTableWidget.setRowCount(len(proxies)) self.proxyTableWidget.setEnabled(False) for currentRowCount, proxy in enumerate(proxies): self.proxyTableWidget.setItem(currentRowCount, 0, QTableWidgetItem(proxy.ip)) self.proxyTableWidget.setItem(currentRowCount, 1, QTableWidgetItem(proxy.port)) self.proxyTableWidget.setItem(currentRowCount, 2, QTableWidgetItem(proxy.type)) if proxy.active is 1: self.proxyTableWidget.setItem(currentRowCount, 3, QTableWidgetItem('Active')) self.proxyTableWidget.item(currentRowCount, 3).setBackground( QColor(43, 228, 55)) else: self.proxyTableWidget.setItem(currentRowCount, 3, QTableWidgetItem('Inactive')) self.proxyTableWidget.item(currentRowCount, 3).setBackground( QColor(229, 70, 70)) self.proxyTableWidget.setEnabled(True) self.dbSession.close()
def newProfileDataSave(self): self.clCreateProfileSaveBtn.setEnabled(False) self.clCreateProfileSaveBtn.setText("Saving profile") self.dbSession = dbSession() profile = Profile( name=self.clProfileNameLineEdit.text(), selected_location=self.profileDataDict['selected_location'], selected_sub_location=self. profileDataDict['selected_sub_location'], selected_post_url=self.profileDataDict['selected_post_url'], active=1) self.dbSession.add(profile) self.dbSession.flush() profilePickerList = [] for count, profilePicker in enumerate(self.profilePickerDataDict): profilePickerList.append( Profilepicker(profile_id=profile.id, order=count + 1, url=profilePicker['url'], selected_value=profilePicker['value'], selected_text=profilePicker['text'])) self.dbSession.add_all(profilePickerList) self.dbSession.commit() self.dbSession.close() self.clCreateProfileSaveBtn.setText("Saved Successfully!") time.sleep(2) dialog.close()
def uploadedProxyFile(self): selectedIPVersion = self.proxyIPVersionComboBox.itemData( self.proxyIPVersionComboBox.currentIndex()) if selectedIPVersion != "": self.fileBrowserDialogProgram = FileBrowserDialogProgram() file = self.fileBrowserDialogProgram.openFileNameDialog( "Text File (*.txt)") if file != "": prevProxyDelStatus = self.proxyDeletePrevCheckBox.isChecked() if prevProxyDelStatus is True: self.dbSession = dbSession() self.dbSession.execute('''DELETE FROM proxies''') self.dbSession.commit() self.dbSession.close() self.saveProxyIPsToDBThread = threading.Thread( target=self.saveProxyDataToDB, args=(file, selectedIPVersion)) self.saveProxyIPsToDBThread.daemon = True self.saveProxyIPsToDBThread.start() else: self.showMessageDialog("error", "No file found!") else: self.showMessageDialog("warning", "No IP Version selected!")
def getProfiles(self): self.dbSession = dbSession() profiles = self.dbSession.query(Profile).filter( Profile.active == 1).order_by(Profile.id.desc()).all() for profile in profiles: item = QtWidgets.QListWidgetItem(profile.name) item.setData(QtCore.Qt.UserRole, profile.id) self.clProfileListWidget.addItem(item) self.clProfileListWidget.itemClicked.connect( self.profileItemChangeEvent)
def fetchOnlineProxyDataEvent(self): prevProxyDelStatus = self.proxyDeletePrevCheckBox.isChecked() if prevProxyDelStatus is True: self.dbSession = dbSession() self.dbSession.execute('''DELETE FROM proxies''') self.dbSession.commit() self.dbSession.close() self.fetchOnlineProxyDataThread = threading.Thread( target=self.fetchOnlineProxyData) self.fetchOnlineProxyDataThread.daemon = True self.fetchOnlineProxyDataThread.start()
def addLocationItems(self): self.dbSession = dbSession() locations = self.dbSession.query(Location).order_by( asc(Location.location)).all() self.clLocationComboBox.clear() # self.clLocationComboBox.addItem("Select", "") if len(locations) > 0: for location in locations: self.clLocationComboBox.addItem(location.location, location.location) self.dbSession.close()
def newProfileDataSaveEvent(self): if self.clProfileNameLineEdit.text() != "": self.dbSession = dbSession() profiles = self.dbSession.query(Profile).filter( Profile.name == self.clProfileNameLineEdit.text()).all() self.dbSession.close() if len(profiles) < 1: self.newProfileDataSaveThread = threading.Thread( target=self.newProfileDataSave) self.newProfileDataSaveThread.daemon = True self.newProfileDataSaveThread.start() else: self.showMessageDialog("warning", "Profile name already exist!") else: self.showMessageDialog("warning", "Profile name cannot be empty!")
def fetchOnlineProxyData(self): self.proxyUploadPushButton.setEnabled(False) self.proxyFetchPushButton.setEnabled(False) self.proxyIPVersionComboBox.setEnabled(False) self.proxyDeletePrevCheckBox.setEnabled(False) self.proxyFetchPushButton.setText("Fetching...") fetchOnlineProxies = FetchOnlineProxies() fetchOnlineProxies.proxyCount = 100 fetchOnlineProxies.countries = ['US'] fetchOnlineProxies.types = ['SOCKS4', 'SOCKS5'] fetchedProxyList = fetchOnlineProxies.getProxies( self.loop, self.proxyFetchPushButton) self.dbSession = dbSession() proxyList = [] for count, ipPortList in enumerate(fetchedProxyList): self.proxyFetchPushButton.setText("Saving (" + str(count) + "/" + str(len(fetchedProxyList)) + ")") proxy = self.dbSession.query(Proxy).filter( Proxy.ip == ipPortList['host'], Proxy.port == ipPortList['port'], Proxy.type == ipPortList['type']).all() if len(proxy) < 1: proxyList.append( Proxy(ip=ipPortList['host'], port=ipPortList['port'], type=ipPortList['type'], active=1)) self.dbSession.add_all(proxyList) self.dbSession.commit() self.dbSession.close() self.proxyFetchPushButton.setText("Fetch Online") self.proxyUploadPushButton.setEnabled(True) self.proxyFetchPushButton.setEnabled(True) self.proxyIPVersionComboBox.setEnabled(True) self.proxyDeletePrevCheckBox.setEnabled(True) self.getProxyIPsFromDB()
def addSubLocationItems(self): selectedLocation = self.clLocationComboBox.itemData( self.clLocationComboBox.currentIndex()) # saving selected location in profileDataDict self.profileDataDict['selected_location'] = selectedLocation self.dbSession = dbSession() location = self.dbSession.query(Location) \ .filter(Location.location == str(selectedLocation)) \ .filter(Location.active == 1) \ .order_by(asc(Location.location)).first() subLocationDict = json.loads(location.sub_location) self.clSubLocationComboBox.clear() # self.clSubLocationComboBox.addItem("Select", "") for subLocation in subLocationDict: self.clSubLocationComboBox.addItem(subLocation['location'], subLocation['link']) self.clSubLocationLbl.setVisible(True) self.clSubLocationComboBox.setVisible(True)
def saveLocData(self, locationUrlDictJsonData): locationUrlDict = json.loads(locationUrlDictJsonData) if len(locationUrlDict) > 0: self.downloadLocPushButton.setText("Deleting Previous all") self.dbSession = dbSession() self.dbSession.execute('''DELETE FROM locations''') self.dbSession.commit() locationObjList = [] for count, location in enumerate(locationUrlDict): self.downloadLocPushButton.setText("Saving (" + str(count) + "/" + str(len(locationUrlDict)) + ")") locationObjList.append( Location(location=location, sub_location=json.dumps( locationUrlDict[location]), active=1)) self.dbSession.add_all(locationObjList) self.dbSession.commit() self.dbSession.close()
def saveProxyDataToDB(self, file, selectedIPVersion): self.proxyUploadPushButton.setEnabled(False) self.proxyFetchPushButton.setEnabled(False) self.proxyIPVersionComboBox.setEnabled(False) self.proxyDeletePrevCheckBox.setEnabled(False) self.proxyUploadPushButton.setText("Uploading...") ipPortMultiList = [ line.strip('\n').split(':') for line in open(file, 'r') ] self.dbSession = dbSession() proxyList = [] for count, ipPortList in enumerate(ipPortMultiList): self.proxyUploadPushButton.setText("Saving (" + str(count) + "/" + str(len(ipPortMultiList)) + ")") proxy = self.dbSession.query(Proxy).filter( Proxy.ip == ipPortList[0], Proxy.port == ipPortList[1], Proxy.type == selectedIPVersion).all() if len(proxy) < 1: proxyList.append( Proxy(ip=ipPortList[0], port=ipPortList[1], type=selectedIPVersion, active=1)) self.dbSession.add_all(proxyList) self.dbSession.commit() self.dbSession.close() self.proxyUploadPushButton.setText("Upload") self.proxyUploadPushButton.setEnabled(True) self.proxyFetchPushButton.setEnabled(True) self.proxyIPVersionComboBox.setEnabled(True) self.proxyDeletePrevCheckBox.setEnabled(True) self.getProxyIPsFromDB()
def getProxy(self): self.dbSession = dbSession() proxy = self.dbSession.query(Proxy).filter_by(active=1).first() self.dbSession.close() return proxy
def inactiveProxy(self, proxy): self.dbSession = dbSession() proxy.active = 0 self.dbSession.add(proxy) self.dbSession.commit() self.dbSession.close()