diff options
author | Micah Lee <micah@micahflee.com> | 2020-11-29 11:08:46 -0800 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2020-11-29 11:08:46 -0800 |
commit | aecaae896d36b98ee745148f1efe7aa74497b945 (patch) | |
tree | 67cbed7e358b8d4919a871f48bc958386f39658c /cli/onionshare_cli/common.py | |
parent | 7bcfe6cad11036feeb52b199a9f0736ff35e21d6 (diff) | |
download | onionshare-aecaae896d36b98ee745148f1efe7aa74497b945.tar.gz onionshare-aecaae896d36b98ee745148f1efe7aa74497b945.zip |
Make CLI throw an error if it cannot find tor binary
Diffstat (limited to 'cli/onionshare_cli/common.py')
-rw-r--r-- | cli/onionshare_cli/common.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cli/onionshare_cli/common.py b/cli/onionshare_cli/common.py index a1213387..e8b174b6 100644 --- a/cli/onionshare_cli/common.py +++ b/cli/onionshare_cli/common.py @@ -34,6 +34,12 @@ from pkg_resources import resource_filename from .settings import Settings +class CannotFindTor(Exception): + """ + OnionShare can't find a tor binary + """ + + class Common: """ The Common object is shared amongst all parts of OnionShare. @@ -82,6 +88,8 @@ class Common: def get_tor_paths(self): if self.platform == "Linux": tor_path = shutil.which("tor") + if not tor_path: + raise CannotFindTor() obfs4proxy_file_path = shutil.which("obfs4proxy") prefix = os.path.dirname(os.path.dirname(tor_path)) tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip") @@ -94,6 +102,8 @@ class Common: tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6") elif self.platform == "Darwin": tor_path = shutil.which("tor") + if not tor_path: + raise CannotFindTor() obfs4proxy_file_path = shutil.which("obfs4proxy") prefix = os.path.dirname(os.path.dirname(tor_path)) tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip") |