aggiunta bolletta windtre
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,6 @@
|
|||||||
|
windtre.py
|
||||||
|
prova.py
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|||||||
69
agsm.py
69
agsm.py
@@ -49,6 +49,9 @@ passwdacq = config.passwdacq
|
|||||||
loginds = config.loginds
|
loginds = config.loginds
|
||||||
passds = config.passds
|
passds = config.passds
|
||||||
|
|
||||||
|
loginw3 = config.loginw3
|
||||||
|
passwdw3 = config.passwdw3
|
||||||
|
|
||||||
diskstation = config.diskstation
|
diskstation = config.diskstation
|
||||||
|
|
||||||
url = 'https://countbox.agsm.it/'
|
url = 'https://countbox.agsm.it/'
|
||||||
@@ -247,14 +250,6 @@ def agsmenergia():
|
|||||||
zabbix_send('agsmenergia',0)
|
zabbix_send('agsmenergia',0)
|
||||||
|
|
||||||
def acqueveronesi():
|
def acqueveronesi():
|
||||||
if platform.node() == 'ds7':
|
|
||||||
try:
|
|
||||||
subprocess.run(["docker","start", "SeleniumGrid"])
|
|
||||||
time.sleep(30)
|
|
||||||
zabbix_send('dockerstart',1)
|
|
||||||
except:
|
|
||||||
logger.error('Avvio docker fallito')
|
|
||||||
zabbix_send('dockerstart',0)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
firefox_options = webdriver.FirefoxOptions()
|
firefox_options = webdriver.FirefoxOptions()
|
||||||
@@ -295,14 +290,52 @@ def acqueveronesi():
|
|||||||
importo = importo.replace('€. ','')
|
importo = importo.replace('€. ','')
|
||||||
print('Sacchi', importo)
|
print('Sacchi', importo)
|
||||||
client1.publish('bollette/sacchi/acqua', importo, qos=0,retain=True) #publish
|
client1.publish('bollette/sacchi/acqua', importo, qos=0,retain=True) #publish
|
||||||
driver.quit()
|
|
||||||
if platform.node() == 'ds7':
|
|
||||||
subprocess.run(["docker","stop", "SeleniumGrid"])
|
|
||||||
zabbix_send('acqueveronesi',1)
|
zabbix_send('acqueveronesi',1)
|
||||||
except:
|
except:
|
||||||
logger.error('Qualcosa è andato storto con acque veronesi')
|
logger.error('Qualcosa è andato storto con acque veronesi')
|
||||||
zabbix_send('acqueveronesi',0)
|
zabbix_send('acqueveronesi',0)
|
||||||
|
|
||||||
|
def windtre():
|
||||||
|
url = 'https://areaclienti.windtre.it/login'
|
||||||
|
urlconto = 'https://areaclienti.windtre.it/phx/fixed/conto'
|
||||||
|
|
||||||
|
try:
|
||||||
|
firefox_options = webdriver.FirefoxOptions()
|
||||||
|
driver = webdriver.Remote(
|
||||||
|
command_executor='http://ds7.romito.net:4444',
|
||||||
|
options=firefox_options
|
||||||
|
)
|
||||||
|
driver.set_page_load_timeout(10)
|
||||||
|
driver.get(url)
|
||||||
|
time.sleep(10)
|
||||||
|
try:
|
||||||
|
driver.find_element_by_id('close').click()
|
||||||
|
print('accetto cookie!')
|
||||||
|
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
driver.find_element_by_id('username').send_keys(loginw3)
|
||||||
|
driver.find_element_by_id ('password').send_keys(passwdw3)
|
||||||
|
driver.find_element_by_class_name('btn-login').click()
|
||||||
|
|
||||||
|
time.sleep(10)
|
||||||
|
|
||||||
|
driver.get(urlconto)
|
||||||
|
time.sleep(10)
|
||||||
|
l = driver.find_element_by_class_name('invoice-table')
|
||||||
|
|
||||||
|
importo = re.search(r"[0-9][0-9],[0-9][0-9]", l.text).group()
|
||||||
|
|
||||||
|
print(importo)
|
||||||
|
client1= paho.Client("control1") #create client object
|
||||||
|
client1.on_publish = on_publish #assign function to callback
|
||||||
|
client1.connect(mqttbroker,mqttport) #establish connection
|
||||||
|
client1.publish('bollette/sacchi/windtre', importo, qos=0,retain=True)
|
||||||
|
zabbix_send('windtre',1)
|
||||||
|
except:
|
||||||
|
zabbix_send('windtre',0)
|
||||||
|
driver.quit()
|
||||||
|
|
||||||
def zabbix_send(item,dato):
|
def zabbix_send(item,dato):
|
||||||
# Send metrics to zabbix trapper
|
# Send metrics to zabbix trapper
|
||||||
@@ -315,4 +348,18 @@ def zabbix_send(item,dato):
|
|||||||
|
|
||||||
|
|
||||||
agsmenergia()
|
agsmenergia()
|
||||||
|
|
||||||
|
if platform.node() == 'ds7':
|
||||||
|
try:
|
||||||
|
subprocess.run(["docker","start", "SeleniumGrid"])
|
||||||
|
time.sleep(30)
|
||||||
|
zabbix_send('dockerstart',1)
|
||||||
|
except:
|
||||||
|
logger.error('Avvio docker fallito')
|
||||||
|
zabbix_send('dockerstart',0)
|
||||||
|
|
||||||
acqueveronesi()
|
acqueveronesi()
|
||||||
|
windtre()
|
||||||
|
|
||||||
|
if platform.node() == 'ds7':
|
||||||
|
subprocess.run(["docker","stop", "SeleniumGrid"])
|
||||||
Reference in New Issue
Block a user