aboutsummaryrefslogtreecommitdiff
path: root/cli/onionshare_cli/common.py
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2020-11-29 11:08:46 -0800
committerMicah Lee <micah@micahflee.com>2020-11-29 11:08:46 -0800
commitaecaae896d36b98ee745148f1efe7aa74497b945 (patch)
tree67cbed7e358b8d4919a871f48bc958386f39658c /cli/onionshare_cli/common.py
parent7bcfe6cad11036feeb52b199a9f0736ff35e21d6 (diff)
downloadonionshare-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.py10
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")