|
@@ -0,0 +1,112 @@
|
|
|
+#!/usr/bin/env python3
|
|
|
+
|
|
|
+import requests
|
|
|
+import json
|
|
|
+import os.path
|
|
|
+from pprint import pprint
|
|
|
+
|
|
|
+LATEST = "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json"
|
|
|
+VERFILE = "version"
|
|
|
+
|
|
|
+r = requests.get(LATEST)
|
|
|
+
|
|
|
+data = r.json()
|
|
|
+stable = data['channels']['Stable']
|
|
|
+version = stable['version']
|
|
|
+update = False
|
|
|
+
|
|
|
+# Check current version against what is available.
|
|
|
+if os.path.exists(VERFILE):
|
|
|
+ with open(VERFILE, "rt") as fp:
|
|
|
+ current_version = fp.readline().strip()
|
|
|
+ print(f"Current version: {current_version}")
|
|
|
+ if current_version != version:
|
|
|
+ update = True
|
|
|
+else:
|
|
|
+ update = True
|
|
|
+
|
|
|
+if update:
|
|
|
+ with open(VERFILE, "wt") as fp:
|
|
|
+ print(f"{version}", file=fp)
|
|
|
+
|
|
|
+print(f"Google Chrome {version}")
|
|
|
+
|
|
|
+if not update:
|
|
|
+ os.sys.exit()
|
|
|
+
|
|
|
+# Ok, we need to update
|
|
|
+
|
|
|
+NEED = ("chrome", "chromedriver")
|
|
|
+grab = list()
|
|
|
+
|
|
|
+# I need chrome and chromedriver for linux64
|
|
|
+for d in stable['downloads']:
|
|
|
+ if d in NEED:
|
|
|
+ # Ok, that's something we need!
|
|
|
+ for platform in stable['downloads'][d]:
|
|
|
+ if platform['platform'] == "linux64":
|
|
|
+ grab.append(platform['url'])
|
|
|
+ break
|
|
|
+
|
|
|
+# Ok, lets grab some files here
|
|
|
+def download_file(url):
|
|
|
+ local_filename = url.split('/')[-1]
|
|
|
+ print(f"Download {url} to {local_filename}")
|
|
|
+ # NOTE the stream=True parameter below
|
|
|
+ with requests.get(url, stream=True) as r:
|
|
|
+ r.raise_for_status()
|
|
|
+ with open(local_filename, 'wb') as f:
|
|
|
+ for chunk in r.iter_content(chunk_size=8192):
|
|
|
+ # If you have chunk encoded response uncomment if
|
|
|
+ # and set chunk_size parameter to None.
|
|
|
+ #if chunk:
|
|
|
+ f.write(chunk)
|
|
|
+ print("Done")
|
|
|
+ return local_filename
|
|
|
+
|
|
|
+for g in grab:
|
|
|
+ download_file(g)
|
|
|
+
|
|
|
+# Ok, now what needs to be done?
|
|
|
+# unzip, remove chrome-linux64, chromedriver-linux64 directories.
|
|
|
+# pprint(stable)
|
|
|
+# pprint(grab)
|
|
|
+
|
|
|
+"""
|
|
|
+{'channel': 'Stable',
|
|
|
+ 'downloads': {'chrome': [{'platform': 'linux64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/linux64/chrome-linux64.zip'},
|
|
|
+ {'platform': 'mac-arm64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/mac-arm64/chrome-mac-arm64.zip'},
|
|
|
+ {'platform': 'mac-x64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/mac-x64/chrome-mac-x64.zip'},
|
|
|
+ {'platform': 'win32',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/win32/chrome-win32.zip'},
|
|
|
+ {'platform': 'win64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/win64/chrome-win64.zip'}],
|
|
|
+ 'chrome-headless-shell': [{'platform': 'linux64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/linux64/chrome-headless-shell-linux64.zip'},
|
|
|
+ {'platform': 'mac-arm64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/mac-arm64/chrome-headless-shell-mac-arm64.zip'},
|
|
|
+ {'platform': 'mac-x64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/mac-x64/chrome-headless-shell-mac-x64.zip'},
|
|
|
+ {'platform': 'win32',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/win32/chrome-headless-shell-win32.zip'},
|
|
|
+ {'platform': 'win64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/win64/chrome-headless-shell-win64.zip'}],
|
|
|
+ 'chromedriver': [{'platform': 'linux64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/linux64/chromedriver-linux64.zip'},
|
|
|
+ {'platform': 'mac-arm64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/mac-arm64/chromedriver-mac-arm64.zip'},
|
|
|
+ {'platform': 'mac-x64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/mac-x64/chromedriver-mac-x64.zip'},
|
|
|
+ {'platform': 'win32',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/win32/chromedriver-win32.zip'},
|
|
|
+ {'platform': 'win64',
|
|
|
+ 'url': 'https://storage.googleapis.com/chrome-for-testing-public/134.0.6998.35/win64/chromedriver-win64.zip'}]},
|
|
|
+ 'revision': '1415337',
|
|
|
+ 'version': '134.0.6998.35'}
|
|
|
+"""
|
|
|
+
|
|
|
+
|
|
|
+
|