Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions sherlock_project/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
from colorama import Fore, Style
import webbrowser

# Global variable to count the number of results.
globvar = 0


class QueryNotify:
"""Query Notify Object.
Expand Down Expand Up @@ -132,6 +129,7 @@ def __init__(self, result=None, verbose=False, print_all=False, browse=False):
self.verbose = verbose
self.print_all = print_all
self.browse = browse
self._result_count = 0


def start(self, message):
Expand Down Expand Up @@ -169,9 +167,8 @@ def countResults(self):
Return Value:
The number of results by the time we call the function.
"""
global globvar
globvar += 1
return globvar
self._result_count += 1
return self._result_count

def update(self, result):
"""Notify Update.
Expand Down Expand Up @@ -258,7 +255,7 @@ def finish(self, message="The processing has been finished."):
Return Value:
Nothing.
"""
NumberOfResults = self.countResults() - 1
NumberOfResults = self._result_count

print(Style.BRIGHT + Fore.GREEN + "[" +
Fore.YELLOW + "*" +
Expand Down
31 changes: 22 additions & 9 deletions sherlock_project/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import requests
import secrets
from pathlib import Path


MANIFEST_URL = "https://data.sherlockproject.xyz"
Expand Down Expand Up @@ -131,15 +132,27 @@ def __init__(
)

if response.status_code != 200:
raise FileNotFoundError(f"Bad response while accessing "
f"data file URL '{data_file_path}'."
)
try:
site_data = response.json()
except Exception as error:
raise ValueError(
f"Problem parsing json contents at '{data_file_path}': {error}."
)
local_fallback = Path(__file__).parent / "resources" / "data.json"
if local_fallback.exists():
print(
f"Warning: Remote data unavailable (HTTP {response.status_code}). "
"Falling back to bundled local data file."
)
with open(local_fallback, "r", encoding="utf-8") as f:
site_data = json.load(f)
else:
raise FileNotFoundError(
f"Bad response while accessing data file URL '{data_file_path}' "
f"(HTTP {response.status_code}). "
"Try updating: pip install -U sherlock-project"
)
else:
try:
site_data = response.json()
except Exception as error:
raise ValueError(
f"Problem parsing json contents at '{data_file_path}': {error}."
)

else:
# Reference is to a file.
Expand Down