qr-codes with individual data
This commit is contained in:
parent
76733fd896
commit
7234a330a8
|
@ -1,6 +1,8 @@
|
||||||
import tkinter
|
import tkinter
|
||||||
import threading
|
import threading
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
plt.switch_backend("Agg") # Set the backend dynamically
|
||||||
|
from urllib.parse import urlencode, quote_plus
|
||||||
|
|
||||||
import selenium.webdriver.firefox.service
|
import selenium.webdriver.firefox.service
|
||||||
import webdriver_manager.chrome
|
import webdriver_manager.chrome
|
||||||
|
@ -24,11 +26,11 @@ import requests
|
||||||
import statistics
|
import statistics
|
||||||
from webdriver_manager.firefox import GeckoDriverManager
|
from webdriver_manager.firefox import GeckoDriverManager
|
||||||
|
|
||||||
DropDownLabels = ["Street: ", "Number: ", "Postal code: ", "City: ", "coordinate X", "coordinate Y", "Sonnendach URL: ", "Suitability:", "Image Filename: ", "PV Production 75", "Value Electricity production", "Roof area", "existing PV Production Power", "existing PV Production begining of operation"]
|
DropDownLabels = ["Street: ", "Number: ", "Postal code: ", "City: ", "coordinate X", "coordinate Y", "Sonnendach URL: ", "Suitability:", "Image Filename: ", "PV Production 75", "Value Electricity production", "Roof area", "existing PV Production Power", "existing PV Production begining of operation","id", "firstname", "lastname"]
|
||||||
file_split_char = ","
|
file_split_char = ";"
|
||||||
minRoofSize = 2
|
minRoofSize = 5
|
||||||
minSuitability = 3
|
minSuitability = 3
|
||||||
electricityPrice = 0.198
|
electricityPrice = 0.11556
|
||||||
electricityUsageFactor = 0.75
|
electricityUsageFactor = 0.75
|
||||||
OptionList = []
|
OptionList = []
|
||||||
exit = False
|
exit = False
|
||||||
|
@ -247,8 +249,20 @@ def search_adresses(adress_list, filename_adresslist, driver, mainText):
|
||||||
elif(suitability == 5):
|
elif(suitability == 5):
|
||||||
barchart_color = "#a80000"
|
barchart_color = "#a80000"
|
||||||
|
|
||||||
|
qr_url = "https://nexs.ch/redirect?" + urlencode({
|
||||||
|
"id": adress[columnIndexes[14]],
|
||||||
|
"project": "PJ2505-0014",
|
||||||
|
"target": "https://www.solosolar.ch/de/kontakt?" + urlencode({
|
||||||
|
"firstname": adress[columnIndexes[15]],
|
||||||
|
"lastname": adress[columnIndexes[16]],
|
||||||
|
"adresse": f"{adress[columnIndexes[0]]} {adress[columnIndexes[1]]}",
|
||||||
|
"zip": adress[columnIndexes[2]],
|
||||||
|
"city": adress[columnIndexes[3]]
|
||||||
|
}, quote_via=quote_plus)
|
||||||
|
}, quote_via=quote_plus)
|
||||||
|
|
||||||
create_images(address_string, driver, image_filename, image_folder_map, image_folder_production, image_folder_qrcode, image_folder_barcharts,
|
create_images(address_string, driver, image_filename, image_folder_map, image_folder_production, image_folder_qrcode, image_folder_barcharts,
|
||||||
url, barChartMonth, barChartData, barchart_color)
|
url, barChartMonth, barChartData, barchart_color, qr_url)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
image_filename = "not-created"
|
image_filename = "not-created"
|
||||||
|
@ -352,13 +366,13 @@ def create_roof_info(roofs):
|
||||||
info_text = info_text + str(i + 1) + ". Fläche\n" + "Potenzielle Energie: " + str(roofs[i]['attributes']['gstrahlung']*0.2*0.8) + "\nFläche: " + str(roofs[i]['attributes']['flaeche']) + "\nEignung: " + str(roofs[i]['attributes']['klasse']) + " (" + str(roofs[i]['attributes']['klasse_text']).split("##")[0] + ")\n\n"
|
info_text = info_text + str(i + 1) + ". Fläche\n" + "Potenzielle Energie: " + str(roofs[i]['attributes']['gstrahlung']*0.2*0.8) + "\nFläche: " + str(roofs[i]['attributes']['flaeche']) + "\nEignung: " + str(roofs[i]['attributes']['klasse']) + " (" + str(roofs[i]['attributes']['klasse_text']).split("##")[0] + ")\n\n"
|
||||||
return info_text
|
return info_text
|
||||||
|
|
||||||
def create_images(address_string, driver, image_filename, image_folder_map, image_folder_production, image_folder_qrcode, image_folder_barcharts, url, barChartMonth, barChartData, barchart_color):
|
def create_images(address_string, driver, image_filename, image_folder_map, image_folder_production, image_folder_qrcode, image_folder_barcharts, url, barChartMonth, barChartData, barchart_color, qr_url):
|
||||||
driver.get(url)
|
driver.get(url)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
# Create QR-Code
|
# Create QR-Code
|
||||||
qr = qrcode.QRCode(version=1, box_size=10, border=5)
|
qr = qrcode.QRCode(version=1, box_size=10, border=5)
|
||||||
qr.add_data(url)
|
qr.add_data(qr_url)
|
||||||
qr.make(fit=True)
|
qr.make(fit=True)
|
||||||
qr.make_image(fill='black', back_color='white').save(image_folder_qrcode + image_filename)
|
qr.make_image(fill='black', back_color='white').save(image_folder_qrcode + image_filename)
|
||||||
|
|
||||||
|
@ -367,6 +381,11 @@ def create_images(address_string, driver, image_filename, image_folder_map, imag
|
||||||
try:
|
try:
|
||||||
driver.execute_script("""var l = document.getElementsByClassName("ol-zoom ol-unselectable ol-control")[0];
|
driver.execute_script("""var l = document.getElementsByClassName("ol-zoom ol-unselectable ol-control")[0];
|
||||||
l.parentNode.removeChild(l);""")
|
l.parentNode.removeChild(l);""")
|
||||||
|
|
||||||
|
# Marker entfernen
|
||||||
|
# driver.execute_script("""var l = document.getElementsByClassName("marker ga-crosshair")[0];
|
||||||
|
# l.parentNode.removeChild(l);""")
|
||||||
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -379,12 +398,13 @@ def create_images(address_string, driver, image_filename, image_folder_map, imag
|
||||||
w = x + size["width"]
|
w = x + size["width"]
|
||||||
h = size["height"]
|
h = size["height"]
|
||||||
area = (x, 0, w, h)
|
area = (x, 0, w, h)
|
||||||
driver.execute_script("window.scrollTo(0, " + str(y) + ")")
|
mapElement.screenshot(image_folder_map + image_filename)
|
||||||
time.sleep(1)
|
# driver.execute_script("window.scrollTo(0, " + str(y) + ")")
|
||||||
driver.save_screenshot(image_folder_map + image_filename)
|
# time.sleep(1)
|
||||||
time.sleep(0.2)
|
# driver.save_screenshot(image_folder_map + image_filename)
|
||||||
Image.open(image_folder_map + image_filename).crop(area).save(
|
# time.sleep(0.2)
|
||||||
image_folder_map + image_filename)
|
# Image.open(image_folder_map + image_filename).crop(area).save(
|
||||||
|
# image_folder_map + image_filename)
|
||||||
|
|
||||||
# Create Screenshot of Chart
|
# Create Screenshot of Chart
|
||||||
# try:
|
# try:
|
||||||
|
@ -434,7 +454,7 @@ def create_images(address_string, driver, image_filename, image_folder_map, imag
|
||||||
# plt.xlim(barChartMonth[0], barChartMonth[-1])
|
# plt.xlim(barChartMonth[0], barChartMonth[-1])
|
||||||
|
|
||||||
plt.savefig(f"{image_folder_barcharts}{image_filename}", bbox_inches='tight')
|
plt.savefig(f"{image_folder_barcharts}{image_filename}", bbox_inches='tight')
|
||||||
|
plt.close('all')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
search_string = "Toggenburgstrasse 31 8245 Feuerthalen"
|
search_string = "Pelikanweg 51 3074 Muri b. Bern"
|
||||||
|
|
||||||
#Address to coordinates
|
#Address to coordinates
|
||||||
params={
|
params={
|
||||||
|
|
Loading…
Reference in New Issue