No-Ip Renew: error while executing Python script

Salut. Il y a plusieurs sujets avec le même titre mais je n’ai pas trouvé de solution.
Jeedom 4.2.20 tournant sur une VM proxmox en utilisant l’image Debian GNU/Linux 10 (buster) 64bits ()
Version du plugin: 2021-11-14 16:01:50

Launch install of noip dependencies

-- Current OS version :
Description:	Debian GNU/Linux 10 (buster)

-- Updating repo...
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://security.debian.org/debian-security buster/updates/non-free Sources [688 B]
Get:3 http://security.debian.org/debian-security buster/updates/non-free amd64 Packages [556 B]
Hit:4 http://ftp.es.debian.org/debian buster InRelease
Get:5 http://ftp.es.debian.org/debian buster-updates InRelease [51.9 kB]
Hit:6 https://deb.nodesource.com/node_16.x buster InRelease
Fetched 119 kB in 1s (141 kB/s)
Reading package lists...

-- Installation of python3 and dependencies
Reading package lists...
Building dependency tree...
Reading state information...
build-essential is already the newest version (12.6).
python-dev is already the newest version (2.7.16-1).
python3 is already the newest version (3.7.3-1).
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.

-- Installed version of Python :
Python 3.7.3
  Your version of python is compatible with this plugin.

-- Installation of pip for python3 and necessary libraries
Reading package lists...
Building dependency tree...
Reading state information...
python3-pip is already the newest version (18.1-5).
python3-dev is already the newest version (3.7.3-1).
python-requests is already the newest version (2.21.0-1).
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.

-- Installation of chromium
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package chromium-chromedriver
Reading package lists...
Building dependency tree...
Reading state information...
chromium-driver is already the newest version (90.0.4430.212-1~deb10u1).
0 upgraded, 0 newly installed, 0 to remove and 13 not upgraded.
Reading package lists...
Building dependency tree...
Reading state information...
Package chromium-browser is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'chromium-browser' has no installation candidate


-- Installed version of pip :
pip 22.1.2 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)

-- Installation of python library 'selenium' with command pip3.7
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Requirement already satisfied: selenium in /usr/local/lib/python3.7/dist-packages (4.3.0)
Requirement already satisfied: trio~=0.17 in /usr/local/lib/python3.7/dist-packages (from selenium) (0.21.0)
Requirement already satisfied: trio-websocket~=0.9 in /usr/local/lib/python3.7/dist-packages (from selenium) (0.9.2)
Requirement already satisfied: urllib3[secure,socks]~=1.26 in /usr/local/lib/python3.7/dist-packages (from selenium) (1.26.9)
Requirement already satisfied: idna in /usr/local/lib/python3.7/dist-packages (from trio~=0.17->selenium) (3.3)
Requirement already satisfied: outcome in /usr/local/lib/python3.7/dist-packages (from trio~=0.17->selenium) (1.2.0)
Requirement already satisfied: attrs>=19.2.0 in /usr/local/lib/python3.7/dist-packages (from trio~=0.17->selenium) (21.4.0)
Requirement already satisfied: async-generator>=1.9 in /usr/local/lib/python3.7/dist-packages (from trio~=0.17->selenium) (1.10)
Requirement already satisfied: sortedcontainers in /usr/local/lib/python3.7/dist-packages (from trio~=0.17->selenium) (2.4.0)
Requirement already satisfied: sniffio in /usr/local/lib/python3.7/dist-packages (from trio~=0.17->selenium) (1.2.0)
Requirement already satisfied: wsproto>=0.14 in /usr/local/lib/python3.7/dist-packages (from trio-websocket~=0.9->selenium) (1.1.0)
Requirement already satisfied: cryptography>=1.3.4 in /usr/local/lib/python3.7/dist-packages (from urllib3[secure,socks]~=1.26->selenium) (37.0.4)
Requirement already satisfied: certifi in /usr/local/lib/python3.7/dist-packages (from urllib3[secure,socks]~=1.26->selenium) (2022.6.15)
Requirement already satisfied: pyOpenSSL>=0.14 in /usr/local/lib/python3.7/dist-packages (from urllib3[secure,socks]~=1.26->selenium) (22.0.0)
Requirement already satisfied: PySocks!=1.5.7,<2.0,>=1.5.6 in /usr/local/lib/python3.7/dist-packages (from urllib3[secure,socks]~=1.26->selenium) (1.7.1)
Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.7/dist-packages (from cryptography>=1.3.4->urllib3[secure,socks]~=1.26->selenium) (1.15.1)
Requirement already satisfied: h11<1,>=0.9.0 in /usr/local/lib/python3.7/dist-packages (from wsproto>=0.14->trio-websocket~=0.9->selenium) (0.13.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.7/dist-packages (from cffi>=1.12->cryptography>=1.3.4->urllib3[secure,socks]~=1.26->selenium) (2.21)
Requirement already satisfied: typing-extensions in /usr/local/lib/python3.7/dist-packages (from h11<1,>=0.9.0->wsproto>=0.14->trio-websocket~=0.9->selenium) (4.3.0)

-- Installation of dependencies is done !

[2022-07-07 10:13:15][INFO] : syncNoIp
[2022-07-07 10:13:15][INFO] : Lancement script No-Ip : sudo python3 /var/www/html/plugins/noip/core/class/../../resources/noip-renew.py euepunto@hotmail.com "#####" 2 0 /var/www/html/plugins/noip/core/class/../.. 2
[2022/07/07 10:13:16] - Debug level: 2
[2022/07/07 10:13:16] - Opening https://www.noip.com/login...
[2022/07/07 10:13:18] - Logging in...
[2022/07/07 10:13:18] - 'WebDriver' object has no attribute 'find_element_by_name'
[2022-07-07 10:13:18][DEBUG] : [Monitoreo][No-IP] file content: {"msg": "'WebDriver' object has no attribute 'find_element_by_name'"}
[2022-07-07 10:13:18][ERROR] : [Monitoreo][No-IP] error while executing Python script: 

Bonjour,
J’ai le même problème !
Quelqu’un as une solution ???
Merci

Bonjour. Est-ce que quelqu’un a une idée? Merci.

1 « J'aime »

J’ai résolu mon problème comme ça :

wget http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-codecs-ffmpeg-extra_90.0.4430.72-0ubuntu0.16.04.1_amd64.deb
dpkg -i chromium-codecs-ffmpeg-extra_90.0.4430.72-0ubuntu0.16.04.1_amd64.deb
wget http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-browser_90.0.4430.72-0ubuntu0.16.04.1_amd64.deb
dpkg -i chromium-browser_90.0.4430.72-0ubuntu0.16.04.1_amd64.deb

Si besoin il faut adapter le script /var/www/html/plugins/noip/resources/noip-renew.py de la manière suivante :

#!/usr/bin/env python3
# Copyright 2017 loblab
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from datetime import date
from datetime import timedelta
from selenium.webdriver.common.by import By
import time
import sys
import os
import re
import base64
import json

class Logger:
    def __init__(self, level):
        self.level = 0 if level is None else level

    def log(self, msg, level=None):
        self.time_string_formatter = time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(time.time()))
        self.level = self.level if level is None else level
        if self.level > 0:
            print("[{mydate}] - {msg}".format(mydate=self.time_string_formatter,msg=msg))


class Robot:

    USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:64.0) Gecko/20100101 Firefox/64.0"
    LOGIN_URL = "https://www.noip.com/login"
    HOST_URL = "https://my.noip.com/dynamic-dns"

    def __init__(self, username, password, threshold, renew, rootpath, debug):
        self.debug = debug
        self.username = username
        self.password = password
        self.threshold = threshold
        self.renew = renew
        self.rootpath = rootpath
        self.browser = self.init_browser()
        self.logger = Logger(debug)
        self.data = []

    @staticmethod
    def init_browser():
        options = webdriver.ChromeOptions()
        #added for Raspbian Buster 4.0+ versions. Check https://www.raspberrypi.org/forums/viewtopic.php?t=258019 for reference.
        options.add_argument("disable-features=VizDisplayCompositor")
        options.add_argument("headless")
        options.add_argument("no-sandbox")  # need when run in docker
        options.add_argument("window-size=1200x800")
        options.add_argument("user-agent={USER_AGENT}".format(USER_AGENT=Robot.USER_AGENT))
        if 'https_proxy' in os.environ:
            options.add_argument("proxy-server=" + os.environ['https_proxy'])
        browser = webdriver.Chrome(options=options)
        browser.set_page_load_timeout(90) # Extended timeout for Raspberry Pi.
        return browser

    def login(self):
        self.logger.log("Opening {LOGIN_URL}...".format(LOGIN_URL=Robot.LOGIN_URL))
        self.browser.get(Robot.LOGIN_URL)
        if self.debug > 1:
            self.browser.save_screenshot(self.rootpath + "/data/debug1.png")

        self.logger.log("Logging in...")
        ele_usr = self.browser.find_element(By.NAME, "username")#find_element_by_name("username")
        ele_pwd = self.browser.find_element(By.NAME, "password")#find_element_by_name("password")
        ele_usr.send_keys(self.username)
        #ele_pwd.send_keys(base64.b64decode(self.password).decode('utf-8'))
        ele_pwd.send_keys(self.password)

        button_found = False
       
        try:
            # self.browser.find_element(By.NAME, "Login").click()#find_element_by_name("Login").click()
            self.browser.find_element(By.ID, "clogs-captcha-button").click()#find_element_by_name("Login").click()
            button_found = True
        except Exception as e:
            if self.debug > 1:
                self.logger.log("DEBUG: Element by name login not found: {e}".format(e=str(e)))
        
        if button_found == False:
            try:
                self.browser.find_element(By.XPATH, '//button[@data-action="login"]').click()#find_element_by_xpath('//button[@data-action="login"]').click()
                button_found = True
            except Exception as e:
                if self.debug > 1:
                    self.logger.log("DEBUG: Element by attr data-action=login not found: {e}".format(e=str(e))) 

        if button_found == False:
            try:
                self.browser.find_element(By.XPATH, '//button[@id="clogs-captcha-button"]').click()#find_element_by_xpath('//button[@id="clogs-captcha-button"]').click()
                button_found = True
            except Exception as e:
                self.logger.log("ERROR: Element by attr id=clogs-captcha-button not found: {e}".format(e=str(e))) 
                raise Exception('Login button not found')

        time.sleep(3)
        if self.debug > 1:
            self.browser.save_screenshot(self.rootpath + "/data/debug2.png")

    def update_hosts(self):
        count = 0

        self.open_hosts_page()
        time.sleep(3)
        iteration = 1

        hosts = self.get_hosts()
        for host in hosts:
            host_link = self.get_host_link(host, iteration) # This is for if we wanted to modify our Host IP.
            host_button = self.get_host_button(host, iteration) # This is the button to confirm our free host
            host_name = host_link.text
            if self.debug > 1:
                self.logger.log("Dealing with {host_name}".format(host_name=host_name)) 
            expiration_days = self.get_host_expiration_days(self, host, iteration)
            self.logger.log("{host_name} expires in {expiration_days} days".format(host_name=host_name,expiration_days=str(expiration_days)))
            renewed = "ok"
            if expiration_days <= 7:
                renewed = "warning"
            if self.renew > 0 and expiration_days < self.threshold:
                renewed = self.update_host(host_button, host_name)
                if renewed == "ok":
                    expiration_days = self.get_host_expiration_days(self, host, iteration)
                count += 1
            iteration += 1
            self.data.append({'hostname':host_name, 'expirationdays':expiration_days, 'renewed':renewed})
        self.browser.save_screenshot(self.rootpath + "/data/results.png")
        self.logger.log("Confirmed hosts: {count}".format(count=str(count)))
        return True

    def open_hosts_page(self):
        self.logger.log("Opening {HOST_URL}...".format(HOST_URL=Robot.HOST_URL))
        try:
            self.browser.get(Robot.HOST_URL)
        except TimeoutException as e:
            self.browser.save_screenshot(self.rootpath + "/data/timeout.png")
            self.logger.log("Timeout: {e}".format(e=str(e)))

    def update_host(self, host_button, host_name):
        self.logger.log("Updating {host_name}".format(host_name=host_name))
        host_button.click()
        time.sleep(3)
        intervention = False
        try:
            if self.browser.find_elements_by_xpath("//h2[@class='big']")[0].text == "Upgrade Now":
                intervention = True      
        except:
            pass

        if intervention:
            if self.debug > 1:
                self.browser.save_screenshot(self.rootpath + "/data/intervention.png")
            self.logger.log("{host_name} requires manual intervention for update".format(host_name=host_name,))
            return "error"
        else:
            self.browser.save_screenshot(self.rootpath + "/data/{host_name}_success.png".format(host_name=host_name))
            return "ok"       

    @staticmethod
    def get_host_expiration_days(self, host, iteration):
        try:
            host_remaining_days = host.find_element(By.XPATH, ".//a[contains(@class,'no-link-style')]").get_attribute("data-original-title")#find_element_by_xpath(".//a[contains(@class,'no-link-style')]").get_attribute("data-original-title")
            if host_remaining_days is None:
                host_remaining_days = host.find_element(By.XPATH, ".//a[contains(@class,'no-link-style')]").text#find_element_by_xpath(".//a[contains(@class,'no-link-style')]").text
            if self.debug > 1:
                self.logger.log("host remaining days found: {days}".format(days=str(host_remaining_days))) 
        except:
            host_remaining_days = "Expires in 0 days"
            pass
        regex_match = re.search("\\d+", host_remaining_days)
        #if regex_match is None:
        #    host_remaining_days = host.find_element_by_xpath(".//a[@class='no-link-style']").text
        #regex_match = re.search("\\d+", host_remaining_days)
        if regex_match is None:    
            raise Exception("Expiration days label does not match the expected pattern")
        expiration_days = int(regex_match.group(0))
        return expiration_days

    @staticmethod
    def get_host_link(host, iteration):
        return host.find_element(By.XPATH, ".//a[@class='link-info cursor-pointer']")#find_element_by_xpath(".//a[@class='link-info cursor-pointer']")

    @staticmethod
    def get_host_button(host, iteration):
        return host.find_element(By.XPATH, ".//following-sibling::td[4]/button[contains(@class, 'btn')]")#find_element_by_xpath(".//following-sibling::td[4]/button[contains(@class, 'btn')]")

    def get_hosts(self):
        if self.debug > 1:
            self.logger.log("Getting hosts list...") 
        host_tds = self.browser.find_elements(By.XPATH, "//td[@data-title=\"Host\"]")#find_elements_by_xpath("//td[@data-title=\"Host\"]")
        if len(host_tds) == 0:
            raise Exception("No hosts or host table rows not found")
        if self.debug > 1:
            self.browser.save_screenshot(self.rootpath + "/data/debug3.png")
        return host_tds

    def run(self):
        rc = 0
        self.logger.log("Debug level: {debug}".format(debug=str(self.debug)))
        try:
            self.login()
            if not self.update_hosts():
                rc = 3
        except Exception as e:
            self.logger.log(str(e))
            self.browser.save_screenshot(self.rootpath + "/data/exception.png")
            self.data = {'msg':str(e)}
            rc = 2
        finally:
            self.browser.quit()
            myfile = open(self.rootpath + "/data/output.json", "w")
            json.dump(self.data, myfile)
            myfile.close()
        return rc


def main(argv=None):
    noip_username, noip_password, noip_threshold, noip_renew, noip_rootpath, debug,  = get_args_values(argv)
    return (Robot(noip_username, noip_password, noip_threshold, noip_renew, noip_rootpath, debug)).run()


def get_args_values(argv):
    if argv is None:
        argv = sys.argv
    if len(argv) < 3:
        print("Usage: <noip_username> <noip_password> <threshold> <renew> <rootpath> [<debug-level>]")
        sys.exit(1)

    noip_username = argv[1]
    noip_password = argv[2]
    noip_threshold = int(argv[3])
    noip_renew = int(argv[4])
    noip_rootpath = argv[5]
    debug = 1
    if len(argv) > 6:
        debug = int(argv[6])
    return noip_username, noip_password, noip_threshold, noip_renew, noip_rootpath, debug


if __name__ == "__main__":
    sys.exit(main())

4 « J'aime »

Résolu. Merci.

Bonjour,

je profite du sujet car j’ai le même problème.
J’ai donc remplacer le script /var/www/html/plugins/noip/resources/noip-renew.py comme le décrit Arnaud, mais cela ne fonctionne pas.
Config : jeedom V4.2.21

  • Dans le panneau de configuration lorsque je clique sur OPTIONS / Visible, le dashboard séléctionné ne s’affiche pas.
  • d
    Dès que je fait une modification dans le plugin-noip/ équipement j’ai un message d’erreur :

Dans le log :

Merci

Hello,

Toujours eu le même souci et signalé il y a un paquet de mois (ou plus). C’est pour cela que ce plugin n’a jamais été installé sur autre chose que ma maquette sur laquelle je veux bien lancer des commandes manuellement.

Par contre, sur du stable, je ne veux pas commencer à faire ça (même si je sais ce que je fais) car c’est censé être géré au niveau de l’installation des dépendances.
Mais présent pour des éventuels tests.

Ce sujet a été automatiquement fermé après 24 heures suivant le dernier commentaire. Aucune réponse n’est permise dorénavant.