mirror of
https://github.com/daijro/camoufox.git
synced 2026-09-07 00:00:42 +00:00
Exception handling
This commit is contained in:
@@ -200,14 +200,18 @@ def cli() -> None:
|
||||
|
||||
|
||||
@cli.command(name='sync')
|
||||
@click.option('--spoof-os', type=click.Choice(['mac', 'win', 'lin']), help='Spoof OS')
|
||||
@click.option('--spoof-os', type=click.Choice(['auto', 'mac', 'win', 'lin']), help='Spoof OS (auto = native)')
|
||||
@click.option(
|
||||
'--spoof-arch', type=click.Choice(['x86_64', 'i686', 'arm64']), help='Spoof architecture'
|
||||
'--spoof-arch', type=click.Choice(['auto', 'x86_64', 'i686', 'arm64']), help='Spoof architecture (auto = native)'
|
||||
)
|
||||
def sync(spoof_os, spoof_arch):
|
||||
"""
|
||||
Sync available versions from remote repositories.
|
||||
"""
|
||||
if spoof_os == 'auto':
|
||||
spoof_os = None
|
||||
if spoof_arch == 'auto':
|
||||
spoof_arch = None
|
||||
_do_sync(spoof_os=spoof_os, spoof_arch=spoof_arch)
|
||||
|
||||
|
||||
|
||||
@@ -608,6 +608,8 @@ def installed_verstr() -> str:
|
||||
from .multiversion import get_active_path
|
||||
|
||||
active = get_active_path()
|
||||
if active is None:
|
||||
raise FileNotFoundError("No active version. Please run `camoufox fetch` to install.")
|
||||
return Version.from_path(active).full_string
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ from typing_extensions import Literal
|
||||
|
||||
from camoufox.virtdisplay import VirtualDisplay
|
||||
|
||||
from .exceptions import InvalidProxy
|
||||
from .utils import launch_options, sync_attach_vd
|
||||
|
||||
|
||||
@@ -28,8 +29,8 @@ class Camoufox(PlaywrightContextManager):
|
||||
super().__enter__()
|
||||
try:
|
||||
self.browser = NewBrowser(self._playwright, **self.launch_options)
|
||||
except camoufox.exceptions.InvalidProxy as e:
|
||||
super().__exit__(camoufox.exceptions.InvalidProxy, e, None)
|
||||
except InvalidProxy as e:
|
||||
super().__exit__(InvalidProxy, e, None)
|
||||
raise
|
||||
return self.browser
|
||||
|
||||
|
||||
Reference in New Issue
Block a user