From 0ece8bf672f0796b13d20df035b640c921ad823d Mon Sep 17 00:00:00 2001 From: Paul Pfeister Date: Sun, 30 Jun 2024 22:32:31 -0400 Subject: [PATCH 1/3] Except ImportErrors induced by legacy run method --- sherlock/__init__.py | 3 +++ sherlock/sherlock.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sherlock/__init__.py b/sherlock/__init__.py index 5bf79e24..2e97d156 100644 --- a/sherlock/__init__.py +++ b/sherlock/__init__.py @@ -5,6 +5,9 @@ networks. """ +# This variable is only used to check for ImportErrors induced by users running as script rather than as module or package +importErrTestVar = None + __shortname__ = "Sherlock" __longname__ = "Sherlock: Find Usernames Across Social Networks" __version__ = "0.14.4" diff --git a/sherlock/sherlock.py b/sherlock/sherlock.py index db8e9c2c..1da83bd5 100644 --- a/sherlock/sherlock.py +++ b/sherlock/sherlock.py @@ -7,12 +7,21 @@ This module contains the main logic to search for usernames at social networks. """ +import sys + +try: + from sherlock.__init__ import importErrTestVar # noqa: F401 +except ImportError: + print("Did you run Sherlock with `python3 sherlock/sherlock.py ...`?") + print("This is an outdated method. Please see https://sherlockproject.xyz/installation for up to date instructions.") + print("Most users can simply run `pipx install sherlock-project`, but other options are detailed on the website.") + sys.exit(1) + import csv import signal import pandas as pd import os import re -import sys from argparse import ArgumentParser, RawDescriptionHelpFormatter from time import monotonic From 80e61cd3bef11be41eea581c35cfb754774e73ae Mon Sep 17 00:00:00 2001 From: Paul Pfeister Date: Mon, 8 Jul 2024 01:34:20 -0400 Subject: [PATCH 2/3] Shrink error message --- sherlock/sherlock.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sherlock/sherlock.py b/sherlock/sherlock.py index 1da83bd5..bbd5a72c 100644 --- a/sherlock/sherlock.py +++ b/sherlock/sherlock.py @@ -14,7 +14,6 @@ try: except ImportError: print("Did you run Sherlock with `python3 sherlock/sherlock.py ...`?") print("This is an outdated method. Please see https://sherlockproject.xyz/installation for up to date instructions.") - print("Most users can simply run `pipx install sherlock-project`, but other options are detailed on the website.") sys.exit(1) import csv From f1d4a841eb934cde3efb4696dfe9b589c2fe444b Mon Sep 17 00:00:00 2001 From: Paul Pfeister Date: Mon, 8 Jul 2024 01:36:24 -0400 Subject: [PATCH 3/3] Switch to snake_case --- sherlock/__init__.py | 2 +- sherlock/sherlock.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sherlock/__init__.py b/sherlock/__init__.py index 2e97d156..91f8f66e 100644 --- a/sherlock/__init__.py +++ b/sherlock/__init__.py @@ -6,7 +6,7 @@ networks. """ # This variable is only used to check for ImportErrors induced by users running as script rather than as module or package -importErrTestVar = None +import_error_test_var = None __shortname__ = "Sherlock" __longname__ = "Sherlock: Find Usernames Across Social Networks" diff --git a/sherlock/sherlock.py b/sherlock/sherlock.py index bbd5a72c..2ebd0d74 100644 --- a/sherlock/sherlock.py +++ b/sherlock/sherlock.py @@ -10,7 +10,7 @@ networks. import sys try: - from sherlock.__init__ import importErrTestVar # noqa: F401 + from sherlock.__init__ import import_error_test_var # noqa: F401 except ImportError: print("Did you run Sherlock with `python3 sherlock/sherlock.py ...`?") print("This is an outdated method. Please see https://sherlockproject.xyz/installation for up to date instructions.")