diff --git a/peru/resources/plugins/curl/curl_plugin.py b/peru/resources/plugins/curl/curl_plugin.py index 668428d..a8ec74e 100755 --- a/peru/resources/plugins/curl/curl_plugin.py +++ b/peru/resources/plugins/curl/curl_plugin.py @@ -10,14 +10,19 @@ from urllib.error import HTTPError, URLError from urllib.parse import urlsplit from urllib.request import Request -import peru.main import urllib.request import zipfile +try: + from peru.main import get_version +except ModuleNotFoundError: + get_version = None + + def add_user_agent_to_request(request): components = [ - "peru/%s" % peru.main.get_version(), + "peru/%s" % get_version() if get_version else "peru", urllib.request.URLopener.version ] request.add_header("User-agent", " ".join(components))