forked from piair/MsRewards-Reborn
mise à jour automatique de chrome
This commit is contained in:
parent
200b0d8a86
commit
b45e9e549f
10
modules/Tools/generate_error.py
Normal file
10
modules/Tools/generate_error.py
Normal file
@ -0,0 +1,10 @@
|
||||
import abfvlj
|
||||
|
||||
import undetected_chromedriver as uc
|
||||
from pyvirtualdisplay.smartdisplay import SmartDisplay
|
||||
|
||||
display = SmartDisplay(size=(1920, 1080))
|
||||
display.start()
|
||||
driver = uc.Chrome()
|
||||
driver.close()
|
||||
driver.close()
|
48
modules/Tools/update_chrome.py
Normal file
48
modules/Tools/update_chrome.py
Normal file
@ -0,0 +1,48 @@
|
||||
import requests
|
||||
import re
|
||||
from packaging import version
|
||||
import subprocess
|
||||
|
||||
from logger import critical, info, error
|
||||
|
||||
errorMessage = subprocess.run(['python3', 'generate_error.py'], check=False, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE).stderr.decode("utf-8")
|
||||
|
||||
versionPattern = "This version of ChromeDriver only supports Chrome version ([0-9]+)"
|
||||
|
||||
try:
|
||||
versionN = re.search(versionPattern, errorMessage)[1]
|
||||
except Exception as e:
|
||||
critical("Can't get version number from error")
|
||||
error(e)
|
||||
exit(0)
|
||||
|
||||
info(f"Needed version : '{versionN}'")
|
||||
|
||||
downloadUrl = "http://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/"
|
||||
r = requests.get(downloadUrl)
|
||||
|
||||
content = r.text
|
||||
|
||||
exactVersionList = re.findall(f"(google-chrome-stable_({versionN}.[0-9.]+)[^<^>^\"]+)", content)
|
||||
|
||||
try:
|
||||
best = exactVersionList[0]
|
||||
except Exception as e:
|
||||
critical("No version matches required version")
|
||||
error(e)
|
||||
exit(0)
|
||||
|
||||
for i in exactVersionList:
|
||||
if version.parse(i[1]) > version.parse(best[1]):
|
||||
best = i
|
||||
|
||||
chromeDebURL = f"http://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/{best[0]}"
|
||||
info(f"chrome deb URL : {chromeDebURL}")
|
||||
info("downloading chrome")
|
||||
|
||||
subprocess.call(['wget', "-O", "/tmp/chrome.deb", chromeDebURL])
|
||||
info("Chrome deb downloaded. Installing chrome")
|
||||
|
||||
subprocess.call(["dpkg", "-i", "/tmp/chrome.deb"])
|
||||
info("Chrome installed")
|
Loading…
Reference in New Issue
Block a user