job-scrapper/lib/config.py

57 lines
1.6 KiB
Python
Raw Permalink Normal View History

2024-06-13 09:11:58 +00:00
import time
import configparser
from PySide6.QtWidgets import QDialog,QPushButton, QLineEdit,QVBoxLayout, QLabel
class Entry:
user=0
pw=0
loginurl=0
scrapurl=0
tag=0
def __str__(self):
return "values from Entry: %s %s PW %s %s" %(self.tag,self.user,self.loginurl,self.scrapurl)
def input_pw(self,gui,message,worker):
self.gui=gui
if not self.gui:
self.pw = input("Enter your Password")
if self.gui:
worker.messageContent = self.scrapurl
worker.dialog_closed=False
worker.pwprompt.emit() #signal to mainthread
while not worker.dialog_closed:
time.sleep(1)
pass
self.pw = worker.password
def readConfig(file,gui,worker):
if not hasattr(readConfig,"counter"):
readConfig.counter = -1
print(readConfig.counter)
entry = Entry()
config = configparser.RawConfigParser()
buffer = config.read(file)
print("buffer:",buffer)
sections = config.sections()
if(readConfig.counter < (len(sections)-1)):
readConfig.counter += 1
else:
readConfig.counter = -1
return 0
entry.user = config[sections[readConfig.counter]]["USER"]
entry.pw = config[sections[readConfig.counter]]["PW"]
entry.scrapurl = config[sections[readConfig.counter]]["SCRAPURL"]
entry.tag = config[sections[readConfig.counter]]["TAG"]
if(entry.user != 0):
if(entry.pw == "ASK"):
entry.input_pw(gui,entry.user,worker)
entry.loginurl = config[sections[readConfig.counter]]["LOGINURL"]
print(entry)
return entry