implement cancel button to cancel login profedure and continue with the
next entry
This commit is contained in:
parent
83e0d81ebe
commit
e0e54adb5d
@ -18,7 +18,7 @@ class Entry:
|
|||||||
if self.gui:
|
if self.gui:
|
||||||
worker.messageContent = self.scrapurl
|
worker.messageContent = self.scrapurl
|
||||||
worker.dialog_closed=False
|
worker.dialog_closed=False
|
||||||
worker.pwprompt.emit() #signal to mainthread
|
worker.pwprompt.emit() #signal to mainthread run showDialog and wait for close
|
||||||
while not worker.dialog_closed:
|
while not worker.dialog_closed:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
pass
|
pass
|
||||||
|
@ -91,8 +91,10 @@ def writedb(jobs):
|
|||||||
log(hash1);
|
log(hash1);
|
||||||
if(cursor.execute("SELECT * FROM jobs WHERE hash = ?",(hash1,)).fetchone() != None):
|
if(cursor.execute("SELECT * FROM jobs WHERE hash = ?",(hash1,)).fetchone() != None):
|
||||||
log("Hash already exist")
|
log("Hash already exist")
|
||||||
|
elif(cursor.execute("SELECT * FROM jobs where link = ?",(job.link,)).fetchone() != None):
|
||||||
|
log("link already exist")
|
||||||
else:
|
else:
|
||||||
print("NEW_ENTRY")
|
log("NEW_ENTRY")
|
||||||
cursor.execute("INSERT INTO jobs (star,tag,title,company,location,link,pubdate,hash,viewed) VALUES (?,?,?,?,?,?,?,?,?)",(job.starred,job.tag,job.title,job.company,job.location,job.link,job.date,hash1,0))
|
cursor.execute("INSERT INTO jobs (star,tag,title,company,location,link,pubdate,hash,viewed) VALUES (?,?,?,?,?,?,?,?,?)",(job.starred,job.tag,job.title,job.company,job.location,job.link,job.date,hash1,0))
|
||||||
|
|
||||||
def viewedEntry(hash1):
|
def viewedEntry(hash1):
|
||||||
|
30
lib/gui.py
30
lib/gui.py
@ -9,6 +9,11 @@ import sys
|
|||||||
import db as db
|
import db as db
|
||||||
from qsqlmod import SqlQueryModel_editable
|
from qsqlmod import SqlQueryModel_editable
|
||||||
|
|
||||||
|
DEBUG = True
|
||||||
|
def log(*s):
|
||||||
|
if DEBUG:
|
||||||
|
print(s)
|
||||||
|
|
||||||
DBFILE = "../db/sqlite3.db"
|
DBFILE = "../db/sqlite3.db"
|
||||||
|
|
||||||
Cantons = ["AG","ZH","BE","SG","SO"]
|
Cantons = ["AG","ZH","BE","SG","SO"]
|
||||||
@ -22,12 +27,9 @@ class ColorDelegate(QStyledItemDelegate):
|
|||||||
print("initialice overload init of ColorDelegate")
|
print("initialice overload init of ColorDelegate")
|
||||||
self.main = main
|
self.main = main
|
||||||
def initStyleOption(self,option,index):
|
def initStyleOption(self,option,index):
|
||||||
#we have to rewrite this because it depends on viewport but it should depend on the model
|
|
||||||
super().initStyleOption(option,index)
|
super().initStyleOption(option,index)
|
||||||
data = index.data()
|
data = index.data()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
#flag_viewed = self.main.model.index(index.row(),8).data()
|
|
||||||
#flag_starred = self.main.model.index(index.row(),0).data()
|
|
||||||
flag_viewed = self.main.sel_model.model().index(index.row(),8).data()
|
flag_viewed = self.main.sel_model.model().index(index.row(),8).data()
|
||||||
try:
|
try:
|
||||||
flag_starred = int(self.main.sel_model.model().index(index.row(),0).data())
|
flag_starred = int(self.main.sel_model.model().index(index.row(),0).data())
|
||||||
@ -35,11 +37,10 @@ class ColorDelegate(QStyledItemDelegate):
|
|||||||
print("probably empty string asign zero")
|
print("probably empty string asign zero")
|
||||||
flag_starred = 0
|
flag_starred = 0
|
||||||
|
|
||||||
print("index:",index)
|
#print("index:",index)
|
||||||
print("column ",column)
|
#print("column ",column)
|
||||||
print("data:", flag_starred)
|
#print("data:", flag_starred)
|
||||||
if flag_starred == 1:
|
if flag_starred == 1:
|
||||||
print("Starred!!!!!")
|
|
||||||
option.backgroundBrush = QtGui.QColor("red")
|
option.backgroundBrush = QtGui.QColor("red")
|
||||||
elif flag_viewed != 1:
|
elif flag_viewed != 1:
|
||||||
option.backgroundBrush = QtGui.QColor("green")
|
option.backgroundBrush = QtGui.QColor("green")
|
||||||
@ -89,6 +90,7 @@ class Worker(QObject):
|
|||||||
pw = Signal(str)
|
pw = Signal(str)
|
||||||
finished = Signal()
|
finished = Signal()
|
||||||
dialog_closed = True
|
dialog_closed = True
|
||||||
|
dialog_rejected = False
|
||||||
password = ['empty']
|
password = ['empty']
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
@ -123,13 +125,6 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
editables = {0 : ("UPDATE jobs SET star = '{}' WHERE hash = '{}'",7)}
|
editables = {0 : ("UPDATE jobs SET star = '{}' WHERE hash = '{}'",7)}
|
||||||
self.model = SqlQueryModel_editable(editables)
|
self.model = SqlQueryModel_editable(editables)
|
||||||
#self.model.setTable("jobs")
|
|
||||||
#self.model.setEditStrategy(QSqlTableModel.OnFieldChange)
|
|
||||||
#self.model.select()
|
|
||||||
|
|
||||||
#self.proxymodel2 = QSortFilterProxyModel(self)
|
|
||||||
#self.proxymodel2.setSourceModel(self.model)
|
|
||||||
#self.proxymodel2.setTable("jobs")
|
|
||||||
|
|
||||||
self.view = QTableView()
|
self.view = QTableView()
|
||||||
self.view.setModel(self.model)
|
self.view.setModel(self.model)
|
||||||
@ -211,12 +206,13 @@ class MainWindow(QMainWindow):
|
|||||||
w = PWPrompt()
|
w = PWPrompt()
|
||||||
w.set_MSG(self.worker.messageContent)
|
w.set_MSG(self.worker.messageContent)
|
||||||
ret = w.exec()
|
ret = w.exec()
|
||||||
|
if ret == QDialog.Rejected:
|
||||||
|
self.worker.dialog_rejected = True
|
||||||
|
log("[gui] qdialog.rejected set to TRUE")
|
||||||
self.pw = w.pw
|
self.pw = w.pw
|
||||||
self.worker.password = w.pw
|
self.worker.password = w.pw
|
||||||
print("showDialog,self.pw:",self.pw)
|
log("showDialog,self.pw:",self.pw)
|
||||||
self.worker.dialog_closed=True
|
self.worker.dialog_closed=True
|
||||||
if ret == QDialog.Rejected:
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def showQueryWindow(self,checked):
|
def showQueryWindow(self,checked):
|
||||||
if self.w is None:
|
if self.w is None:
|
||||||
|
@ -45,7 +45,7 @@ def scrap_indeed_com(url,entry,session):
|
|||||||
def scrap_jobs(url,entry,session):
|
def scrap_jobs(url,entry,session):
|
||||||
jobs = []
|
jobs = []
|
||||||
log("in scrap jobs,url",url)
|
log("in scrap jobs,url",url)
|
||||||
if(session == 0):
|
if(session == 0 or session == -1):
|
||||||
with requests.Session() as session:
|
with requests.Session() as session:
|
||||||
page = session.get(url)
|
page = session.get(url)
|
||||||
log(page)
|
log(page)
|
||||||
@ -157,7 +157,7 @@ def next_url_jobagent(base_url,session,c):#depreacted will be removed in the fut
|
|||||||
def scrap_jobagent(url,entry,session):
|
def scrap_jobagent(url,entry,session):
|
||||||
jobs = []
|
jobs = []
|
||||||
log("in scrap jobs,url",url)
|
log("in scrap jobs,url",url)
|
||||||
if(session == 0):
|
if(session == 0 or session == -1):
|
||||||
with requests.Session() as session:
|
with requests.Session() as session:
|
||||||
page = session.get(url)
|
page = session.get(url)
|
||||||
log(page)
|
log(page)
|
||||||
|
@ -7,7 +7,7 @@ from login import *
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
from db import *
|
from db import *
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = True
|
||||||
def log(*s):
|
def log(*s):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print(s)
|
print(s)
|
||||||
@ -76,15 +76,18 @@ def login_loop(config_file,gui,worker):
|
|||||||
ret_login = 0
|
ret_login = 0
|
||||||
session = 0
|
session = 0
|
||||||
while (ret != 0):
|
while (ret != 0):
|
||||||
|
worker.dialog_rejected = False
|
||||||
ret = entry2 = config.readConfig(config_file,gui,worker)
|
ret = entry2 = config.readConfig(config_file,gui,worker)
|
||||||
print(entry2)
|
print(entry2)
|
||||||
if(ret != 0 and ret_login != 1):
|
if(ret != 0 and ret_login != 1):
|
||||||
if(entry2.loginurl != 'NONE'):
|
if(entry2.loginurl != 'NONE'):
|
||||||
session = -1
|
session = -1
|
||||||
while session == -1:
|
log("[pre while] worker.dialog_rejected = ",worker.dialog_rejected)
|
||||||
|
while (session == -1 and worker.dialog_rejected == False):
|
||||||
|
log("worker.dialog_rejected = ",worker.dialog_rejected)
|
||||||
session = login(entry2)
|
session = login(entry2)
|
||||||
if session == -1:
|
|
||||||
ret_login = entry2.input_pw(gui,entry2.user,worker)
|
ret_login = entry2.input_pw(gui,entry2.user,worker)
|
||||||
|
if worker.dialog_rejected == False:
|
||||||
choose_scraper(entry2,session)
|
choose_scraper(entry2,session)
|
||||||
|
|
||||||
def runner(entry,session,scrap_func,next_url_func):
|
def runner(entry,session,scrap_func,next_url_func):
|
||||||
|
Loading…
Reference in New Issue
Block a user