forked from Silias-Public/Sonnendach
added check if adress has empty fields. (Street, Number, Postal Code, City) Skip adress if one of those fields is empty.
This commit is contained in:
parent
7a3ba625d3
commit
58bb85660a
9
Main.py
9
Main.py
|
@ -20,8 +20,8 @@ stopThread = False
|
||||||
filename_adresslist = ""
|
filename_adresslist = ""
|
||||||
adresslist = ""
|
adresslist = ""
|
||||||
step = 0
|
step = 0
|
||||||
s = Service(ChromeDriverManager().install())
|
service = Service(ChromeDriverManager().install())
|
||||||
driver = webdriver.Chrome(service=s)
|
driver = webdriver.Chrome(service=service)
|
||||||
driver.minimize_window()
|
driver.minimize_window()
|
||||||
outputtext = "Welcome to application Sonnendach\n"
|
outputtext = "Welcome to application Sonnendach\n"
|
||||||
columnIndexes = []
|
columnIndexes = []
|
||||||
|
@ -33,15 +33,17 @@ def search_adresses(adress_list, filename_adresslist, driver):
|
||||||
global stopThread
|
global stopThread
|
||||||
global columnIndexes
|
global columnIndexes
|
||||||
|
|
||||||
|
#Create Direcotrys to save screenshots and qrcodes if they don't exist yet.
|
||||||
if(not os.path.exists("screenshots")):
|
if(not os.path.exists("screenshots")):
|
||||||
os.makedirs("screenshots", exist_ok=False)
|
os.makedirs("screenshots", exist_ok=False)
|
||||||
if (not os.path.exists("qrcodes")):
|
if (not os.path.exists("qrcodes")):
|
||||||
os.makedirs("qrcodes", exist_ok=False)
|
os.makedirs("qrcodes", exist_ok=False)
|
||||||
|
|
||||||
|
#Search for each adress in the list and create screenshots and qrcodes
|
||||||
for i in range(len(adress_list)):
|
for i in range(len(adress_list)):
|
||||||
line = adress_list[i]
|
line = adress_list[i]
|
||||||
adress = line.split(file_split_char)
|
adress = line.split(file_split_char)
|
||||||
if((line != adress_list[0]) & ((adress[columnIndexes[4]] == ""))):
|
if((line != adress_list[0]) & (adress[columnIndexes[4]] == "") & (len((adress[columnIndexes[0]]) > 0)) & (len(adress[columnIndexes[1]] > 0)) & (len(adress[columnIndexes[2]] > 0)) & (len(adress[columnIndexes[3]] > 0))):
|
||||||
print(adress)
|
print(adress)
|
||||||
search_string = adress[columnIndexes[0]] + " " + adress[columnIndexes[1]] + " " + adress[columnIndexes[2]] + " " + adress[columnIndexes[3]]
|
search_string = adress[columnIndexes[0]] + " " + adress[columnIndexes[1]] + " " + adress[columnIndexes[2]] + " " + adress[columnIndexes[3]]
|
||||||
search_bar = driver.find_element(By.ID, "searchTypeahead1")
|
search_bar = driver.find_element(By.ID, "searchTypeahead1")
|
||||||
|
@ -61,7 +63,6 @@ def search_adresses(adress_list, filename_adresslist, driver):
|
||||||
|
|
||||||
if(found):
|
if(found):
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
# TODO: Validation
|
|
||||||
url = driver.current_url
|
url = driver.current_url
|
||||||
eignung = driver.find_element(By.ID, "eignung").text
|
eignung = driver.find_element(By.ID, "eignung").text
|
||||||
pv_Production50 = driver.find_element(By.ID, "pv50").text.replace("'", "")
|
pv_Production50 = driver.find_element(By.ID, "pv50").text.replace("'", "")
|
||||||
|
|
|
@ -10,11 +10,11 @@ print("select Directory:")
|
||||||
filename_Directory = filedialog.askdirectory()
|
filename_Directory = filedialog.askdirectory()
|
||||||
root.withdraw
|
root.withdraw
|
||||||
print(filename_Directory)
|
print(filename_Directory)
|
||||||
adress_file = open(filename_Filelist, "r", encoding='utf-8')
|
adress_file = open(filename_Filelist, "r")
|
||||||
address_list = adress_file.read().splitlines()
|
address_list = adress_file.read().splitlines()
|
||||||
|
|
||||||
for adress in address_list:
|
for adress in address_list:
|
||||||
filenames = adress.split(";")
|
filenames = adress.split(",")
|
||||||
try:
|
try:
|
||||||
os.rename(filename_Directory + "/" + filenames[0], filename_Directory + "/" + filenames[1])
|
os.rename(filename_Directory + "/" + filenames[0], filename_Directory + "/" + filenames[1])
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in New Issue