Skip to content
Open
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
19 changes: 16 additions & 3 deletions shodan/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import csv
import os
import os.path
import pkg_resources
import shodan
import shodan.helpers as helpers
import threading
import requests
import time
import json
import sys

# The file converters that are used to go from .json.gz to various other formats
from shodan.cli.converter import CsvConverter, KmlConverter, GeoJsonConverter, ExcelConverter, ImagesConverter
Expand All @@ -50,7 +50,13 @@

# Allow 3rd-parties to develop custom commands
from click_plugins import with_plugins
from pkg_resources import iter_entry_points
if sys.version_info >= (3, 10):
from importlib.metadata import entry_points

def iter_entry_points(name):
return entry_points(group=name)
else:
from pkg_resources import iter_entry_points

# Large subcommands are stored in separate modules
from shodan.cli.alert import alert
Expand Down Expand Up @@ -942,7 +948,14 @@ def radar():
@main.command()
def version():
"""Print version of this tool."""
print(pkg_resources.get_distribution("shodan").version)
try:
from importlib import metadata

print(metadata.version("shodan"))
except ImportError:
import pkg_resources

print(pkg_resources.get_distribution("shodan").version)


if __name__ == '__main__':
Expand Down