mirror of
https://forge.fsky.io/oneflux/omegafox.git
synced 2026-02-11 01:52:04 -08:00
pythonlib: Fixes & cleanup
- Fix chmod not working - Add more instructions to README - Cleanup comments
This commit is contained in:
parent
a05379fd38
commit
581cb5ce3f
3 changed files with 19 additions and 10 deletions
|
|
@ -7,12 +7,22 @@
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
First, install the `camoufox` package:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/camoufox
|
git clone --depth 1 https://github.com/camoufox
|
||||||
cd camoufox/pythonlib
|
cd camoufox/pythonlib
|
||||||
pip install .
|
pip install .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Then, download the Camoufox browser:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
camoufox fetch
|
||||||
|
```
|
||||||
|
|
||||||
|
To uninstall, run `camoufox remove`.
|
||||||
|
|
||||||
<hr width=50>
|
<hr width=50>
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ def cli() -> None:
|
||||||
|
|
||||||
|
|
||||||
@cli.command(name='fetch')
|
@cli.command(name='fetch')
|
||||||
def fetch():
|
def fetch() -> None:
|
||||||
"""
|
"""
|
||||||
Fetch the latest version of Camoufox
|
Fetch the latest version of Camoufox
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
@ -69,10 +70,9 @@ class CamoufoxFetcher:
|
||||||
Get the current platform and architecture information.
|
Get the current platform and architecture information.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
str: The architecture of the current platform
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
UnsupportedOS: If the current OS is not supported
|
|
||||||
UnsupportedArchitecture: If the current architecture is not supported
|
UnsupportedArchitecture: If the current architecture is not supported
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -125,7 +125,7 @@ class CamoufoxFetcher:
|
||||||
url (str): The URL to download the file from
|
url (str): The URL to download the file from
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
BytesIO: The downloaded file content as a BytesIO object
|
DownloadBuffer: The downloaded file content as a BytesIO object
|
||||||
"""
|
"""
|
||||||
rprint(f'Downloading package: {url}')
|
rprint(f'Downloading package: {url}')
|
||||||
return webdl(url, buffer=file)
|
return webdl(url, buffer=file)
|
||||||
|
|
@ -135,7 +135,7 @@ class CamoufoxFetcher:
|
||||||
Extract the contents of a zip file to the installation directory.
|
Extract the contents of a zip file to the installation directory.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
zip_file (BytesIO): The zip file content as a BytesIO object
|
zip_file (DownloadBuffer): The zip file content as a BytesIO object
|
||||||
"""
|
"""
|
||||||
rprint(f'Extracting Camoufox: {INSTALL_DIR}')
|
rprint(f'Extracting Camoufox: {INSTALL_DIR}')
|
||||||
unzip(zip_file, str(INSTALL_DIR))
|
unzip(zip_file, str(INSTALL_DIR))
|
||||||
|
|
@ -177,11 +177,10 @@ class CamoufoxFetcher:
|
||||||
self.extract_zip(temp_file)
|
self.extract_zip(temp_file)
|
||||||
self.set_version()
|
self.set_version()
|
||||||
|
|
||||||
# Run chmod -R 755 on INSTALL_DIR
|
# Set permissions on INSTALL_DIR
|
||||||
if OS_NAME != 'win':
|
if OS_NAME != 'win':
|
||||||
shutil.chmod(INSTALL_DIR, 0o755)
|
os.system(f'chmod -R 755 {shlex.quote(str(INSTALL_DIR))}')
|
||||||
|
|
||||||
# Clean up old installation
|
|
||||||
rprint('\nCamoufox successfully installed.', fg="yellow")
|
rprint('\nCamoufox successfully installed.', fg="yellow")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
rprint(f"Error installing Camoufox: {str(e)}")
|
rprint(f"Error installing Camoufox: {str(e)}")
|
||||||
|
|
@ -302,7 +301,7 @@ def webdl(
|
||||||
Raises:
|
Raises:
|
||||||
requests.RequestException: If there's an error downloading the file
|
requests.RequestException: If there's an error downloading the file
|
||||||
"""
|
"""
|
||||||
response = requests.get(url, stream=True, timeout=20)
|
response = requests.get(url, stream=True)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|
||||||
total_size = int(response.headers.get('content-length', 0))
|
total_size = int(response.headers.get('content-length', 0))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue