From 4cf2f38745b4ff01f61133ebc20f817d0d2e7cc4 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Wed, 27 Jul 2022 18:22:58 +0200 Subject: [PATCH] removed old files. --- RenameFiles.py | 21 ------- Screenshot_test.py | 134 --------------------------------------------- 2 files changed, 155 deletions(-) delete mode 100644 RenameFiles.py delete mode 100644 Screenshot_test.py diff --git a/RenameFiles.py b/RenameFiles.py deleted file mode 100644 index 7930c3c..0000000 --- a/RenameFiles.py +++ /dev/null @@ -1,21 +0,0 @@ -import os -import shutil -import tkinter -from tkinter import filedialog - -root = tkinter.Tk() -print("select List File:") -filename_Filelist = filedialog.askopenfilename() -print("select Directory:") -filename_Directory = filedialog.askdirectory() -root.withdraw -print(filename_Directory) -adress_file = open(filename_Filelist, "r") -address_list = adress_file.read().splitlines() - -for adress in address_list: - filenames = adress.split(",") - try: - os.rename(filename_Directory + "/" + filenames[0], filename_Directory + "/" + filenames[1]) - except: - print("Failed Renaming File: " + filenames[0]) \ No newline at end of file diff --git a/Screenshot_test.py b/Screenshot_test.py deleted file mode 100644 index aac0173..0000000 --- a/Screenshot_test.py +++ /dev/null @@ -1,134 +0,0 @@ -from selenium import webdriver -from selenium.webdriver.chrome.service import Service -from webdriver_manager.chrome import ChromeDriverManager -from selenium.webdriver.common.by import By -from selenium.webdriver.common.keys import Keys -import time -from PIL import Image -import os -import qrcode -from selenium.webdriver.common.action_chains import ActionChains - -file_split_char = "," -filename_adresslist = "GWR-Daten Schaffhausen.csv" -adress_file = open(filename_adresslist, "r") -adress_list = adress_file.read().splitlines() -adress_file.close() -s = Service(ChromeDriverManager().install()) -driver = webdriver.Chrome(service=s) -driver.minimize_window() -driver.maximize_window() -driver.get("https://www.uvek-gis.admin.ch/BFE/sonnendach/") -driver.implicitly_wait(5) - -try: - if(not os.path.exists("screenshots")): - os.makedirs("screenshots", exist_ok=False) - if (not os.path.exists("qrcodes")): - os.makedirs("qrcodes", exist_ok=False) - for i in range(len(adress_list)): - line = adress_list[i] - print(line) - adress = line.split(file_split_char) - if((line != adress_list[0]) & ((adress[20][0:11] != "screenshots"))): - print(adress) - search_string = adress[15] + " " + adress[3] + " " + adress[11] + " " + adress[13] - print(search_string) - search_bar = driver.find_element(By.ID, "searchTypeahead1") - search_bar.send_keys(Keys.CONTROL + "a") - search_bar.send_keys(Keys.DELETE) - search_bar.send_keys(search_string) - driver.implicitly_wait(10) - - found = False - suggestions = driver.find_elements(By.XPATH, "//div[@class='tt-suggestion tt-selectable']") - for suggestion in suggestions: - if(suggestion.text == search_string): - found = True - suggestion.click() - driver.implicitly_wait(120) - break - - if(found): - print("found") - time.sleep(2) - url = driver.current_url - eignung = driver.find_element(By.ID, "eignung") - image_filename = eignung.text + " - " + search_string - - adress[18] = url - adress[19] = eignung.text - adress[20] = image_filename - - #adress_file = open(filename_adresslist, "w") - new_line_string = "" - for j in adress: - new_line_string = new_line_string + j + file_split_char - adress_list[i] = new_line_string - new_adress_list = "" - for j in adress_list: - new_adress_list = new_adress_list + (j) + "\n" - #adress_file.write(new_adress_list) - #adress_file.close() - - print("start") - - # Create QR-Code - qr = qrcode.QRCode(version=1, box_size=10, border=5) - qr.add_data(url) - qr.make(fit=True) - qr.make_image(fill='black', back_color='white').save( - "qrcodes/" + image_filename + "production" + ".png") - - # Create Screenshot - actions = ActionChains(driver) - try: - driver.execute_script("""var l = document.getElementsByClassName("ol-zoom ol-unselectable ol-control")[0]; - l.parentNode.removeChild(l);""") - except: - pass - - mapElement = driver.find_element(By.XPATH, - "//div[@id='map']//div[@class='ol-viewport']") - location = mapElement.location - size = mapElement.size - x = location["x"] - y = location["y"] - w = x + size["width"] - h = size["height"] - area = (x, 0, w, h) - driver.execute_script("window.scrollTo(0, " + str(y) + ")") - time.sleep(1) - driver.save_screenshot("screenshots/" + image_filename + "map" + ".png") - time.sleep(0.2) - Image.open("screenshots/" + image_filename + "map" + ".png").crop(area).save("screenshots/" + image_filename + "map" + ".png") - - #take Screenshot 2 - chartElement = driver.find_elements(By.XPATH, "//div[@id='chart']//*")[0] - location = chartElement.location - size = chartElement.size - x = location["x"] - y = location["y"] - w = x + size["width"] - h = size["height"] - area = (x, 0, w, h) - driver.execute_script("window.scrollTo(0, " + str(y) + ")") - print("X: " + str(x) + " Y: "+ str(y) + " W: "+ str(w) + " H: " + str(h)) - - time.sleep(1) - driver.save_screenshot("screenshots/" + image_filename + "production" + ".png") - time.sleep(0.2) - Image.open("screenshots/" + image_filename + "production" + ".png").crop(area).save("screenshots/" + image_filename + "production" + ".png") - - - print("stop") - - - print(image_filename + " was saved.") - else: - print("not found: " + search_string) - if(input("Enter zum fortfahren") == "exit"): - break -except Exception as e: - print(str(e)) -driver.quit() \ No newline at end of file