MCPcopy
hub / github.com/FlareSolverr/FlareSolverr / download_chromium

Function download_chromium

src/build_package.py:27–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25
26
27def download_chromium():
28 # https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/
29 revision = "1522586" if os.name == 'nt' else '1522586'
30 arch = 'Win_x64' if os.name == 'nt' else 'Linux_x64'
31 dl_file = 'chrome-win' if os.name == 'nt' else 'chrome-linux'
32 dl_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, 'dist_chrome')
33 dl_path_folder = os.path.join(dl_path, dl_file)
34 dl_path_zip = dl_path_folder + '.zip'
35
36 # response = requests.get(
37 # f'https://commondatastorage.googleapis.com/chromium-browser-snapshots/{arch}/LAST_CHANGE',
38 # timeout=30)
39 # revision = response.text.strip()
40 print("Downloading revision: " + revision)
41
42 os.mkdir(dl_path)
43 with requests.get(
44 f'https://commondatastorage.googleapis.com/chromium-browser-snapshots/{arch}/{revision}/{dl_file}.zip',
45 stream=True) as r:
46 r.raise_for_status()
47 with open(dl_path_zip, 'wb') as f:
48 for chunk in r.iter_content(chunk_size=8192):
49 f.write(chunk)
50 print("File downloaded: " + dl_path_zip)
51 with zipfile.ZipFile(dl_path_zip, 'r') as zip_ref:
52 zip_ref.extractall(dl_path)
53 os.remove(dl_path_zip)
54
55 chrome_path = os.path.join(dl_path, "chrome")
56 shutil.move(dl_path_folder, chrome_path)
57 print("Extracted in: " + chrome_path)
58
59 if os.name != 'nt':
60 # Give executable permissions for *nix
61 # file * | grep executable | cut -d: -f1
62 print("Giving executable permissions...")
63 execs = ['chrome', 'chrome_crashpad_handler', 'chrome_sandbox', 'chrome-wrapper', 'xdg-mime', 'xdg-settings']
64 for exec_file in execs:
65 exec_path = os.path.join(chrome_path, exec_file)
66 os.chmod(exec_path, 0o755)
67
68
69def run_pyinstaller():

Callers 1

build_package.pyFile · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected